![](https://www.opentextbooks.org.hk/sites/opentextbooks/files/book_profile/cc_icon/by-sa.png)
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.
![media/image1.png](http://www.opentextbooks.org.hk/system/files/resource/8/8091/8150/media/image1.png)
In the Front Panel window, from the Functions »Modern »Numeric select the vertical pointer slide. From the Functions »Modern »Graph select Waveform Chart.
![media/image2.png](http://www.opentextbooks.org.hk/system/files/resource/8/8091/8150/media/image2.png)
![media/image3.png](http://www.opentextbooks.org.hk/system/files/resource/8/8091/8150/media/image3.png)
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.
![media/image4.png](http://www.opentextbooks.org.hk/system/files/resource/8/8091/8150/media/image4.png)
Right click on Sine Wave and select Properties from the pop-up menu.
![media/image5.png](http://www.opentextbooks.org.hk/system/files/resource/8/8091/8150/media/image5.png)
Select the Scales tab and change Maximum to 1023. Sine Wave will display 1024 samples.
![media/image6.png](http://www.opentextbooks.org.hk/system/files/resource/8/8091/8150/media/image6.png)
Click on the down arrow located to the right of Time (XAxis) and select Amplitude (YAxis).
![media/image7.png](http://www.opentextbooks.org.hk/system/files/resource/8/8091/8150/media/image7.png)
De-selectAutoscale and change the Minimum and Maximum values to-10 and 10. ClickOK.
![media/image8.png](http://www.opentextbooks.org.hk/system/files/resource/8/8091/8150/media/image8.png)
Rearrange Amplitude and Sine Wave terminals and finish the program as shown in Figure Figure 8.9. Scroll the mouse pointer over the Loop Control...
![media/image9.png](http://www.opentextbooks.org.hk/system/files/resource/8/8091/8150/media/image9.png)
![media/image10.png](http://www.opentextbooks.org.hk/system/files/resource/8/8091/8150/media/image10.png)
And right click on the Loop Control and from the pop-up menu select Create Control. A stop terminal is created.
![media/image11.png](http://www.opentextbooks.org.hk/system/files/resource/8/8091/8150/media/image11.png)
![media/image12.png](http://www.opentextbooks.org.hk/system/files/resource/8/8091/8150/media/image12.png)
With the corresponding stop Boolean input control. Save the G program asInteractivity.vi.
![media/image13.png](http://www.opentextbooks.org.hk/system/files/resource/8/8091/8150/media/image13.png)
Run the G program.
![media/image14.png](http://www.opentextbooks.org.hk/system/files/resource/8/8091/8150/media/image14.png)
While the program is running, change the Amplitude and watch the graph update to reflect the interactive changes.
![media/image15.png](http://www.opentextbooks.org.hk/system/files/resource/8/8091/8150/media/image15.png)
To end the G program, simply click on the stop button.
![media/image16.png](http://www.opentextbooks.org.hk/system/files/resource/8/8091/8150/media/image16.png)
Congratulations. You have successfully completed and executed your first interactive G program.
- 1439 reads