$lines » History » Version 2
Per Amundsen, 02/23/2023 04:13 PM
| 1 | 1 | Per Amundsen | _Added in 1.9.0_ |
|---|---|---|---|
| 2 | |||
| 3 | *$lines(filename)* |
||
| 4 | |||
| 5 | Returns the total number of lines in the specified text file. |
||
| 6 | |||
| 7 | *Parameters* |
||
| 8 | |||
| 9 | 2 | Per Amundsen | table(ktable). |
| 10 | |*Parameter*|*Description*| |
||
| 11 | | filename | Filename to read from. | |
||
| 12 | 1 | Per Amundsen | |
| 13 | *Example* |
||
| 14 | |||
| 15 | <pre> |
||
| 16 | ;Open a file for writing |
||
| 17 | /fopen file file.txt |
||
| 18 | |||
| 19 | ;Write a line to the file |
||
| 20 | /fwrite file Hello World |
||
| 21 | |||
| 22 | ;Close the file |
||
| 23 | /fclose file |
||
| 24 | |||
| 25 | ;Print the number of lines in file.txt |
||
| 26 | //echo -ag $lines(file.txt) |
||
| 27 | <pre> |