Page 1 of 1 1
Topic Options
#44179 - 2003-08-18 08:51 PM Multiple locations
atiisler Offline
Fresh Scripter

Registered: 2002-07-10
Posts: 34
Hi everyone..
I am trying to write code that would search in either one place or the other for a file. I need to identify a file and some users have this file in one location (older installation of program) or another (newer installation of program) and am not sure how to do. Here is my current code: HELP

$sourcefilea = "c:\Lotus\Notes\Data\bookmark.nsf"
if not exist($sourcefilea )
$rc=messagebox(" Can not find file " + $sourcefilea, "bookmark.nsf",0)
endif

The file Bookmark.nsf can now either be in the directory indicated in code shown or it can be in the following directory

"C:\Program Files\Notes\Data\bookmark.nsf"
how can I check both before the if not exist statement...

Top
#44180 - 2003-08-18 08:53 PM Re: Multiple locations
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
if not exist() and not exist()
? 'file not present'
endif
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#44181 - 2003-08-18 09:07 PM Re: Multiple locations
atiisler Offline
Fresh Scripter

Registered: 2002-07-10
Posts: 34
I am confused...
I want the variable $sourcefilea to have the value of names.nsf if it exists in either location. It will not exist in both but may not exist at all...I need to chech both directories.

Top
#44182 - 2003-08-18 09:12 PM Re: Multiple locations
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
simply:
code:
$sourcefilea1 = "c:\Lotus\Notes\Data\bookmark.nsf"
$sourcefilea2 = "C:\Program Files\Notes\Data\bookmark.nsf"
if not (exist($sourcefilea1 ) or exist($sourcefilea2 ))
$rc=messagebox(" Can not find file bookmark.nsf", "bookmark.nsf",0)
endif



[ 18. August 2003, 21:13: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
#44183 - 2003-08-18 09:26 PM Re: Multiple locations
atiisler Offline
Fresh Scripter

Registered: 2002-07-10
Posts: 34
Is there a way without creating seperate variables..
Can this be done using the OR statement
$sourcefilea = "c:\Lotus\Notes\Data\bookmark.nsf" or
"c:\program files\lotus\notes\data\bookmark.nsf"

Top
#44184 - 2003-08-18 09:31 PM Re: Multiple locations
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You could use an array
code:
dim $a[1]
$a[0]='c:\Lotus\Notes\Data\bookmark.nsf'
$a[1]='C:\Program Files\Notes\Data\bookmark.nsf'
for each $b in $a
if exist($b)
$found=1
endif
next
if not $found
$rc=messagebox(" Can not find file bookmark.nsf", "bookmark.nsf",0)
endif

_________________________
There are two types of vessels, submarines and targets.

Top
#44185 - 2003-08-18 09:42 PM Re: Multiple locations
atiisler Offline
Fresh Scripter

Registered: 2002-07-10
Posts: 34
So I actually have 6 files I have to search for..

$sourcefile="c:\Lotus\Notes\Data\names.nsf" or "c:\Program Files\Lotus\Notes\Data\names.nsf"
if not exist($sourcefile)
$rc=messagebox(" Can not find file " + $sourcefile, "names.nsf",0)
endif
$sourcefilea = "c:\Lotus\Notes\Data\bookmark.nsf"
if not exist($sourcefilea )
$rc=messagebox(" Can not find file " + $sourcefilea, "bookmark.nsf",0)
endif
so and so on for 4 more files

Should I use an array at every file???

Top
#44186 - 2003-08-18 09:54 PM Re: Multiple locations
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
think you need to rethink what you actually want to do.
do you really want to show 6 messageboxes to the user that the file didn't exist and force him/her to press ok?

if that is your goal, I must wonder how patient your users are.
if it isn't, please tell what is.
_________________________
!

download KiXnet

Top
#44187 - 2003-08-18 09:59 PM Re: Multiple locations
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
you could do an array

$found =0
$file[0]='path\file'
$file[1]='path\file'
$file[2]='path\file'
$file[3]='path\file'
$file[4]='path\file'
for each $try in $file
if exist($try)
$found=$try
endif
next
if $found
? 'file is '+$found
else
? 'File not found'
endif
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#44188 - 2003-08-18 10:29 PM Re: Multiple locations
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Looks kind-of like what I subgested, though I've only used a two-element-array.

atiisler: Please read ABC's of KiXtart board etiquette and message to new forum users , Section F. You are changing the scope of your problem. so, please give us the big pictures, purpose, and all.
_________________________
There are two types of vessels, submarines and targets.

Top
#44189 - 2003-08-19 01:31 AM Re: Multiple locations
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
This worked for me. Changed it a bit to support your situation. Simple code, no need for array's and stuff.

Assuming that you don’t have systems running old and new installs (if that's at all possible).

code:
;Check if file exist on system.
$LocationA = Exist("c:\Lotus\Notes\Data\bookmark.nsf")
$LocationB = Exist("C:\Program Files\Notes\Data\bookmark.nsf")
;Check if old, new or no install.
Select
Case $LocationA = 0 AND $LocationB = 0
MessageBox("File Bookmark.nsf not found on system.","File search...",64)
Case $LocationA = 1
MessageBox("File Bookmark.nsf found in c:\Lotus\Notes\Data\ (old install).","File check...",64)
Case $LocationB = 1
MessageBox("File Bookmark.nsf found in C:\Program Files\Notes\Data\ (new install).","File check...",64)
EndSelect

_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

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 1636 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.063 seconds in which 0.027 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