forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


stacked if's

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
noveltech
Contributor
Contributor


Joined: 16 Sep 2002
Posts: 105

PostPosted: Sat Nov 22, 2003 3:27 am    Post subject: stacked if's Reply with quote

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
View user's profile Send private message
nick
Contributor
Contributor


Joined: 15 Aug 2000
Posts: 50
Location: hamburg,nj

PostPosted: Sat Nov 22, 2003 5:05 am    Post subject: Reply with quote

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
View user's profile Send private message
Serge
Professional Member
Professional Member


Joined: 04 Mar 2002
Posts: 1480
Location: Australia

PostPosted: Sat Nov 22, 2003 7:49 am    Post subject: Reply with quote

great idea nick...my thoughts exactly Very Happy

serge

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Sat Nov 22, 2003 5:18 pm    Post subject: Reply with quote

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. Wink

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Sun Nov 23, 2003 2:09 am    Post subject: Reply with quote

Nice one FF Smile
U can additionally use
Code:
DIRECTORY CHANGE, <path>

if your current directory is different.

_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
Serge
Professional Member
Professional Member


Joined: 04 Mar 2002
Posts: 1480
Location: Australia

PostPosted: Sun Nov 23, 2003 7:41 am    Post subject: Reply with quote

good one ff...great coding idea Very Happy

serge

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Sun Nov 23, 2003 3:27 pm    Post subject: Reply with quote

Thanks. Smile I find it very easy to code and very efficient to use.
_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group