Hi All,
I searched the forum, but didn't see anything. I'm sure it is here.
I want to read from a text file that is a txt. The text file has multiple rows with 2 elements per row. For Instance...
----------------BEGIN------------------
apple,fruit
turnip,vegetable
cat,animal
...
----------------END--------------------
The following code is an adaptation from code that I found here on the forum (thanks to whoever did it).
Variable Set Integer %N[1]% to 0
Text File Begin Process: c:\list.txt
Variable Modify Integer %N[1]%: Increment
Text File End Process
Variable Set Integer %N[2]% to a random value between 0 and %N[1]%
Text File Begin Process: c:\list.txt
Text File End Process
Text Type (Simulate Keystrokes): %T[2]%<TAB>
The direct code is here
<VARIABLE SET INTEGER Option="\x00" Destination="%N[1]%" Value="0"/>
<TEXT FILE BEGIN PROCESS Filename="c:\\list.txt" Start_Record="1" Process_All="TRUE" Records="0" Variable="%T[1]%"/>
<VARIABLE MODIFY INTEGER Option="\x07" Destination="%N[1]%"/>
<TEXT FILE END PROCESS/>
<VARIABLE SET INTEGER Option="\x05" Destination="%N[2]%" Minimum="0" Maximum="%N[1]%"/>
<TEXT FILE BEGIN PROCESS Filename="c:\\list.txt" Start_Record="%N[2]%" Process_All="FALSE" Records="1" Variable="%T[2]%"/>
<TEXT FILE END PROCESS/>
<TEXT TYPE Action="0" Text="%T[2]%<TAB>"/>
This code first counts the number of lines in the TXT file.
Then is randomly selects one of the lines to put into %T[2]%
It works perfectly.
However, I need to be able to parse that line into the two elements.
So.
%T[2]% = first element (before the comma)
%T[3]% = second element (after the comma)
I hope that explanation makes sense.
Any chance this can be done?
Thanks in advance for the help,
Ed