Parser

A library for parsing values from text files.

File:
Parser.lib
Version:
1.0
Author:
Marcus Johansson

Contents

Details
Constants
Sub routines


Details

The Parser library lets you read integers, floats and strings from text files.


Constants

Value types.

Name
Description
P_TYPE_INT
Integer.
P_TYPE_FLOAT
Float.
P_TYPE_STRING
String.
P_TYPE_CHAR
Character.
P_TYPE_EOL
End of line.
P_TYPE_EOF
End of file.


Subroutines

Name
Parameters
Brief description
procedure
Reset
Reset parser.
function
GetNext?
f
Get next value.
procedure
SkipLine
f
Skip line.
function
IsAlpha
char
Return true if parameter is an alphabetic character.
function
IsDigit
char
Return true if parameter is a numeric character.


Subroutine documentation

procedure Reset ( )

Resets the parser. You should call this before starting to parse values from a file.

[ Back ]


function GetNext? ( f )

This function finds the next integer, float or string value in file 'f'. Note that the file must be opened in BINARY mode. Check the 'type' field of the returned object to determine the value type. If the type is 'P_TYPE_INT' you will find the integer value in the 'i' field. If the type is 'P_TYPE_FLOAT', the field 'f#' holds a floating point value. For 'P_TYPE_STRING' a string value is stored in the 's$' field. And for 'P_TYPE_CHAR' a character in string format can be found in the 'c$' and the same character as an integer in the 'i' field. Type 'P_TYPE_EOL' and 'P_TYPE_EOF' represents the end of a line or the file. Text within double quotes are treated as single strings and returned as 'P_TYPE_STRING'.

Parameter
Mode
Description
f
In
The file to read next value from.

Return value
An object containing the result.

[ Back ]


procedure SkipLine ( f )

Call this function to skip the rest of the line.

[ Back ]


function IsAlpha ( char )

Return true if parameter is an alphabetic character.

Parameter
Mode
Description
char
In
The character in integer format to check.

Return value
True if 'char' is alphabetic.

[ Back ]


function IsDigit ( char )

Return true if parameter is a numeric character.

Parameter
Mode
Description
char
In
The character in integer format to check.

Return value
True if 'char' is numeric.

[ Back ]


Generated with NLDoc 20140630.