With the LabWindows/CVI CodeBuilder, you can create automatically complete C code that compiles and runs based on a user interface (.uir) file you are creating or editing. By choosing certain options in the Code menu, you can produce skeleton code. Skeleton code is syntactically and programmatically correct code that compiles and runs before you have typed a single line of code. With the CodeBuilder feature, you save the time of typing in standard code included in every program, eliminate syntax and typing errors, and maintain 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. 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 skeleton code runs, you must customize it to implement the actions you want to take place in the case of each event.
When you generate code for a specific control or panel callback function, LabWindows/CVI places the skeleton code for that function in the target file in the same complete format as was done for the Code»Generate»All Code command. However, this code might not run. In order for a project to run, a 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, use the Generate Panel, Control Callbacks, and Menu Callbacks commands to make 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.