Overview - Building (Compiling) Code

The options in the Build menu allow you to compile source code into executable code that the control system can understand. NetLinx Studio has the ability to compile and link all the source code (.AXS and .AXI) files at the Workspace, Project, System or File level, plus the ability to compile a single file as a NetLinx source code file.

To send the compiled code to the Master Controller, use the File Transfers option in the Tools menu.

NOTE: The NetLinx Complier tab of the Preferences dialog provides the ability to configure the NetLinx compliers if needed. Seepage 188 for details.

Building the Workspace

One advantage to the Workspace concept employed by NetLinx Studio is that you can choose to build (compile) the entire Workspace. That is, every Source Code, Include, and Module file contained within the open Workspace can be compiled with a single command: Build Workspace.

NOTE: In NetLinx Studio, the term "build" represents compiling multiple f iles with a Workspace, Project or System.

There are several ways to access the Build Workspace command - via the Build menu, the Workspace context menu (in the Workspace tab of the Workspace Bar), or via the toolbar button (FIG. 194):

Build Menu Workspace Context Menu Build Toolbar options

FIG. 194 Build Workspace command

  1. Select Build > Build Workspace.

Any errors detected by the program before the build operation starts are listed in the Pre-Build Errors dialog. This dialog gives you the option of ignoring the errors and continuing with the build.

  1. The status and results of the build are displayed in the Status tab of the Output Bar (FIG. 195):

FIG. 195 Output Bar - Status tab indicates example Build status information

Building the Selected Project

You can select to build a single Project within the open Workspace, using the Build Project command. When you compile a Project, every Source Code, Include, and Module file contained in all of the Systems within the selected Project are compiled.

There are several ways to access the Build Project command - via the Build menu, the Project Folder context menu (in the Workspace tab of the Workspace Bar), or via the toolbar button (FIG. 196):

Build Menu Workspace Context Menu Build Toolbar options

FIG. 196 Build Project command

  1. Click to select and highlight the Project that you want to compile (in the Workspace tab of the Workspace Bar).
  2. Select Build > Build <Project Name> Project.
    • Any errors detected by the program before the build operation starts are listed in the Pre-Build Errors dialog.
    • This dialog gives you the option of ignoring the errors and continuing with the build.
  3. The status and results of the build are displayed in the Status tab of the Output Bar.

Building the Selected System

You can select to build any System in the Workspace, using the Build System command. When you build a System, every Source Code, Include, and Module file contained in the selected System is compiled. The Build System command always works on the selected System, regardless of whether it is currently designated as the active system or not.

  1. Click to select (highlight) the System that you want to build (in the Workspace tab of the Workspace Bar).
  2. Select Build System <System name> from the Build menu.

Any errors detected by the program before the build operation starts are listed in the Pre-Build Errors dialog. This dialog gives you the option of ignoring the errors and continuing with the build.

  1. The status and results of the build are displayed in the Status tab of the Output Bar.

Building the Active System

You can select to build (compile) only the System currently designated as the Active System, using the Build Active System

command. When you compile a System, every Source Code, Include, and Module file contained in the selected System is compiled.

NOTE: The currently active System is indicated in bold (in the Workspace tab of the Workspace Bar). See the Designating the ActiveSystem section on page 40 for more information.

  1. Select Build Active System from the Build menu.
    • Any errors detected by the program before the build operation starts are listed in the Pre-Build Errors dialog.
    • Assuming that a Master Source Code file has been defined for the System, this dialog gives you the option of ignoring the errors and continuing with the build.
  2. The status and results of the build are displayed in the Status tab of the Output Bar.

Building an Individual File

You can select to compile a single Source Code, Include, or Module file, using the Compile and Compile As NetLinx commands (or toolbar buttons).

  1. Select the file that you want to compile:
    • If the file is already included in the open Workspace, click to select the file and select the appropriate Compile command from the Build menu.
    • If the file is not part of the open Workspace, open the file via the File > Open command, then right-click on the file (in the Editor window).
  2. Select the appropriate compile command. There are several ways to access the compile commands - via the Build menu, the System File context menus (in the Workspace tab of the Workspace Bar), the Editor window context window, or via the toolbar buttons.
    • If you create a new non-Project related file, without a Workspace file open, the Compile command compiles the file using the compiler associated with the file when it was created.
    • If you open an existing non-Project related file, with a Workspace open, the Compile command compiles the file using the compiler specified in the System communication settings for the currently active System.
    • The Compile as NetLinx command compiles the selected file using the NetLinx compiler.

NOTE: Any errors detected by the program before the build operation starts are listed in the Pre-Build Errors dialog. This dialog gives you the option of ignoring the errors and continuing with the build.

  1. The status and results of the build are displayed in the Status tab of the Output Bar.

Compiler Errors and Warnings

These help topics contain information on the various types of errors and bugs common to programming, and some techniques for solving these problems. Note that Warnings will not automatically preclude a successful compile operation. By contrast, Errors must be corrected before your program can be compiled.

Compiler Error Types

There are three general types of programming errors:

    • Compilation errors - Errors that occur at compile time. The compiler alerts you to these errors immediately and identifies each error and the line where it is located.
    • Run-time errors - Errors that occur after the program has been compiled and loaded into the Master Controller. These errors are caused by program statements that attempt illegal operations.
    • Logic errors - Logic errors are errors in program design and thus are the programmer's responsibility; The master cannot tell if the program it is executing is accomplishing what the user intends.

Compiler Errors

When the compiler finds an error during the compilation process, it informs the programmer. Most of the time these errors occur due to a typographical error or incorrect syntax of a particular command. Unlike warnings, errors must be corrected before your program can be executed. Compilation errors are described below:

Compiler Errors
A "<symbol>" was expected The compiler is expecting a certain symbol at this particular place.
Active keyword expected An ACTIVE keyword is not present after a SELECT keyword.
Allowed only in DEFINE_START A keyword that is only allowed to appear in the DEFINE_START section of the program was encountered elsewhere.
Attempted CALL to undefined subroutine A CALL statement refers to a subroutine that has not been defined with a DEFINE_CALL statement.
Comment never ends, EOF encountered A comment begins but never ends. Place a close comment, * ) at the end of the unfinished comment.
Conditional compile nesting too deep There are too many nested #IF_DEFINED or #IF_NOT_DEFINED conditional compilation statements. The limit is 20 nested conditional compilation statements.
Constant type not allowed A constant value was declared as latching, toggling, or mutually exclusive, as shown below:
DEFINE_CALL must have a name DEFINE_CALL must have a name after it. For example, DEFINE_CALL 'VHS'.
DEFINE_CALL name already used The name of the DEFINE_CALL has already been used.
Device values must be equal In a range specification, the devices (or their defined identifiers) must be equal. For example, ([1,1]..[1,5]) is valid; ([1,1]..[2,5]) is not.
Duplicate symbol Duplicate definitions of variables or constants are found. All variables and constants must have unique identifiers.
Evaluation stack overflow Evaluation stack underflow The expression is too complicated. Try breaking it up into smaller pieces.
Identifier expected The compiler is expecting an identifier after a #DEFINE statement or after an integer declaration in the DEFINE_VARIABLE section.
Identifier is not an array type A non-array variable was treated as an array.
Include file not found An INCLUDE statement was encountered, but the specified Include file could not be found.
Invalid Include file name A string literal enclosed in single quotes must follow the INCLUDE keyword.
Library file not found The library file containing the specified SYSTEM_CALL could not be found.
Maximum string length exceeded String literals are limited in length to 132 characters, including spaces.
Compiler Errors (Cont.)
Must be char array reference An array type variable was expected in CREATE_BUFFER, CREATE_MULTI_BUFFER, or CLEAR_BUFFER.
Must be integer reference The identifier in question must be an integer. This error occurs when the third parameter of CREATE_LEVEL is an array or array element.
NetLinx Compiler failed RT: -2147417851 ST:1 This error means that the compiler cannot find the line number to even check what type of error has occurred, so it gives no details on the cause.
Out of memory The compiler has run out of memory.
Parameter mismatch in CALL A value or variable passed to a CALL as a parameter is of the wrong type as defined by the DEFINE_CALL statement.
PROGRAM_NAME must be on line 1 Move the PROGRAM_NAME= statement to the first line of the program.
PUSH/RELEASE not allowed within PUSH/RELEASE A PUSH or RELEASE statement was found within a block of code headed by a PUSH or RELEASE statement.
PUSH/RELEASE not allowed within WAIT PUSH_CHANNEL not allowed within WAIT RELEASE_CHANNEL not allowed within WAIT PUSH_DEVICE not allowed within WAIT RELEASE_DEVICE not allowed within WAIT These keywords are not allowed in a section of code which will be executed due to a WAIT keyword.
String constant expected A string is required for the particular operation. This error occurs if a string literal enclosed in single quotes does not follow the PROGRAM_NAME keyword.
String constant never ends, EOF encountered A string literal is started but never ends.
String literal expected A string is required for the particular operation. This error would occur if a string literal enclosed in single quotes does not follow the #WARN keyword.
Subroutine may not call itself A subroutine cannot call itself. It can, however, call a different subroutine.
Syntax error A syntax error is found in an expression.
SYSTEM_CALL name not same as PROGRAM_NAME in <file> This error occurs when a library file is compiled and the name of the subroutine in the library file does not match the PROGRAM_NAME string on the first line of the file.
This variable type not allowed This error occurs when an attempt is made to use an array variable with DEFINE_LATCHING, DEFINE_TOGGLING, or DEFINE_MUTUALLY_EXCLUSIVE.
To not allowed within DEFINE_START To not allowed within MAINLINE These errors occur if the TO keyword is found in an erroneous location. The TO keyword can only be associated directly with a PUSH statement.
Too few parameters in CALL There are not enough parameters being passed to the subroutine.
Too many Include files A program may only contain up to 20 Include files.
Too many parameters in CALL There are too many parameters being passed to the subroutine.
Type mismatch in function CALL A function was called with a parameter of the wrong type. For instance, attempting to use ITOA with an array as a parameter will result in an error.
Undefined identifier An attempt was made to reference an identifier that has not been defined previously in the program.
Unmatched #END_IF An #END_IF keyword was found, but no #IF_DEFINED or #IF_NOT_DEFINED was previously compiled.
Unrecognized character in input file An invalid character was found during compilation.
Use SYSTEM_CALL [INSTANCE] 'NAME' This error occurs if a SYSTEM_CALL statement is written incorrectly as SYSTEM_CALL 'NAME' [INSTANCE NUMBER].
Variable assignment not allowed here Variables may not be assigned a value when they are defined in the DEFINE_VARIABLE section.
WAIT not found A statement references a WAIT by a name that does not exist. For example, CANCEL_WAIT 'CASS' will produce this error if there is no WAIT named CASS.

Compiler Warnings

Sometimes the compiler generates a warning message instead of an error message; these warning messages always start with ’w’. A warning about a particular statement means that the statement is not technically an error, but you should be careful doing it.

Warnings, unlike errors, do not stop the program from compiling.

Some types of warnings can be disabled in the Compiler Options tab of the Preferences dialog. Common compiler warnings are described below:

Compiler Warnings
(w) Cannot assign unlike types This warning occurs when a variable or value of one type is assigned to a variable of a different type. Here are some examples:
(w) Define_Call is not used This warning occurs at the end of program compilation for each DEFINE_CALL subroutine that was declared but never used.
(w) Integer applies to arrays only This warning appears when the keyword INTEGER is applied to a non-array type of variable. Doing this is not an error, because non-array variables are already integers, but it is redundant.
(w) Long_While within While This warning occurs if the compiler finds a LONG_WHILE or MEDIUM_WHILE inside a block of code following a WHILE keyword. This warning exists because the WHILE command has a 1/2 second timeout period, and the LONG_WHILE and MEDIUM_WHILE keywords do not.
(w) Possibly too many nested levels This warning appears if there is a large amount of nesting in the program. This can happen with a long chain of IF...ELSE IF statements.
(w) Variable is not used This warning occurs at the end of compilation for each variable that was declared but never used. The generation of this warning can be turned on or off in the Compiler Options tab of the Preferences dialog.

Compiler Error Warnings Report dialog

This dialog is invoked via the Compiler Errors/Warning Report option in the Output Bar Context Menu (FIG. 197).

FIG. 197 Compiler Error Warnings Report dialog

    • Use the options in this dialog to specify what you want to include in the report (Errors, Warnings, or both). By default, both Errors and Warning are included.
    • Note that Warnings will not automatically preclude a successful compile operation. By contrast, Errors must be corrected before your program can be compiled.

Disabling Compiler Warnings in NetLinx Code

Disabling NetLinx compiler warnings can be done in code by adding a #DISABLE_WARNING statement with a warning number generated by the compiler. For example, if you are getting a warning you want to disable, such as:

WARNING: U:\My Documents\Studio\Test\DISABLE_WARNINGtest.axs(12). C10571: Converting type [SINTEGER] to [INTEGER]

The warning number is 10571. Add the line to the beginning of the code file:

DISABLE_WARNING 10571

The code will now compile without generating the specified warning.

Run-Time Errors

In many cases, a program is compiled and sent to the Master Controller error-free, but the System does not act in the way it should. If the program code is correct, you should check for run-time errors. These errors occur in the Master Controller, usually when it could not perform a particular operation in the program.

Run-Time errors are errors that occur during program execution, and are described below:

Run-Time Errors
Bad assign 2dim... These errors occur if an attempt is made to assign a two-dimensional array to a different type (such as a variable or one-dimensional array), and vice versa.
Bad assign Call... These errors occur if the Master Controller cannot assign a parameter in a CALL statement to the parameter in the corresponding DEFINE_CALL statement.
Bad element assign... These errors occur if an assignment is attempted past the end of an array, or to the Ø location of an array (for example, ARRAY[Ø]).
Bad Off... Bad On... Bad To... These errors indicate that the device-channel or variable that is being referenced by an OFF, ON, or TO keyword is out of range.
Bad re-assign Call... These errors occur when the Master Controller attempts to re-assign the parameter variables in a DEFINE_CALL to the parameters in the corresponding CALL statement, and the assignment cannot be made.
Bad run token This error occurs when the Master Controller does not understand a piece of data in the program it is executing.
Bad Set_Length... These errors occur if the SET_LENGTH_STRING keyword tries to set the length value of an array to a value greater than the array's storage capacity.
Bad While This error occurs whenever a WHILE loop terminates due to the half-second timeout imposed on WHILE loops.

results matching ""

    No results matching ""