qb45advr.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
DECLARE (BASIC Procedure) Statement Details
  QuickSCREEN      Details      Example      Contents      Index
──────────────────────────────────────────────────────────────────────────────
DECLARE (BASIC Procedure) Statement Details
 
Syntax
  DECLARE {FUNCTION | SUB } name [([parameterlist])]
 
  Argument        Description
  name            The procedure's name. The name is limited to 40
                  characters. FUNCTION names can end in one of the
                  type-declaration characters (%, &, !, #, or $) to
                  indicate the type of value returned.
 
  parameterlist   A list of parameters indicating the number and
                  type of arguments used when calling the procedure.
                  Syntax is shown below. Only the number and type of
                  the arguments are significant.
 
For calls within BASIC, the DECLARE statement is required only if you
call SUB procedures without the CALL keyword, or if you invoke a
FUNCTION defined in another module.
 
A DECLARE statement also causes the compiler to check the number and
type of arguments used to invoke the procedure. QuickBASIC
automatically generates DECLARE statements when you save your program
while working in the environment. The DECLARE statement can appear
only in module-level code (not in a SUB or FUNCTION) and affects the
entire module.
 
The parameterlist serves as a prototype for checking the number
and type of the arguments in SUB and FUNCTION calls. It has the
following syntax:
 
  variable[AS type][,variable[AS type]]...
 
A variable is any valid BASIC variable name. If the variable is an
array, it may be followed by the number of dimensions in parentheses:
 
  DECLARE SUB DisplayText (A(2) AS STRING)
  DIM Text$(100,5)
  .
  .
  .
  CALL DisplayText(Text$())
 
The number of dimensions is optional.
 
The type is either INTEGER, LONG, SINGLE, DOUBLE, STRING, or a
user-defined type. Again, only the number and types of arguments are
significant.
 
  Note: You cannot have fixed-length strings in DECLARE statements
        because only variable-length strings can be passed to SUB
        and FUNCTION procedures. Fixed-length strings can appear
        in an argument list but are converted to variable-length
        strings before being passed.
 
A variable's type can also be indicated by including an explicit type
character ( %, &, !, #,  or $) or by relying on the default type.
 
The form of the parameter list determines whether or not argument
checking is done, as shown in the following list:
 
  Declaration                     Meaning
 
  DECLARE SUB First               You may only omit the parentheses
                                  if the SUB or FUNCTION is separately
                                  compiled. No argument checking is
                                  done.
 
  DECLARE SUB First ()            First has no parameters. Arguments
                                  in a CALL to First are flagged as
                                  an error. An empty parameter list
                                  indicates that the SUB or FUNCTION
                                  has no parameters.
 
  DECLARE SUB First (X AS LONG)   First has one long-integer
                                  parameter. The number and type of
                                  the arguments in each CALL or
                                  invocation are checked when the
                                  parameter list appears in the
                                  DECLARE.