$read » History » Version 1
Per Amundsen, 08/14/2015 01:30 PM
1 | 1 | Per Amundsen | _Added in 1.9.0_ |
---|---|---|---|
2 | |||
3 | *$read(filename, [ntswrp], [matchtext], [N])* |
||
4 | |||
5 | Returns a single line of text from a file. |
||
6 | |||
7 | _See also [[$readn]]._ |
||
8 | |||
9 | *Parameters* |
||
10 | |||
11 | filename - Filename to read. |
||
12 | [ntswrp] - (optional) |
||
13 | <pre> |
||
14 | n - Don't evaluate any identifiers in the line. |
||
15 | t - Treat the first line as a plain text, even if it's a number. |
||
16 | s - Search for matchtext. |
||
17 | w - Search for matchtext as a wildmatch. |
||
18 | r - Search for matchtext as a regular expression. |
||
19 | p - Treat command | separators as such instead of as plain text. |
||
20 | </pre> |
||
21 | |||
22 | [matchtext] - Matchtext to search. (optional) |
||
23 | [N] - The Nth line. |
||
24 | |||
25 | *Example* |
||
26 | |||
27 | <pre> |
||
28 | ; Prints a random line from the file 'file.txt'. |
||
29 | //echo $read(file.txt) |
||
30 | |||
31 | ; Prints line '10' from the file 'file,txt. |
||
32 | //echo $read(file.txt, 10) |
||
33 | |||
34 | ; Searches file 'file,txt for a line beginning with the text 'Hello World' and prints the text following the match value. |
||
35 | //echo $read(file.txt, s, Hello World) |
||
36 | |||
37 | ; Searches file 'file.txt' for a line matching the wildmatch '*Hello World*' and prints it. |
||
38 | //echo $read(file.txt, w, *Hello World*) |
||
39 | </pre> |