gclib  307
Communications API for Galil controllers and PLCs
 All Data Structures Files Functions Variables Typedefs Macros Pages
GCLIB_DLL_EXPORTED GReturn GCALL GProgramDownload ( GCon  g,
GCStringIn  program,
GCStringIn  preprocessor 
)

Downloads a program to the controller's program buffer.

Parameters
gConnection's handle.
programNull-terminated program for download.
preprocessorOptions string for preprocessing the program before sending it to the controller.
  • Null allows the library to use defaults for the download.
    • Maximum compression, only if needed, to fit the program.
    • Code downloads at start of buffer.
  • Compression options
    • --max n provides preprocessing up to and including level n. Only the necessary preprocessing will be performed up to level n, as listed below.
      • Level 0 (mandatory)
        1. Remove lines starting with REM.
        2. Error on \ in buffer.
        3. Comment blank lines with '.
        4. Remove white space (space/tab) in front of # (label declarations).
        5. Remove white space after commands.
        6. Remove trailing semicolons.
        7. Line ends changed to carriage return.
        8. Replace leading tabs with double space.
        9. Replace non-leading tabs with single space.
      • Level 1
        1. Remove unnecessary spaces. Strings, comments ('), and no-ops (NO) are not changed.
      • Level 2
        1. Remove comments (') but not no-ops (NO).
      • Level 3
        1. Remove no-ops (NO) too.
      • Level 4
        1. Break apart compound lines that are too long.
        2. Compact lines of code to maximize line usage.
        3. Use backtick to support long lines where applicable.
    • --min n will preprocess at least up to and including n. n defined as with --max above.
  • Code insertion
    • --insert arg invokes the insert option of the firmware's DL command. arg can be one of the following.
      • Line number, e.g. 100. Program insertion will occur on the line after the line specified.
      • Variable name, e.g. myvar. Program insertion will occur on the line after the line equal to the value of the variable.
      • Label callout, e.g. #mylabel. Program insertion will occur on the line after the label.
      • A lone # symbol. Program insertion will occur on the line after the last line in the program buffer.
    • Important Warning. It is the user's responsibility to ensure that the code will fit in the inserted location. The preprocessor will not check line numbers when executing the --insert option.
    • Compression directives --max and --min are followed.
    • All original code following the point of insertion is cleared.
    • Not all products support the --insert operation, e.g. DMC-30010. See the DL command for support.
Returns
The success status or error code of the function. See gclib_errors.h for possible values.

See x_programs.cpp for an example.

Referenced by GProgramDownloadFile().