Greetings.
Please what´s the syntax to declare the last array position ?
Example:
Let>t=0
Repeat>t
Let>t=t+1
Let>filename=Tip_Nor[%t%]
Until>t=????
Some languages, as PERL, has an specific syntax ($#Tip_Nor) to declare the last index.
Thanks. Papi.
Last array position
Moderators: Dorian (MJT support), JRL
???? will be an integer either as a number or a variable value that is a number. You will need to either explicitly place a number in the code, e.g. Until>t=10 Or you will need to programatically determine the number, assign it to a variable and use the variable with the until> function. For example:Until>t=????
GetFileList>c:\temp\*.*,files
Separate>files,;,file_names
Let>t=0
Repeat>t
Let>t=t+1
Let>filename=Tip_Nor[%t%]
Until>t=%file_names_count%
GetFileList> creates a list of files and Separate> assigns each list item to a variable and also creates variable_count that contains the number of items in the list.
Using this same principle, how would this work:
[code]
ReadFile>d:\jobs.txt,inFile
Separate>inFile,CRLF,lines
//
Let>j=0
Let>k=0
Let>combined=
Repeat>k
Let>j=j+1
Let>k=k+1
Let>this_line=lines_%k%
//this position code starts on the second line after my job number is found.
Position>#,this_line,1,p
//p will = 1 when the script reaches the next job number, which is the point I will stop storing variables and write what I have to excel.
If>p=1
//found line starting with #,
If>combined
//output variables to excel
Endif
//reset combined
Let>combined=
Else
Let>combined=1
Let>var_%j%=%this_line%
//OMIT THIS LINELet>combined=%combined%%this_line%
Endif
Until>k=lines_count
[/code]
how can i send all of the collected variables noted as var_%j% to excel. how can i identify all variables in this array? Sometimes there will be 3-20 lines of text.
how do i know how many items are in an array?
If there are 3 lines, var_1, var_2, and var_3 will have a value in there, but how can I know which var_# have been written.
[code]
ReadFile>d:\jobs.txt,inFile
Separate>inFile,CRLF,lines
//
Let>j=0
Let>k=0
Let>combined=
Repeat>k
Let>j=j+1
Let>k=k+1
Let>this_line=lines_%k%
//this position code starts on the second line after my job number is found.
Position>#,this_line,1,p
//p will = 1 when the script reaches the next job number, which is the point I will stop storing variables and write what I have to excel.
If>p=1
//found line starting with #,
If>combined
//output variables to excel
Endif
//reset combined
Let>combined=
Else
Let>combined=1
Let>var_%j%=%this_line%
//OMIT THIS LINELet>combined=%combined%%this_line%
Endif
Until>k=lines_count
[/code]
how can i send all of the collected variables noted as var_%j% to excel. how can i identify all variables in this array? Sometimes there will be 3-20 lines of text.
how do i know how many items are in an array?
If there are 3 lines, var_1, var_2, and var_3 will have a value in there, but how can I know which var_# have been written.