Project

General

Profile

$read » History » Version 3

Per Amundsen, 05/22/2023 05:31 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 2 Per Amundsen
table(ktable).
12
|*Parameter*|*Description*|
13
| filename | Filename to read. |
14
| [ntswrp] | (optional) |
15
| [matchtext] | Matchtext to search. (optional) |
16
| [N] | The Nth line. |
17 1 Per Amundsen
18 2 Per Amundsen
*Options*
19
20
table(ktable).
21
|*Option*|*Description*|
22
| n | Don't evaluate any identifiers in the line. |
23
| t | Treat the first line as a plain text, even if it's a number. |
24
| s | Search for matchtext. |
25 3 Per Amundsen
| w | Search for case-insensitive matchtext as a wildmatch. |
26
| W | Search for case-sensitive matchtext as a wildmatch. *(AdiIRC only)* |
27 2 Per Amundsen
| r | Search for matchtext as a regular expression. |
28
| p | Treat command <notextile>|</notextile> separators as such instead of as plain text. |
29 1 Per Amundsen
30
*Example*
31
32
<pre>
33
; Prints a random line from the file 'file.txt'.
34
//echo $read(file.txt)
35
36
; Prints line '10' from the file 'file,txt.
37
//echo $read(file.txt, 10)
38
39
; Searches file 'file,txt for a line beginning with the text 'Hello World' and prints the text following the match value.
40
//echo $read(file.txt, s, Hello World)
41
42
; Searches file 'file.txt' for a line matching the wildmatch '*Hello World*' and prints it.
43
//echo $read(file.txt, w, *Hello World*)
44
</pre>