include

Prev Next

Function Names

include

Synopsis

include ( program file name, parameters )

Description

Starts a separate B4P application script as a sub program and waits until the sub program has ended. In contrast to start(), this function provides specific features which are suitable to define B4P libraries containing procedures and functions:

  • Global variables defined (with global() function) will be preserved.
  • The code will stay resident in memory after completion. When called again, the already loaded code will be used. Performance is better than with start() since the internal compilation process is not repeated.
  • User procedures and functions defined in the called program will be preserved. You can create B4P libraries and use include() to include them.
  • Local variables created inside the program will be preserved and are available for later use. Note: Local variables created inside user-defined procedures and user-defined functions will be discareded when the procedure or function execution has completed.
  • The once() calls will be memorized. A second program execution will skip the once-declared code accordingly.
  • If the specified program file name contains no file type (e.g. '.b4p', '.txt'), then B4P will look for the file in the standard libary directory.

Call as: procedure or function

Parameter count

Min. 1

Parameters

No.TypeDescription
1
input
string Program Name

Name of B4P program or library to include.
If a file type is specified, e.g. '.b4p' or '.txt', then B4P will look for this file in the current or specified directgory.
If no path and no file type is specified, then B4P will look in the standard library folder.

Opt. 2, etc.
input
all types Additional parameters

Any additional optional parameter. If specified, then they will replace the existing "command line parameters" by the ones supplied here.

Return value

TypeDescription
all types returned value

Value returned by called program

Exceptions

Program file not found

Examples

      include ( Office Library ); // Looks for 'Office Library.b4p' in the standard B4P library folder.
      include ( My Library.b4p, English ); // Looks for "My Libary.b4p" in the current folder, and pass a parameter.
      //
      // command line argument[0]: start.txt   (The file name of the program)
      // command line argument[1]: English (string)

See also

start