<< Click to Display Table of Contents >> Navigation: 3. Script Language > Filesystem-Commands > Filesystem-Commands |
MiniRobotLanguage (MRL)
GLC. Command
Get Line Count
Intention
This command can be used to get the number of Lines of a given Text-File as well as the biggest line-width. Using with with binary files may lead to unexpected results.
Usage is simple:
: $$FIL=C:My_Textfile.txt
GLC.$$FIL|$$TXT|$$WIT
MBX.The Linecount is: $$TXT
MBX. The largest line-width is: $$WIT$
You can omit all parameters except the filename.
GLC.$$FIL
In that case you find the number of lines on the stack. The second information, the maximum line with is dropped in that case. It will only be delivered when using a third variable parameter.
You can however do this:
GLC.$$FIL||$$000
STS.DUMP
MBX.Whats on the stack?
ENR.
And also mix variable output and stack output.
GLC.$$FIL||$$WIT
STS.DUMP
MBX.Width is $$WIT
ENR.
This will get the Line-count onto the stack and the maximum line-width into a variable.
Speed Considerations:
Our tests show that a Textfile with 99998 Lines and 2.5 MB in Size is scanned in about 0.03 seconds.
Syntax
GLC.P1[|P2][|P3]
Parameter Explanation
P1 - Filename to count Lines in.
P2 - optional variable to return the number of lines. If omitted TOS is used.
P3 - optional variable to return the width of the longest line.
If omitted Value is been placed on TOS.
Example
'********************************************
' Demo for GLC.
'********************************************
VAR.$$TIM=#dtime#
GLC.$$FIL|$$TXT|$$WIT
MBX.The Linecount is: $$TXT-$$WIT$crlf$#dsince#
ENR.
'********************************************
' Demo for LFF and GLC.
'********************************************
'DBM.2
' This should be a valid name of a Text-File
: §§FIL=start.ini
GLC.§§FIL|$$RET
PRT.File: $$FIL contains: $$RET Lines.
FOR.$$AAA|1|20
' Read Lin Nr. $$AAA from File ?path\$$FIL into $$RET
LFF.§§FIL|$$AAA|$$REB
PRT.[$$AAA]->$$REB
NEX.
MBX.!
END.
Remarks
-
Limitations:
-
See also:
• IEF. / NEF. - If - exist - File