Referring to Me_again's code above:
Repeat>K
Let>APTData=Apt_%k%
Let>k=k+1
Until>K>APT-Count
What's the purpose of Let>APTData=Apt_%k%?
In fact, prior executing the line, APTdata has already been assigned with the content of c:\ftps\book1.txt.
I don't see how it could create an array.
Please enlighten me.
Thanks.
A faster way to Separate
Moderators: Dorian (MJT support), JRL
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
The content of the file is split into an array of lines. The line prior to the Repeat/Until loop is a Separate line:armsys wrote:Referring to Me_again's code above:
Repeat>K
Let>APTData=Apt_%k%
Let>k=k+1
Until>K>APT-Count
What's the purpose of Let>APTData=Apt_%k%?
In fact, prior executing the line, APTdata has already been assigned with the content of c:\ftps\book1.txt.
I don't see how it could create an array.
Please enlighten me.
Thanks.
Separate>APTData,CRLF,APT
This splits the file data line by line into APT_1, APT_2 ... APT_n - one for each line.
The "Let>APTData=APT_%k%" line you refer to, inside the Repeat/Until accesses each array entry.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Hi mtettmar,
Thanks for your explanation. But the following loop haunts my curiosity. It keeps assigning the values of APT_1, APT_2 ... APT_n to the APTData.
APTData isn't an array, is it? The whole repeat loop doesn't make any sense. What's the meaningful purpose the repeat loop attempts to achieve?
Repeat>k
Let>APTData=APT_%k%
Let>k=k+1
Until>k>APT_Count
BTW, k wasn't initiated before the Repeat>K statement. Is it true that all uninitated/undeclared variables are assigned 0 (zero) by default?
Thanks for your explanation. But the following loop haunts my curiosity. It keeps assigning the values of APT_1, APT_2 ... APT_n to the APTData.
APTData isn't an array, is it? The whole repeat loop doesn't make any sense. What's the meaningful purpose the repeat loop attempts to achieve?
Repeat>k
Let>APTData=APT_%k%
Let>k=k+1
Until>k>APT_Count
BTW, k wasn't initiated before the Repeat>K statement. Is it true that all uninitated/undeclared variables are assigned 0 (zero) by default?
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Perhaps APTData was a confusing choice of variable, although it doesn't really matter since the script no longer needs the entire file contents in the original APTData variable, since it is now in the array. So in fact it wouldn't be a problem using the same name for this variable.
Correct - you *DO* need to initialise the loop counter, otherwise the Let>k=k+1 will create a string, not add a number, because k is not defined.
However, MeAgain only posted a partial screen shot of his code. He may have initialised k earlier in the code than is visible.
Correct - you *DO* need to initialise the loop counter, otherwise the Let>k=k+1 will create a string, not add a number, because k is not defined.
However, MeAgain only posted a partial screen shot of his code. He may have initialised k earlier in the code than is visible.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Yes, as I explained (perhaps I did a bad job), APTData first it contains the entire file contents. Separate is used to take the data in APTData and return an array called APT (APT_1, APT_2 etc). APTData is then also used to store each array value as the loop iterates. Don't think anyone has ever said that APTData is an array.
The array is created by the Separate command. It takes the file contents (in APTData and splits it out based on CRLF as the delimiter. So it splits the file by lines. So you end up with APT_1, APT_2 ... APT_n containing each line of the file.
The array is created by the Separate command. It takes the file contents (in APTData and splits it out based on CRLF as the delimiter. So it splits the file by lines. So you end up with APT_1, APT_2 ... APT_n containing each line of the file.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?