Actions
$read » History » Revision 2
« Previous |
Revision 2/3
(diff)
| Next »
Per Amundsen, 02/23/2023 07:22 PM
Added in 1.9.0
$read(filename, [ntswrp], [matchtext], [N])
Returns a single line of text from a file.
See also $readn.
Parameters
Parameter | Description |
filename | Filename to read. |
[ntswrp] | (optional) |
[matchtext] | Matchtext to search. (optional) |
[N] | The Nth line. |
Options
Option | Description |
n | Don't evaluate any identifiers in the line. |
t | Treat the first line as a plain text, even if it's a number. |
s | Search for matchtext. |
w | Search for matchtext as a wildmatch. |
r | Search for matchtext as a regular expression. |
p | Treat command | separators as such instead of as plain text. |
Example
; Prints a random line from the file 'file.txt'. //echo $read(file.txt) ; Prints line '10' from the file 'file,txt. //echo $read(file.txt, 10) ; Searches file 'file,txt for a line beginning with the text 'Hello World' and prints the text following the match value. //echo $read(file.txt, s, Hello World) ; Searches file 'file.txt' for a line matching the wildmatch '*Hello World*' and prints it. //echo $read(file.txt, w, *Hello World*)
Updated by Per Amundsen over 1 year ago · 2 revisions