View previous topic :: View next topic |
Author |
Message |
noveltech Contributor
Joined: 16 Sep 2002 Posts: 105
|
Posted: Sat Nov 22, 2003 3:27 am Post subject: stacked if's |
|
|
if we are searching "before allowing program to run" for multiple prog files, I use the code below. However, if I am checking for 30 files...the
code gets very redundant. Is there a better way? nt
Code: |
if @file("C:\Program Files\myprog\file1.ext")
if @file("C:\Program Files\myprog\file2.dsu")
if @file("C:\Program Files\myprog\file3.exe")
if @file("C:\Program Files\myprog\file4.bmp")
Rem If files are present, goto Program Start
GOTO Program Start
ELSE
ELSE
ELSE
ELSE
Rem If file is missing, goto Missing Program Files Sub-Routine
GOTO Missing Program Files
END
END
END
END
GOTO Corrupt
:Program Start
|
|
|
Back to top |
|
|
nick Contributor
Joined: 15 Aug 2000 Posts: 50 Location: hamburg,nj
|
Posted: Sat Nov 22, 2003 5:05 am Post subject: |
|
|
Hi:
You could create a file with the list of filenames you are checking for:
myfile.txt
Code: |
%%missing =
list create,1
list loadfile,1,myfile.txt
list seek,1,0
%A = @next(1)
REPEAT
if @file("C:\Program Files\myprog\"%A)
ELSE
%%missing = yes
END
%A = @next(1)
UNTIL @null(%A)@equal(%%missing,yes)
If @equal(%%missing,yes)
Rem If file is missing, goto Missing Program Files Sub-Routine
GOTO Missing Program Files
ELSE
Rem If files are present, goto Program Start
GOTO Program Start
END
:Program Start
|
Nick _________________ nick |
|
Back to top |
|
|
Serge Professional Member
Joined: 04 Mar 2002 Posts: 1480 Location: Australia
|
Posted: Sat Nov 22, 2003 7:49 am Post subject: |
|
|
great idea nick...my thoughts exactly
serge _________________
|
|
Back to top |
|
|
FreezingFire Admin Team
Joined: 23 Jun 2002 Posts: 3508
|
Posted: Sat Nov 22, 2003 5:18 pm Post subject: |
|
|
Actually I would use something like the following:
Code: | if @not(@file(file1.txt))@not(@file(another.jpg))@not(@file(vdsextension.dll))
warn A required component is missing. Please re-install the application to correct the problem.
exit
end |
If any of the files are missing then it will trigger the code inside the if...end,
which is a lot less code. _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
Back to top |
|
|
CodeScript Moderator Team
Joined: 08 Jun 2003 Posts: 1060 Location: India
|
Posted: Sun Nov 23, 2003 2:09 am Post subject: |
|
|
Nice one FF
U can additionally use
Code: | DIRECTORY CHANGE, <path> |
if your current directory is different. _________________ Regards
- CodeScript
Give your application a professional look with the VDSGUI Extension |
|
Back to top |
|
|
Serge Professional Member
Joined: 04 Mar 2002 Posts: 1480 Location: Australia
|
Posted: Sun Nov 23, 2003 7:41 am Post subject: |
|
|
good one ff...great coding idea
serge _________________
|
|
Back to top |
|
|
FreezingFire Admin Team
Joined: 23 Jun 2002 Posts: 3508
|
Posted: Sun Nov 23, 2003 3:27 pm Post subject: |
|
|
Thanks. I find it very easy to code and very efficient to use. _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
Back to top |
|
|
|