SheerPower® 4GL
A Guide to the SheerPower Language


Previous Contents Index

6.8.5 EXTEXT$[(int_expr)]

EXTEXT$ returns explanatory text associated with a specified exception number. See also the EXLABEL$ function example above.

Example 6-164 EXTEXT$ function

  print extext$(2001) 
  
  
Subscript out of bounds 

6.8.6 EXTYPE

EXTYPE returns the number of the last exception that occurred. It is returned as an integer.

Example 6-165 EXTYPE function

  try_it 
  stop
  routine try_it 
    when exception in
      open #1: name 'xx.yy' 
    use
      print 'Open error at '; exlabel$
      print 'Error was: '; extype
    end when
  end routine
  
  
Open error at TRY_IT.0002 
Error was: 7110 

6.8.7 SYSTEXT$

or

SYSTEXT$[(int_expr)]

SYSTEXT$ returns the text associated with the operating system status specified. If no int_expr is supplied, SheerPower returns the text for the last system status. SYSTEXT$ is often used with _STATUS system function.

Example 6-166 SYSTEXT$ function

  print systext$
  
  
The operation completed successfully. 

6.9 Miscellaneous Functions

The following are miscellaneous functions that SheerPower performs:

6.9.1 DECODE(str_expr, int_expr)

With the DECODE function, given the string representation of a number and the base that the value is in (int_expr), SheerPower returns the value in base 10. The number is returned as a real number. See also Section 6.4.11, ENCODE$(num_expr, num_int).

Example 6-167 DECODE function

  do
    line input 'Enter a HEX value', default 'ff': hex$ 
    if  _exit  then exit do
    print 'Decimal value is'; decode(hex$,16) 
  loop
  end
  
Enter a HEX value? ff 
Decimal value is 255 
Enter a HEX value? exit 

6.9.2 DTYPE(expr)

The DTYPE function returns as an integer value, the data type of an expression or object variable: 1 = string, 2 = integer, 3 = real. See Section 5.1, DECLARE for more on declaring variable data types.

Example 6-168 DTYPE function

  declare object x 
  x = 45.6 
  print dtype(x) 
  end
 
 
3 

6.9.3 EVAL(str_expr)

This function evaluates the expression described in str_expr and returns the result. If the variable being assigned the result is dynamic, the function puts the result in whatever data type the expression result was in. If the variable is NOT dynamic and the result is the wrong data type, a "Data type mismatch" error is returned.

Example 6-169 EVAL function

  line input 'Enter an expression': a$ 
  print 'The result is '; eval(a$) 
  end
 
 
Enter an expression?  5 + 4 
The result is  9 

6.9.4 FALSE

FALSE returns the constant 0. It is returned as an integer. See also "TRUE function".

Example 6-170 FALSE function

  input 'Enter your age': age 
  of_age? = false
  if  age >= 18  then of_age? = true
  print 'Given your age, you are '; 
  if  of_age?  then print 'plenty old!' else print 'too young!' 
  end
  
  
 
Enter your age? 22 
Given your age, you are plenty old! 
 
run
Enter your age? 7 
Given your age, you are too young! 

6.9.5 LBOUND(array_name [,int_expr])

Given an array and a dimension number, this function returns the low bound for that dimension. The default dimension is 1.

Example 6-171 LBOUND function

  dim temperature(-40 to 100) 
  print 'Lowest temperature we can handle: '; lbound(temperature,1) 
  print 'Highest temperature we handle   : '; ubound(temperature,1) 
  end
  
  
Lowest temperature we can handle:  -40 
Highest temperature we handle   :   100 

6.9.6 MAXNUM

MAXNUM returns the largest number available in this implementation of SheerPower.

Example 6-172 MAXNUM function

  print maxnum
  
  
9223372046854775807 

6.9.7 SIZE(array_name [,int_expr])

SIZE returns the number of elements in one dimension of an array.

  array-name Array to examine
  int-expr Dimension to get the size of. The default dimension is 1.

Example 6-173 SIZE function

  dim calendar(366) 
  print 'Size of this calendar: '; size(calendar) 
   
   
Size of this calendar: 366 
 

6.9.8 TRUE

TRUE returns the constant 1. It is returned as an integer. See also "FALSE" function.

Example 6-174 TRUE function

  input 'Enter your age': age 
  of_age? = false
  if  age >= 18  then of_age? = true
  print 'Given your age, you are '; 
  if  of_age?  then print 'plenty old!' else print 'too young!' 
  end
  
  
 
Enter your age? 38 
Given your age, you are plenty old! 
 
rnh
Enter your age? 5 
Given your age, you are too young! 

6.9.9 UBOUND(array_name [, int_expr])

Given an array and a dimension number, UBOUND returns the upper bound for that dimension. It returns an integer value. The default dimension is 1.

Example 6-175 UBOUND function

  dim temperature(-40 to 100) 
  print 'Lowest temperature we can handle: '; lbound(temperature,1) 
  print 'Highest temperature we handle   : '; ubound(temperature,1) 
  end
  
  
Lowest temperature we can handle:  -40 
Highest temperature we handle   :   100 


Previous Next Contents Index