Using the Code Wizard
With a source code f ile open, select Edit > Advanced > Code Wizard to launch the Code Wizard. The Code Wizard presents a series of dialogs that help you quickly generate various types of NetLinx code segments. The dialogs in the Code Wizard have default selections that should apply to most typical code files. Adjust these selections as needed.
There are two modes for the Code Wizard: the "Wizard-Style", which steps you through a series of dialogs based on selections prompted by the program, or the tabbed dialog (FIG. 165).
Wizard style Tabbed dialog
FIG. 165 Code Wizard dialog (both modes
Code Wizard - Creating Button Events
- With I want to generate one or more BUTTON EVENT(s) selected, click Next to proceed to the next dialog in the Wizard (FIG. 166).
- By default, the Code Wizard configures Button Events to generate both Push and Release statements. De-select Pushed and/ or Released to avoid generating these statements.
- Select Create Feedback Statements if desired (unchecked by default). Note that if you select this option, these Button Events cannot be set to handle all buttons.
- Click Next to proceed to the next dialog (FIG. 167).
FIG. 167 Button Event Code Wizard dialog 2
- Use this dialog to specify how many buttons should be handled by this Button Event:
- By default, I want to handle a single button is selected. With this option selected, enter the button number to associate with this event in the Button: field (FIG. 167).
- With I want to handle a range of buttons selected, indicate the range of buttons to include (First and Last) to associate with this event in the Button: field (FIG. 168).
FIG. 168 Button Event Code Wizard dialog 2 - Range of Buttons
- Select I want to handle all buttons to apply this event to all buttons. Note that this option is unavailable if the Create Feedback Statements option is selected in the first dialog.
Click Next to proceed to the last dialog in the Button Event Code Wizard (FIG. 169).
- Enter the name of the device for which this Button Event will be created in the Device field (default = MyDevice), and enter a descriptive comment for the generated Button Event code in the Comment field if desired (default = Code Wizard Code).
- Click Finish to close the Code Wizard. The generated code is added to the code file in the active Editor window.
Code Wizard - Creating Channel Events
- With I want to generate one or more CHANNEL EVENT(s) selected, click Next to proceed to the next dialog in the Wizard (FIG. 170).
FIG. 170 Channel Event Code Wizard dialog 1
- Select On and/or Off to create on and/or off statements for this Channel Event as desired (both unchecked by default). Note that at least one option must be selected to enable the Next button.
- Click Next to proceed to the next dialog (FIG. 171).
FIG. 171 Channel Event Code Wizard dialog 2
- Use this dialog to specify how many channels should be handled by this Channel Event:
- By default, I want to handle a single channel is selected. With this option selected, enter the channel number to associate with this event in the Channel: field (as show in FIG. 171).
- With I want to handle a range of channels selected, indicate the range of channels to include (First and Last) to associate with this event (FIG. 172).
FIG. 172 Channel Event Code Wizard dialog 2 - Range of Channels
- Select I want to handle all channels to apply this event to all channels.
Click Next to proceed to the last dialog in the Channel Event Code Wizard (FIG. 173).
FIG. 173 Channel Event Code Wizard dialog 3
- Enter the name of the device for which this Channel Event will be created in the Device field (default = MyDevice), and enter a descriptive comment for the generated Channel Event code in the Comment field if desired (default = Code Wizard Code).
- Click Finish to close the Code Wizard. The generated code is added to the code file in the active Editor window.
Code Wizard - Creating Level Events
- With I want to generate one or more LEVEL EVENT(s) selected, click Next to proceed to the next dialog in the Wizard (FIG. 174).
FIG. 174 Level Event Code Wizard dialog 1
- Use this dialog to specify how many levels should be handled by this Level Event:
- By default, I want to handle a single level is selected. With this option selected, enter the level number to associate with this event in the Level: field (FIG. 174).
- With I want to handle a range of levels selected, indicate the range of levels to include (First and Last) to associate with this event (FIG. 175).
FIG. 175 Channel Event Code Wizard dialog 2 - Range of Levels
- Select I want to handle all levels to apply this event to all levels.
Click Next to proceed to the last dialog in the Level Events Code Wizard (FIG. 176).
FIG. 176 Level Event Code Wizard dialog 3
- Enter the name of the device for which this Level Event will be created in the Device field, and enter a descriptive comment for the generated Level Event code in the Comment field if desired.
- Click Finish to close the Code Wizard. The generated code is added to the code file in the active Editor window.
Code Wizard - Creating Data Events
- With I want to generate a DATA EVENT selected, click Next to proceed to the next dialog in the Wizard (FIG. 177).
FIG. 177 Data Event Code Wizard dialog 1
- Select one or more data event types for which to create statements in the code (Comes ONLINE, Goes OFFLINE, Send a STRING, Send a COMMAND, and Generate an ERROR - all unchecked by default). Note that at least one option must be selected to enable the Next button.
- Click Next to proceed to the next dialog (FIG. 178).
FIG. 178 Data Event Code Wizard dialog 2
- Enter the name of the device for which this Data Event will be created in the Device field, and enter a descriptive comment for the generated Data Event code in the Comment field if desired.
- Click Finish to close the Code Wizard. The generated code is added to the code file in the active Editor window.
Code Wizard - Creating SEND_COMMANDs
- With I want to generate a SEND_COMMAND selected, click Next to proceed to the next dialog in the Wizard (FIG. 177).
FIG. 179 SEND_COMMAND Code Wizard dialog 1
- Specify the type of SEND_COMMAND to create:
- PAGE - Make a new page visible on a touch panel
- @PPN - Make a new popup page visible on a touch panel
If either of these options are selected, enter the desired Page Name in the text box provided. Note that if a Page option is selected, the Text option (below) is disabled.
- ^TXT or @TXT - Change the text of a button on a touch panel
If this option is selected, specify the Variable Text Channel (for the target button), and enter the replacement Text for that button in the field provided.
- Click Next to proceed to the next dialog (FIG. 178).
FIG. 180 SEND_COMMAND Code Wizard dialog 2
- Enter the name of the target device for this Send Command event in the Device field, and enter a descriptive comment for the generated code in the Comment field if desired.
- Click Finish to close the Code Wizard. The generated code is added to the code file in the active Editor window.
Code Wizard - Generating Constants from an IR File
- With I want to generate constants from an IR f ile selected, click Next to proceed to the next dialog in the Wizard (FIG. 181).
FIG. 181 IR File Constants Code Wizard dialog 1
- Specify the IR file to generate constants from (use the Browse (...) button to locate and select the file via the Open IR File
dialog).
- Specify a comment to add to the generated code segment containing the IR constants (optional), and specify a prefix to be added to each IR constant generated (also optional).
- Click Finish to close the Code Wizard. The new IR constants from the specified file are placed in the active Source Code file, in the DEFINE_CONSTANT section.
Code Wizard - Tabbed Dialog (Advanced Users)
You can toggle the Code Wizard to show the individual dialogs (containing detailed options) for all the above functionality that can be used by advanced users. To view the advanced options in every dialog, de-select the Use Wizard Style check box (selected by default). When the Code Wizard generates a new code segment, it is inserted in the active Source Code file, in the appropriate section of the code.
Code Wizard Dialog - Button Tab
Select Tools > Code Wizard to launch the NetLinx Studio Code Wizard. Uncheck the Use Wizard Style check box to access the individual tabs containing detailed options for each code type. The Button tab is shown in FIG. 182:
FIG. 182 Code Wizard dialog - Button tab
- In NetLinx, button events are always created using the BUTTON_EVENT handler in the DEFINE_EVENT section. The items on the Button tab are described below:
Code Wizard - Button Tab options | |
---|---|
Push | Generate PUSH statements |
Release | Generate RELEASE Statements |
Hold | Generate HOLD statement. |
Feedback | Generate feedback assignments. |
No Arrays | Button Range will be generated without using arrays, i.e. multiple BUTTON_EVENTs, PUSHes or RELEASEs will be generated. |
Use DEVCHAN | Button ranges will be placed in a DEVCHAN array named Array Name using the Device and button range defined as From through To in the DEFINE_VARIABLE section. A single BUTTON_EVENT statement referencing Array Name will be generated. Note that when Use DEVCHAN is selected, GET_LAST() is selected and disabled. |
Use INTEGER | Button ranges will be placed in an INTEGER array named Array Name using the button range defined as From through To in the DEFINE_VARIABLE section. A single BUTTON_EVENT statement referencing Device and Array Name will be generated. |
GET_LAST() | This option will include a calculation for the button index using a mathematical calculation, BUTTON.INPUT.CHANNEL - From, for non-array button ranges and a function call to GET_LAST(), GET_LAST(Array Name), for array button ranges. |
SWITCH/CASE | This option will include a SWITCH/CASE construct under the PUSH and/or RELEASE statements. The SWITCH will be based on the Button Index. Note that when SWITCH/CASE is selected, the Button Index option is selected and disabled. |
Stacked | This option will cause each button in the Array Name definition to be generated on its own line with an empty comment at the end of the line. If this option is not selected, eight channels will be generated on each line with an empty comment above the line. |
Hold Repeat | This option will include the REPEAT keyword in the HOLD event handler. |
Device | The device name used during code generation. This name may appear in a DEVCHAN definition, BUTTON_EVENT, PUSH, RELEASE or feedback assignment statements depending on the platform and options selected. |
From, To, Total | The button range used during code generation. The range is 1 - 1000. You may change any of these values; the others will adjust automatically. |
Array Name | The array name used for generating DEVCHAN or INTEGER array for button ranges. |
Hold Time | This value is used when generating the HOLD statement. |
Comment | This value is used on the lines before the array definition, BUTTON_EVENT, PUSH, and RELEASE and feedback statements as determined by the options. |
Insert | Once you have made the relevant selections on this tab, click this button to insert the specified code into the file. |
Code Wizard Dialog - Channel Tab
The items in the Channel tab (FIG. 182) are described below:
FIG. 183 Code Wizard dialog - Channel tab
Code Wizard - Channel Tab options | |
---|---|
On | Generate ON statements |
Off | Generate OFF Statements |
No Arrays | Channel ranges will be generated without arrays (i.e. multiple CHANNEL_EVENTs will be generated). |
Use DEVCHAN | Channel ranges will be placed in a DEVCHAN array named Array Name using the Device and channel range defined as From through To in the DEFINE_VARIABLE section. A single CHANNEL_EVENT statement referencing Array Name will be generated. Note that when Use DEVCHAN is selected, GET_LAST() is selected and disabled. |
Use INTEGER | Channel ranges will be placed in an INTEGER array named Array Name using the channel range defined as From through To in the DEFINE_VARIABLE section. A single CHANNEL_EVENT statement referencing Device and Array Name will be generated. |
Channel Index | This option will include a calculation for the channel index using a mathematical calculation, CHANNEL.CHANNEL - From, for non-array channel ranges and a function call to GET_LAST(), GET_LAST(Array Name), for array channel ranges. |
SWITCH/CASE | This option will include a SWITCH/CASE construct under the ON and/or OFF statements. The SWITCH will be based on the Channel Index. Note that when SWITCH/CASE is selected, the Channel Index option is selected and disabled. |
Stacked | This option will cause each channel in the Array Name definition to be generated on its own line with an empty comment at the end of the line. If this option is not selected, eight channels will be generated on each line with an empty comment above the line. |
Device | The device name used during code generation. This name may appear in a DEVCHAN definition or CHANNEL_EVENT statement depending on the platform and options selected. |
From, To, Total | The channel range used during code generation. The range is 1 - 1000. You may change any of these values; the others will adjust automatically. A value of 0 (zero) in the From field will generate an "all channel" handler. In this case, code generation cannot support arrays. |
Array Name | The array name used for generating DEVCHAN or INTEGER array for channel ranges. |
Comment | This value is used on the lines before the array definition, CHANNEL_EVENT statements as determined by the options. Comments in NetLinx are always line-style comments (i.e. //). |
Insert | Once you have made the relevant selections on this tab, click this button to insert the specified code into the file. |
Code Wizard Dialog - Level Tab
The advanced options available for LEVEL_EVENTs in the Level tab (FIG. 184) are described below:
FIG. 184 Code Wizard dialog - Level tab
Code Wizard - Level Tab options | |
---|---|
Event | Generate LEVEL_EVENT statements. |
Create | Generate CREATE_LEVEL statements. |
Send | Generate SEND_LEVEL statements. |
No Arrays | Level ranges will be generated without using arrays (i.e. multiple LEVEL_EVENTs will be generated). |
Use DEVLEV | Level ranges will be placed in a DEVLEV array named Array Name using the Device and button range defined as From through To in the DEFINEVARIABLE section. A single LEVEL_EVENT statement referencing Array Name will be generated. If CREATE_LEVEL and/or SEND_LEVEL statements will be generated, each construct will reference this array for the level number for NetLinx only. Note that when _Use DEVCHAN is selected, GET_LAST() is selected and disabled. |
Use INTEGER | Level ranges will be placed in an INTEGER array named Array Name using the button range defined as From through To in the DEFINE_VARIABLE section. A single LEVEL_EVENT statement referencing Device and Array Name will be generated. If CREATE_LEVEL and/or SEND_LEVEL statements will be generated, each construct will reference this array for the level number. |
Level Index | This option will include a calculation for the level index using a mathematical calculation, LEVEL.INPUT.LEVEL- From, for non-array level ranges and a function call to GET_LAST(), GET_LAST(Array Name), for array level ranges. The option is only used for LEVEL_EVENTs. |
SWITCH/CASE | This option will include a SWITCH/CASE construct under the LEVELEVENT statement. The SWITCH will be based on the Level Index. Note that when SWITCH/CASE is selected, the _Level Index option is selected and disabled. |
Stacked | This option will cause each level in the Array Name definition to be generated on it's own line with an empty comment at the end of the line. If this option is not selected, eight levels will be generated on each line with an empty comment above the line |
Device | The device name used during code generation. This name may appear in a DEVLEV definition, LEVEL_EVENT, CREATE_LEVEL or SEND_LEVEL statements depending on the platform and options selected. |
From, To, Total | The level range used during code generation. The range is 1 - 1000. You may change any of these values; the others will adjust automatically. A value of 0 (zero) in the From field will generate an "all level" LEVEL_EVENT handler. In this case, code generation cannot support arrays. |
Array Name | The array name used for generating DEVLEV or INTEGER array for level ranges. |
Value/Variable Name | The array name or value used for generating CREATE_LEVEL or SEND_LEVEL statements. If generating code for a level range on NetLinx, this variable will be created as an array. |
Comment | This value is used on the lines before the array definition, LEVEL_EVENT, CREATE_LEVEL, and SEND_LEVEL statements as determined by the options. Comments in NetLinx are always line-style comments (i.e. //). |
Insert | Once you have made the relevant selections on this tab, click this button to insert the specified code into the file. |
Code Wizard Dialog - Data tab
The advanced options available for DataEvents in the Data tab of the _Code Wizard dialog (FIG. 185) are described below:
FIG. 185 Code Wizard dialog - Data tab
Code Wizard - Data Tab options | |
---|---|
Online | Generate ONLINE statements. |
Offline | Generate OFFLINE statements. |
OnError | Generate ONERROR Statements. |
String | Generate STRING statements. |
Command | Generate COMMAND Statements. |
Create Buffer | Define a buffer and connect it to a device using CREATE_BUFFER, in the DEFINE_START section. |
Process Buffer | Generate a construct for detecting incoming strings. |
Device | The device name used during code generation. This name may appear in a variable declaration, ONLINE/OFFLINE construct, DATA_EVENT or CREATE_BUFFER statements depending on the platform and options selected. |
Comment | This value is used on the lines before the variable declaration, ONLINE/OFFLINE construct, DATA_EVENT or CREATE_BUFFER statements as determined by the options. |
Insert | Once you have made the relevant selections on this tab, click this button to insert the specified code into the file. |
Code Wizard Dialog - Send Command tab
The advanced options available for SENDCOMMANDs in the Send Command tab of the _Code Wizard dialog (FIG. 186) are described below:
FIG. 186 Code Wizard dialog - Send Command tab
Code Wizard - Send Command options | |
---|---|
Page | Generate PAGE- page flip send command for touch panels. |
^TXT or @TXT | Generate ^TXT or @TXT variable text send command for touch panels. |
@BMF | Generate @BMF variable text send command for touch panels. |
@PPN | Generate @PPN- popup on send command for touch panels. |
@PPF | Generate @PPF- popup off send command for touch panels. |
@PPK | Generate @PPK- popup kill send command for touch panels. |
@PPX | Generate @PPX- kill all popups send command for touch panels. |
Custom | Generate a custom send command. |
Device | The device name used during code generation. This name will appear in the SEND_COMMAND statement. |
Variable Text | Enter the variable text to be used during code generation. This name will appear in the SEND_COMMAND statement. |
Page Name | Enter the Page Name command parameter to be used in the SEND_COMMAND. |
Comment | This value is used on the line before the SEND_COMMAND statement. Comments in NetLinx are always line-style comments (i.e. //). |
Insert | Once you have made the relevant selections on this tab, click this button to insert the specified code into the file. |
Code Wizard Dialog - IR Constant Tab
Constants are generated from IR files. One constant is generated for every IR function and are placed in the DEFINECONSTANT section. The advanced options available for IR Constants in the IR Constant tab of the _Code Wizard dialog (FIG. 187) are described below:
FIG. 187 Code Wizard dialog - IR Constant tab
Code Wizard - IR Constant options | |
---|---|
Device | The device name used during code generation. This name is used to generate the Constant Prefix field. |
IR File | The IR file for which you would like to generate constants. |
Constant Prefix | The prefix to precede all constant declaration. By default, this will be <Device>_. |
Comment | This value is used on the line before the constant declarations. Comments in NetLinx are always line-style comments (i.e. //). |
Insert | Once you have made the relevant selections on this tab, click this button to insert the specified code into the file. |