,ll 6.6
,cs 10
,pl 66
,lm 0.2,0.5
,pn 15
,ju
,hd
,ce
OmegaSoft 6809 Cross Pascal Language Handbook (V1.0)
,,
,ft

,ce 1
6-##
,,
,ce
OmegaSoft 6809 Cross Pascal Language Handbook (V1.0)
,ce
TYPE CONVERSION FUNCTIONS

ORD

Returns the integer equivalent of its parameter. If the parameter is one byte (boolean, enumerated, character) it will simply add a zero most-significant byte. If the parameter is integer or hex then no code is generated.

ord-function = ord ( (boolean-expression | character-expression |
                      enumerated-expression | hex-expression |
                      integer-expression) )

REAL

Will return the real equivalent of its parameter. If the parameter is boolean, enumerated, or character, then it will be sign extended to an integer, and then converted to real. If the parameter is integer, hex, longhex, or longinteger, it will be converted to real (signed conversion). With a string parameter it must not have any leading or trailing spaces or else a conversion error will be generated. The digits 0-9, a leading plus or minus, and an E or e for the exponent  are acceptable for floating point input. If the value exceeds 5E-19 or 5E18 then a conversion error occurs.

real-function = real ( (conv-parm | real-expression) )

ROUND

Will return the integer equivalent of its parameter. The integer result will be the closest integer to the real value. If the parameter cannot be represented as an integer a truncation error will be generated at runtime.

round (4.6) = 5     round (-4.6) = -5

round-function = round ( real-expression )

STRING

Returns the ascii string equivalent of its parameter. The string returned is in the same format as when the values are written to a text file (see write in chapter 7) with no fieldwidth (no leading or trailing blanks). If the parameter is enumerated then its integer equivalent is converted to a string. If the parameter is character, it is converted to a string of length one. If the parameter is of type real then there is an additional byte or integer parameter to be used as the precision (same function as in write procedure).

Examples : string (false) = ' FALSE'   string ('A') = 'A'
    string (5) = '5'            string ($FE3A) = 'FE3A'
    string (5.3749,3) = '5.375' string (5.3749,-3) = ' 5.375E+00'

string-function = string ( (conv-parm | real-expression 
                                     [, ( character-expression |
                                        integer-expression)]) )
,pg
,ce
TYPE CONVERSIONS

TRUNC

Will return the integer equivalent of its parameter. The integer result will be the real value with its fractional part set to zero. If the parameter cannot be represented as an integer a truncation error will be generated at runtime.

trunc (4.6) = 4     trunc (-4.6) = -4

trunc-function = trunc ( real-expression )

,ce
I/O AND RUNTIME STATUS FUNCTIONS

BREAK

Returns boolean true if the device parameter has encountered a break condition. Break is normally used as an operator input. The break status is cleared after the break function is executed.

If the parameter is not included then the standard input device is used as the parameter.

Example : while not break or eof (t) do
            begin
              readln (t, s) ;
              writeln (s)
            end ;
              
break-function = break [( device-variable )]

CONVERSION

Returns boolean true if the last ascii to internal format conversion encountered an error. These conversions occur during the boolean, integer, hex, longinteger, longhex, and real functions with a string parameter and the read and readln procedures when reading boolean, integer, hex, longhex, longinteger, or real values from a text device.

This value is cleared after any successful conversion takes place. This function is only useful when conversion error checking (compiler toggle C) is off, since if it is on, a conversion error will halt the program execution.

This function may be used in interactive programs to avoid crashing the program if the operator enters an invalid value.

Example : {$c-}
          repeat
            write ('Enter hexadecimal address : ') ;
            readln (h) ;
          until not conversion ;

conversion-function = conversion
,pg
,ce
I/O AND RUNTIME STATUS FUNCTIONS

DEVERR

Returns the device parameter's error byte as a character (byte). Refer to chapter 8 for a description of this byte. This function is only useful when I/O error checking (compiler toggle I) is off, since if it is on, an I/O error will halt the program execution.

This function may be used in interactive programs to avoid crashing the program if the operator enters an invalid file name or if the program requires that it check for or delete files that may not be in the directory.

If the parameter is not used then the standard input device will be used as the parameter.

Example : {$i-}
          repeat
            write ('Enter file name : ') ;
            readln (s) ;
            reset (t, s) ;
            if deverr(t) <> 0
              then
                writeln ('Can''t open ',s)
          until deverr(t) = 0 ;
       
deverr-function = deverr [( device-variable )]

EOF

Returns boolean true if the device parameter has hit end of file. 

If the device is not interactive the element buffer must be valid and if not valid a get procedure will be executed before checking for end of file. If the device is interactive then the current contents of the element buffer will be used, valid or not.

If the device is a text device and eof is true then the element buffer (device^) will be a space.

If the parameter is not used then the standard input device will be used as the parameter.

eof-function = eof [( device-variable )]

EOLN

Returns boolean true if the text device parameter is currently on end of line. If eoln is true then the element buffer (device^) will be a space.

If the device is not interactive the element buffer must be valid and if not valid a get procedure will be executed before checking for end of line. If the device is interactive then the current contents of the element buffer will be used, valid or not.

If the parameter is not used then the standard input device will be used as the parameter.

eoln-function = eoln [( device-variable )]
,pg
,ce
I/O AND RUNTIME STATUS FUNCTIONS

MEMAVAIL

Returns a hex result which is the amount of free space available on the heap. This may be used in interactive programs to make sure that sufficient room is left on the heap for the anticipated data before using the new procedure and risking a heap overflow runtime error. This function can also be used to allocate maximum sized buffers on the heap by using memavail (minus some slop) as the extra parameter to the new procedure.

The amount of space left on the heap is affected by heap allocation (new procedure) and heap de-allocation (release procedure).

Procedure and function calls will also affect the amount left. You should leave enough slop to handle the deepest procedure/function calling when you calculate the amount of heap than can be used. Procedures and functions use up heap space because their parameters, stack frames, and local variables move the stack pointer down towards the heap pointer.

Example : bufsize := memavail - $400 ;
          new (bufpt : bufsize) ;

memavail-function = memavail

RANGE

Returns boolean true if a range error was generated (errors 4 through 12) since the last time this flag was cleared. The range error is different in that it is not cleared when a successful operation takes place, it must be cleared by the programmer.

The range error flag is cleared by an assignment :

range := false ;

In this way it is more of a standard variable rather than a function. This function is only useful when range error checking (compiler toggle R) is off, since if it is on, a range error will halt the program execution.

Example : {$r-}
          range := false ;
          z := x + y * a / b + arcsin(c) ;
          if range
            then
              writeln ('Calculation error') ;

range-function = range
range-assignment = range := boolean expression

