Hi guys,
I've searched the forums (and if I have missed it then very sorry) but I can't find the answer to this.
I would like to create a while loop which for each iteration uses a different variable based on that iteration number.
For example :
What I want it to do is to use the $i number to call a different variable based on the counter within the WHILE statement.
Can this be done, and can you please tell me how?
Again If I have overlooked the answer in the forum, please point me in the right direction.
Thank you,
Farhad
I've searched the forums (and if I have missed it then very sorry) but I can't find the answer to this.
I would like to create a while loop which for each iteration uses a different variable based on that iteration number.
For example :
FTP Script
Can this be done, and can you please tell me how?
Again If I have overlooked the answer in the forum, please point me in the right direction.
Thank you,
Farhad
Hi Farhad,
Thanks for posting this question. Yes, it is something that I think is not covered in the forum.
You have to use ScriptFTP lists. Take a look at this example:
A list is just a text string with a "|" before every item: |item1|item2|item3.... and so on
Thanks for posting this question. Yes, it is something that I think is not covered in the forum.
You have to use ScriptFTP lists. Take a look at this example:
A list is just a text string with a "|" before every item: |item1|item2|item3.... and so on
liked Script FTP? Try our other product Email Parser
Hi,
Is there any other way to perform this as my script is slightly more complicated and I wanted to use different variables for different parts of the script?
So for example and in non-code terms,
A small part of script look like this
while ($i<3)
log into server (i)
file $move(i) from $source(i) to $dest(i)
exec(a few DOS commands such as rename, run other batch shop with input $file(i) $dest(i))
Output to log files (echo. "File "$file(i) to $file (i+1)" ".$date)
Perform a few cleanup operations on file(i)
END While
Or is there an easier mechanism for the above sort of script?
Thank you,
Farhad
Is there any other way to perform this as my script is slightly more complicated and I wanted to use different variables for different parts of the script?
So for example and in non-code terms,
FTP Script
- $Server1="ftp.site1"
- $Server2="ftp.site2"
- $Server3="ftp.site3"
- $file1="file1"
- $file2="file2"
- $file3="file3"
- $source_location1="source1"
- $source_location2="source2"
- $source_location3="source3"
- $dest1="destination1"
- $dest2="destination2"
- $dest2="destination3"
- $date="datenow"
while ($i<3)
log into server (i)
file $move(i) from $source(i) to $dest(i)
exec(a few DOS commands such as rename, run other batch shop with input $file(i) $dest(i))
Output to log files (echo. "File "$file(i) to $file (i+1)" ".$date)
Perform a few cleanup operations on file(i)
END While
Or is there an easier mechanism for the above sort of script?
Thank you,
Farhad
Look at this thread:
http://www.scriptftp.com/forum/viewtopic.php?f=6&t=508
Basically each part sets up expected variables (your $var(i)), then calls a routine which does the work. So each array "group" would simply set up common variables. There would be no while loop.
and so on
http://www.scriptftp.com/forum/viewtopic.php?f=6&t=508
Basically each part sets up expected variables (your $var(i)), then calls a routine which does the work. So each array "group" would simply set up common variables. There would be no while loop.
FTP Script
- # process GH
- $return = 1
- $localDir = "GH"
- $userName = "xxxx"
- $password = "xxxx"
- goto :aprocessFiles
- :Return1
Thanks for answering Bucket
liked Script FTP? Try our other product Email Parser
- All times are UTC -