Admin Production ni-theme
Current Publication

UI CodeBuilder Overview

LabWindows/CVI

CodeBuilder Overview

Use LabWindows/CVI CodeBuilder to automatically generate complete C code that compiles and runs based on a user interface resource (.uir) file. Select from the options in the Code»Generate menu to produce skeleton code. Skeleton code is syntactically and programmatically correct code that compiles and runs before you type a single line of code. CodeBuilder generates template code, helping you eliminate syntax and typing errors and maintaining an organized source code file with a consistent programming style. Because a CodeBuilder program compiles and runs immediately, you can develop and test the project you create, concentrating on one function at a time.

When you choose Code»Generate»All Code, LabWindows/CVI places the #include statements, variable declarations, callback function skeletons, and main function in the source code file you specify as the target file. To generate code for a specific control or panel callback function, select Code»Generate»Panel Callback or Code»Generate»Control Callbacks. Each function skeleton contains a switch construct with a case statement for every default event you specify. You can set default events for control callback functions and panel callback functions by choosing Code»Preferences. Although the skeleton code runs, you must customize the code to implement the actions you want to take place for each event.

In order for a project to run, the main function must exist. If you lack the main function or any of the callback functions you reference in the .uir file, the code is incomplete.

It is good practice to use the Code»Generate»All Code option first to produce a running project from the current state of the .uir file. Then, after adding panels, controls, or menu items to the .uir file, select Code»Generate»Panel Callback, Control Callbacks, or Menu Callbacks to create corresponding additions to the source file.

Also with CodeBuilder, you can make sure that your automatically generated program terminates properly. For a CodeBuilder program to terminate successfully, you must include a call to QuitUserInterface. When you choose Code»Generate»All Code, the Generate All Code dialog box prompts you to choose which callback functions terminate the program. You can select one or more callback functions to ensure proper program termination.