bas7qck.hlp (Table of Contents; Topic list)
Examples
  Procedures                                   Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
FUNCTION Procedure Example
 
QBX automatically generates DECLARE statements for FUNCTION procedures
defined and used in the same module. You must explicitly enter a DECLARE
statement if you use a FUNCTION defined in another module:
 
DECLARE FUNCTION Log10(X)
 
INPUT "Enter a number: ",Num
PRINT "10 ^ Log10(";Num;") is" 10.0^Log10(Num)
END
' Function to find log base 10 of a number using
' BASIC's built-in natural logarithm function.
FUNCTION Log10 (X) STATIC
    Log10=LOG(X)/LOG(10.0)
END FUNCTION
 
SUB Procedure Example
 
' Print a message in the middle of the screen.
CLS
CALL PrntMsg(12,40,"Hello!")
END
 
' Print message at the designated row and column.
SUB PrntMsg(Row%,Col%,Message$) STATIC
     ' Save current cursor position.
     CurRow%=CSRLIN
     CurCol%=POS(0)
     ' Print the message at the location.
     LOCATE Row%,Col% : PRINT Message$;
     ' Restore cursor location.
     LOCATE CurRow%,CurCol%
END SUB
 
DEF FN Procedure Example
 
' Function to find log base 10 of a number using
' BASIC's built-in natural logarithm function.
DEF FNLog10 (X)
    FNLog10=LOG(X)/LOG(10.0)
END DEF
 
INPUT "Enter a number: ",Num
PRINT "10 ^ Log10(";Num;") is" 10.0^FNLog10(Num)
END