Library /sys$common/syshlp/BASICHELP.HLB  —  LSE Topics, Compilation unit
  A compilation unit is a block of code that can be compiled  as  a  unit.
  The  compilation  unit  is the initial token displayed on your screen by
  the Language-Sensitive Editor.  Before you start your  editing  session,
  you  must  select  the  type  of  program  unit you plan to edit.  BASIC
  compilation  units  include  PROGRAM  units,  and   SUB   and   FUNCTION
  subprograms.

1  –  PROGRAM unit

  A main program unit can be compiled, linked, and executed  by  itself,
  whereas a SUB or FUNCTION program unit cannot be executed unless it is
  linked with a main program unit.  A main program unit can be delimited
  with the PROGRAM and END PROGRAM statements; however, these statements
  are optional.

2  –  SUB program unit

  A SUB subprogram cannot be executed unless linked with a main  program
  unit.   A  SUB  subprogram  does not return a value except by way of a
  modifiable parameter (passed BY REF or BY DESC).  SUB subprograms  are
  called from the main program with the CALL statement.

  The SUB  statement  marks  the  beginning  of  a  SUB  subprogram  and
  specifies its parameters by number and data type.

3  –  FUNCTION program unit

  A FUNCTION subprogram cannot be executed unless  linked  with  a  main
  program  unit.   Unlike SUB subprograms, FUNCTION subprograms return a
  value.  FUNCTION subprograms are  called  from  the  main  program  by
  referencing the FUNCTION name.

  FUNCTION subprograms must be declared with the EXTERNAL  statement  in
  the  main program.  You must specify the data type for the function in
  both the main program EXTERNAL statement and the  subprogram  FUNCTION
  statement.

  The FUNCTION statement marks the beginning of  a  FUNCTION  Subprogram
  and defines the subprogram's parameters.
Close Help