#32001 - 2002-11-07 07:20 PM
Variable on the fly
|
kbarnett
Fresh Scripter
Registered: 2001-11-09
Posts: 28
|
I hope someone can help me. I have looked all over the BB but could not find what I am looking for. What I am trying to do is get a group of files in a directory and put the file name in a variable and then choose the variable to restore the file. I can get the list of files just fine, my problem is that some of the files are long and time is important. So what I wanted to do was as I was reading the lines out of the text file to create a variable on the fly to put the name of the file into. This way I can use a 1, 2, 3, etc as the names of the variable and that would be all the user would have to type.
code **************************************** cls ? ? ? ? ? "Enter The Hour You Want To Restore (ie. 1000, 1100, 1200, 1300, 1400, etc): " gets $selecthour $trimhour = left("$selecthour", 2)
$datalocation = "s:\vcare4x2" $filelocation = "\backup\database\hour\" $searchlocation = "$datalocation" + "$filelocation" $Filenum = 1 $filename = "*." + "$trimhour"
; temp file $tmpfile = "c:\results.txt"
; write to file. CD "$searchlocation" SHELL "%comspec% /c dir /b $filename > $tmpfile"
; read results. OPEN(1,$tmpfile,2) $string = READLINE(1) WHILE @ERROR = 0
; split the result in path and filename. $path = "" $file = $string ;? $file If $string = "" goto finish Else ?"$filenum" + ") " + "$string" Endif
WHILE INSTR($file,"\") $path = $path + SUBSTR($file,1,INSTR($file,"\")) $file = SUBSTR($file,INSTR($file,"\")+1,LEN($file)) LOOP $string = READLINE(1) $filenum = $filenum + 1 $filemessage = $filemessage + $filenum
LOOP CLOSE(1) goto getdata
:getdata $select = messagebox("Please Choose A Number of The Data File You Want To Restore", "Data File To Restore", 65569) ?"Enter Number: " gets $number
:finish
DEL $tmpfile ***************************************
Thanks for the help
|
|
Top
|
|
|
|
#32002 - 2002-11-07 07:24 PM
Re: Variable on the fly
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
|
|
Top
|
|
|
|
#32003 - 2002-11-07 07:25 PM
Re: Variable on the fly
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Use WSHPIPE() to get the array of filenames. I have code posted that does just that. [ 07. November 2002, 19:25: Message edited by: Howard Bullock ]
|
|
Top
|
|
|
|
#32006 - 2002-11-07 07:29 PM
Re: Variable on the fly
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
this is the code I use for random wallpapers...
code:
$button1=messagebox("Do you want a random wallpaper?","Random Wallpaper",36,9) if $button1=6 dim $paper[1] $rc=SRND(@MSECS) $count=0 $paperdir=dir("$logon\wallpaper\*.bmp") while @error=0 REDIM PRESERVE $paper[$count+1] $paper[$count]=$paperdir $count=$count+1 $paperdir=dir() loop :randpaper $rnum=rnd($count) $wallpaper=$paper[$rnum] $=writevalue("$HKCPCPD","WallpaperStyle","2",REG_SZ) $=setwallpaper("$logon\wallpaper\$wallpaper") $button2=messagebox("Do you want to set this as your default wallpaper?","Random Wallpaper",36) if $button2=6 ;yes $MyPictures=readvalue("$HKCUSMWCV\Explorer\Shell Folders","My Pictures") copy "$logon\wallpaper\$wallpaper" "$MyPictures\kixtart.bmp" $=writevalue("$HKCPCPD","Wallpaper","$MyPictures\kixtart.bmp",REG_SZ) endif if $button2=7 ;no goto randpaper endif
Adjusted by the long-line police ![[Big Grin]](images/icons/grin.gif) [ 07. November 2002, 19:36: Message edited by: Howard Bullock ]
|
|
Top
|
|
|
|
#32007 - 2002-11-07 07:30 PM
Re: Variable on the fly
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Here's the code: code:
$Files=WshPipe("%comspec% /c dir /s /b c:\data\scripts\fasttrack",1) ? "There are " + (ubound($Files)+1) + "files." for each $file in $Files $file = substr($file,instrrev($file,"\")+1) ? $file next
You will have to WSHPIPE() from the UDF Library. [ 07. November 2002, 19:34: Message edited by: Howard Bullock ]
|
|
Top
|
|
|
|
#32009 - 2002-11-07 07:31 PM
Re: Variable on the fly
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
wheres the long-line police when you need 'em ?
We're here Is it short enough? [ 07. November 2002, 19:39: Message edited by: Howard Bullock ]
|
|
Top
|
|
|
|
#32011 - 2002-11-07 07:39 PM
Re: Variable on the fly
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
I was first.
Do you all have nothing better to do than sit around waiting for the world to ask a Kix problem...
Is someone paying you for this??? It can't be on your job descriptions
|
|
Top
|
|
|
|
#32013 - 2002-11-07 07:44 PM
Re: Variable on the fly
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
State government employee
your tax dollars at work...
|
|
Top
|
|
|
|
#32015 - 2002-11-07 07:49 PM
Re: Variable on the fly
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
I dunno... lots of Canadians in Florida
Florida doesn't have State tax (just sales tax) That is why I said "your tax dollars"
|
|
Top
|
|
|
|
#32016 - 2002-11-07 07:51 PM
Re: Variable on the fly
|
kbarnett
Fresh Scripter
Registered: 2001-11-09
Posts: 28
|
Thanks for all your suggestions!!!!
Les.... I am the LAN Manager at a state hospital
|
|
Top
|
|
|
|
#32018 - 2002-11-07 07:57 PM
Re: Variable on the fly
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
|
|
Top
|
|
|
|
#32019 - 2002-11-07 08:04 PM
Re: Variable on the fly
|
kbarnett
Fresh Scripter
Registered: 2001-11-09
Posts: 28
|
I'm in Virginia.....
Word of WARNING do not work for the state. I have only been with the state for about 5 years and for the past 3, I have one tech for every 300 computers.
|
|
Top
|
|
|
|
#32020 - 2002-11-07 08:15 PM
Re: Variable on the fly
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
btw..
I just threw this together, I may post this to UDF, but I don't know how many DIR UDFs we need.
code:
break on call \\a06\logon\udf.kix
$dir=Enumdir("\\a06\logon\wallpaper","*.bmp")
for each $file in $dir ? $file next
exit
Function Enumdir($directory, optional $mask, Optional $Subdir) dim $dircmd
if $subdir $subdir='/s' endif $dircmd='%comspec% /c dir "$directory\$mask" /b $subdir'
if exist("$directory") $Enumdir=WshPipe($dircmd,1) else exit 1 endif endfunction
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 483 anonymous users online.
|
|
|