Inside Collection (Textbook): Introduction to G Programming
Summary: The creation of this content was supported in some part by NSF grant 0538934.
The heart of interactive programming in G is the while loop. Any input control within the while loop can be modified from the Front Panel window at run time to provide seamless interaction with the G program.
![]() |
In the Front Panel window, from the Functions >> Modern >> Numeric select the vertical pointer slide. From the Functions >> Modern >> Graph select Waveform Chart.
![]() |
![]() |
Re-label the vertical pointer slide as Amplitude and the waveform chart as Sine Wave. Re-arrange to GUI to look like the figure below.
![]() |
Right click on Sine Wave and select Properties from the pop-up menu.
![]() |
Select the Scales tab and change Maximum to 1023. Sine Wave will display 1024 samples.
![]() |
Click on the down arrow located to the right of Time (X-Axis) and select Amplitude (Y-Axis).
![]() |
De-select Autoscale and change the Minimum and Maximum values to -10 and 10. Click OK.
![]() |
Rearrange Amplitude and Sine Wave terminals and finish the program as shown in Figure 9.
Scroll the mouse pointer over the Loop Control…
![]() |
![]() |
And right click on the Loop Control and from the pop-up menu select Create Control.
A stop terminal is created.
![]() |
![]() |
With the corresponding stop Boolean input control. Save the G program as Interactivity.vi.
![]() |
Run the G program.
![]() |
While the program is running, change the Amplitude and watch the graph update to reflect the interactive changes.
![]() |
To end the G program, simply click on the stop button.
![]() |
Congratulations. You have successfully completed and executed your first interactive G program.