In Windows applications they are called spinner controls, in Retro GUI IDE I call them number boxes, why ? well I guess from text box to number box. This is not a WeeGUI object (view) but it is composed of two buttons and a &print statement. There are three of these in the KENO simulator, one for how many number the player will play, one for the number of games to simulate and the third is used to help pick the numbers on the board to play. In this post the number of games option will be explored.
In this version of KENO the player can select to play between 5 and 10 numbers inclusive. A label is added to identify the number box “How many #’s to play :”, at position 2, 14. The number box then is added at 26,14, with a width of 3. This will result in the characters for the number, one space and two button next to each other. One button will lower the number by 1 and the other will raise it. Here’s what it looks like in the IDE and when run.
The Min and Max cotrols in the IDE will be the limits that the number box can take values. The value field is the starting value for the number box, the number of games in the running program is 10. There is some minor complexity to the code that is automatically genetated. There is code that is needed to create the control in WeeGUI then some in the call back function for each button to increase or decrease the value, which is stored in a variable also created by the code building engine.
The code segment below is what is needed to create the increase “>” and decrease “<” buttons and to display the initial value. Line 60102 is the increase button, the following line is the decrease button. Line 60104 creates the variable VG to hold the value for the number box, sets it to 10 and then creates a string so it can be displayed VG$. It’s important to note the variable names VA-VP should be avoided as then will be used for values for views 0-15, where VA is for view 0, VB for view 1 etc. In addition line number 10000-25999 should be used for call back functions where line 10000 is the starting line number for view 0, 11000 for view 1 upto to 25000 for view 15. For this number box the bottons are views number 6 and 7, so the blocks of code 16000 and 17000 are the callback area as can been seen in the &BUTTN statements below.
When a button is clicked a gosub is executed within WeeGUI to the callback line number. For a number box the call back funtion is automatically written, but one could also add additional code if some other actions were needed in the program. The auto generated code is pictured below:
Lines 16000, 16005 and 16010 are used to process a click of the decrease “<” button.
16000 checks if the value is already at the minum then jump the return
16005 decreases the value of VG and redisplays
Lines 17000-17010 per a similar approach for the increase button excpet increase the value of VG by one. As I write this I am thinking there may be occasion to want to change the min and max values based on some other actions in the program, I’ll be adding that to my future enhancements list.
The next post will cover the combination of the a number box and button with associated code to allower the player to select the numbers to play.