standard: Standard functions of Unibase

Include this module to get access to the standard types and functions of unibase.

Future developments

More different type handling functions. Including display layout strings. These should also cover the handling of date and time layout. Also functions for find and replace within texts. A seperate module 'math' should contain the mathematical functions and types.

Known bugs

Text handling functions The text handling is not perfect. Especially the functions on fields don't work as they should. A new text type should get a copy of the text and not the same pointer.

String handling functions

Routine fromhex Gets a hexedecimal value out of a string
    hex constr the string is totally scanned for numbers
    returns: number the number or 0 when nothing was found
  
Routine tohex Creates a string with a hexedecimal value
    num number the none negative number
    returns: string the string or a null when too big or below zero
  
Routine ascii Get the acsii value of the first character of the string
    str string a string, only the first character is relevant
    returns: number the found ascii value of -1 when string was null
  
Routine char Creates a string with a single character
    ascii number the ascii-number of the character
    returns: constr the string
  
Routine findstring Find a substring within another string
    haystack constr the string to search in
    needle constr the string to search for
    from numberdefault: '1'  the starting position to search from
    returns: number the found position or 0 when nothing is found
  
Routine pattern 
    pattern string 
    times number 
    returns: constr 
  
Routine left Get the leftmost part of a string
    string constr the source string
    length number number of characters to get from the string
    returns: string the return string or an empty string when length=0
  
Routine right Get the rightmost part of a string
    string constr the source string
    length number number of characters to get from the string
    returns: string the return string or an empty string when length=0
  
Routine mid Get a subsection from a string
    string constr the source string
    position number the position to start getting characters from
    length numberdefault: '99999'  the maximum length of the return string
    returns: string the return string or and empty string when length=0
  
Routine trim Trim the spaces from the start and the end of a string
    str constr the source string
    returns: string return string or null when str doesn't exist
  
Routine lefttrim Trim the leading spaces from a string
    str constr the source string
    returns: string the resulting string or null when str doesn't exist
  
Routine righttrim Trim the trailing spaces from a string
    str constr the source string
    returns: string the resulting string or null when str doesn't exist
  
Routine uppercase Converts a string to only uppercase characters
    str constr the source string
    returns: string the resulting string
  
Routine lowercase Converts a string to only lowercase characters
    str constr the source string
    returns: string the resulting string
  
Routine length Get the length of a string
    string constr the source string
    returns: number the length or 0 when it is null
  
Routine isalpha Check if a string has only alphabetical characters
    string constr 
    returns: boolean 
  
Routine isnumber 
    string constr 
    returns: boolean 
  

File handling functions

Routine open Open a file for reading
    file constr the name of the file to open
    returns: stream a stream or null when in error
  
Routine close Closes a stream
    stream stream the stream to close
  
Routine write Write data to a stream
    data number the data to write
    stream stream the stream to write to
  
Routine write Write data to a stream
    data text the data to write
    stream stream the stream to write to
  
Routine read Read data from a stream
    stream stream the stream to read
    returns: number the found number of null if nothing is found
  
Routine readtext Read text from a stream
    stream stream the stream to read
    returns: text the found text or null if nothing is found
  
Routine get Gets a single character from a stream
    stream stream the stream to read
    returns: constr a string or a null when nothing found
  
Routine input Read a line of text from a stream
    from streamdefault: 'stdin'  the stream to read
    returns: string The read string or null if the end of the file is reached
  
Routine eof Determin the end of the stream
    str stream the current stream
    returns: boolean True is end of file found
  
Routine append Open a stream to write to the end of it
    file constr the name of the file
    returns: stream the stream or null when in error
  
Routine create Creates a new file with a stream to write to
    file constr the name of the file
    returns: stream the stream or null when in error
  
Routine seek Place the filepointer to a specific position
    str stream the stream to change
    pos number the position to move to
  
Routine flush Flush the buffers used with this stream
    str streamdefault: 'stdout'  the stream to flush
  

System functions

Routine shell Issue a command to the current shell
    command constr the command to perform
    returns: enumerate[OK Error]  return value of the statement
  
Routine getstring Get a specific string from a array of strings
    sarray strings an array of strings like the parameters of a program
    pos number the number of the string to get
    returns: constr the found string not defined for too high values of 'pos'
  
Routine getenv Get the value of a spefic environment variable
    variable constr the variable to find
    returns: constr Returns the found variable or null when not found
  
Routine random Get a random number
    returns: number The found number
  
Routine initiate Feed a random seed
  
Routine curtime Get the current time of day
    returns: time the time of day in hundreth of seconds
  
Routine showtime Show the time
    time time 
    returns: string the time in readable form
  
Routine check Check the contence of two variables
    num1 number first parameter
    num2 number second parameter
    returns: byte If first parameter is lower: -1, when equal 0: higher: 1
  
Routine check Same routine but now for comparation of strings
    str1 constr 
    str2 constr 
    returns: byte 
  
Routine check Same routine but now for comparation of pointers
    ptr1 pointer 
    ptr2 pointer 
    returns: byte 
  
Routine abs Get the absolute value of a number
    num number 
    returns: number 
  
Routine newtext Create a new text value
    str string the once string
    returns: text the text value
  
Routine gettext Get the string from a text
    text text the text
    returns: string the string
  
Routine addtext Adds texts together
    first text the first text
    second text the second text
    returns: text the resulting text
  
Routine nullpointer Get a null pointer value
    returns: pointer 
  
Routine pause Pauses the system till the next signal
  
Copyright (C) 2001 Jurjen J. Stellingwerff