Hi Martin,
Could you please implement a feature like "readln" - means read strings from a text file and automatically parse them by x10x13, so each line of text will be placed into a list[1], list[2] etc...
Not the best explanation but basically just standard readln in programming languages.
Right now I have to parse the file manually which takes quite a lot of time.
thanks.
Readln from a text file
Moderator: Martin
Re: Readln from a text file
Hi,
You can use function split to create a list of text lines from a file:
-action Init Variable Text File: /file.txt to file_text
-action Script: lines = split(text_file, "\\n"); (or "\\r\\n" when the text file uses the windows-style line breaks)
Local variable lines is a list and will contain an element for each line. You can access the elements using function getElement (line 1 is at list index 0):
or using a for-loop in a script:
Regards,
Martin
You can use function split to create a list of text lines from a file:
-action Init Variable Text File: /file.txt to file_text
-action Script: lines = split(text_file, "\\n"); (or "\\r\\n" when the text file uses the windows-style line breaks)
Local variable lines is a list and will contain an element for each line. You can access the elements using function getElement (line 1 is at list index 0):
Code: Select all
line1 = getElement(lines, 0);
line2 = getElement(lines, 1);
Code: Select all
for(line in lines)
{
log(line);
}
Martin