Page 1 of 1 1
Topic Options
#209914 - 2015-02-05 10:35 PM IF Exist ($file1) or Exist ($file2) or Exist ($file3)
jenefa Offline
Fresh Scripter

Registered: 2013-02-01
Posts: 15
Loc: USA
Hello All,

If EXIST ($InstallLoc) or EXIST ($InstallLoc2) or EXIST ($InstallLoc3)

Is the above valid statement in Kix. I am trying to see if the file exist in any of the locations, and if it does i want to process then accordingly.

Thanks
Jenefa

Top
#209915 - 2015-02-06 01:08 AM Re: IF Exist ($file1) or Exist ($file2) or Exist ($file3) [Re: jenefa]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
That would be it.
_________________________
!

download KiXnet

Top
#209916 - 2015-02-06 01:01 PM Re: IF Exist ($file1) or Exist ($file2) or Exist ($file3) [Re: Lonkero]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4403
Loc: New Jersey
That will work, but won't tell you where it exists, if that is important... If you need to know the install location, use a case statement, like this:
 Code:
; Assumes installLoc1, 2, & 3 are already defined...
Select
 Case Exist($InstallLoc1)
  $InstallLoc = $InstallLoc1
 Case Exist($InstallLoc2)
  $InstallLoc = $InstallLoc2
 Case Exist($InstallLoc3)
  $InstallLoc = $InstallLoc3
EndSelect
'Install location is ' $InstallLoc @CRLF
The numbered values determine the location and set the unnumbered InstallLoc variable, which is used for all remaining references to the location.

Since a Case statement stops after the first match, you can change the preference by changing the sequence of matches. If you need to make a decision based on the file existing in multiple locations, then more complex logic with individual If statements are required.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#209923 - 2015-02-06 09:02 PM Re: IF Exist ($file1) or Exist ($file2) or Exist ($file3) [Re: Glenn Barnas]
jenefa Offline
Fresh Scripter

Registered: 2013-02-01
Posts: 15
Loc: USA
Thank you very much, does this also pass the kix standard

If EXIST ($InstallLoc+ '\xxxxx.msi') AND EXIST($InstallLoc+ '\XXXXXXX.exe')
Then do these lines

Top
#209925 - 2015-02-06 09:09 PM Re: IF Exist ($file1) or Exist ($file2) or Exist ($file3) [Re: jenefa]
jenefa Offline
Fresh Scripter

Registered: 2013-02-01
Posts: 15
Loc: USA
I am trying to create an array of directories for my For Each to iterate through,
can someone tell me if the format is correct. I tried the kixtart helpdesk it doesn't have details.

thank again.

Dim $Arrayoflocations
$Arrayoflocations="%programfilesx86%\putty, %userprofile%\tools\putty"

Top
#209928 - 2015-02-06 11:13 PM Re: IF Exist ($file1) or Exist ($file2) or Exist ($file3) [Re: jenefa]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Close...Maybe something like this is what you're after?

 Code:
Dim $Arrayoflocations, $foundLocation
$Arrayoflocations = "%programfiles(x86)%\putty", "%userprofile%\tools\putty"

For Each $location in $Arrayoflocations
   If Exist($location)
      $foundLocation = $location
   Endif
Next

If Len($foundLocation)
   ; Do Stuff Here If Installation Found
   "Install Directory Found: "+$foundLocation ?
Endif

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
1 registered (Henriques) and 2516 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.169 seconds in which 0.14 seconds were spent on a total of 13 queries. Zlib compression enabled.

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