Page 1 of 1 1
Topic Options
#17866 - 2002-02-23 01:24 PM How to set a filename als variable
maikl Offline
Fresh Scripter

Registered: 2002-02-23
Posts: 5
Loc: Germany
How can j set a changing filename
as Variable?

zb.
sdat4321.exe

later

sdat4322.exe
...

thx
maikl

Top
#17867 - 2002-02-23 02:41 PM Re: How to set a filename als variable
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
$sdat=dir("path\sdat????.exe",1)

[ 23 February 2002: Message edited by: Radimus ]

_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#17868 - 2002-02-23 05:32 PM Re: How to set a filename als variable
Will Hetrick Offline
Hey THIS is FUN

Registered: 2001-10-02
Posts: 320
Loc: Harrisburg, PA USA
This bit of code will find the newest sdat file in the server path of your choice no matter how many sdat's are in the directory.
code:
 
;
;------Finds an Superdat in the Server path
$sdatName=Dir($ServPath + "sdat*.exe")
;------Look for a more recent superdat
While $sdatName <>"" AND @ERROR = 0
If $sdatname <>""
$sname=$sdatname
EndIf
$sdatName=Dir() ; retrieve next file
Loop

_________________________
You have at least 2 choices. Each choice changes your destiny. Choose wisely!

Top
#17869 - 2002-02-23 06:05 PM Re: How to set a filename als variable
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Will,
I think you're missing some code. There's nothing that compares for the newest.
I have a similar need for NAV. THe difference is the revision number is in hex otherwise the basic logic is the same. I do a value compare rather than a date compare is there can be several releases in one day.
code:

$TempDir ="C:\Test\Temp" ; ###change to where your's will go###
$WorkDir ="C:\Test" ; ###change to where your's will go###
$VPHome ="C:\Test\NAV" ; ###change to where your NAV parent's .vdb files exist###
$Name = Dir($VPHome + "\*.vdb")
$Newest = $Name
While $Name <> "" and @ERROR = 0
If Not (GetFileAttr($VPHome + $name) & 16) ; sanity check - should not be a folder
If Val("&"+SubStr($Newest,3,6)) < Val("&"+SubStr($Name,3,6))
$Newest=$Name
EndIf
EndIf
$Name = Dir()
Loop

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#17870 - 2002-02-23 06:16 PM Re: How to set a filename als variable
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
all that code is nice... but functionally, for what is needed, just delete all the old sdats, and leave just the newest one.
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#17871 - 2002-02-23 06:28 PM Re: How to set a filename als variable
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I think the old ones are there for a reason, to fall back to an older pattern if the new one causes grief. It is after all one small script that runs only on one server a few times a day.

Oh, and another thought... You'd need this same code to determine what to delete...

[ 23 February 2002: Message edited by: LLigetfa ]

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.675 seconds in which 0.516 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org