Post Reply 
User tabs
04-09-2019, 05:31 PM (This post was last modified: 04-11-2019 04:45 AM by Gene222.)
Post: #1
User tabs
I am trying to learn how to write programs with user tabs. In the program below, I can create a user tab to rerun the program, but I cannot create a tab to exit the program. When I press the exit tab, the program still shows the print terminal, and I have to press the Esc key to return to the Home screen. How can I cleanly exit the program without having to press the esc key?

PHP Code:
EXPORT Menu_Example_2()  //main program
BEGIN 

  LOCAL m
m1mxmy;   //tab variables
  
LOCAL x,y,z;           //input variables

  
INPUT( { {x,[0],{24,18,2}},
           {
y,[0],{24,18,3}},
           {
z,[0],{24,18,4}}},
         
"Menu Input Example",
         { 
"x = ",
           
"y = ",
           
"z = "});

  
//write to the print terminal
  
PRINT();             //clears terminal print buffer
  
PRINT("x = "+x);     //writes to terminal print buffer
  
PRINT("y = "+y);
  PRINT(
"z = "+z);

  
DRAWMENU("x""repeat""exit1""tab 4""tab 5""tab 6");  //draws tabs on the screen

  
WAIT(1);  //displays print terminal screen with the user tabs, pauses for 1 second waiting for a command.
            //after one second, print terminal screen is still displayed (or active), and program continues.

  
REPEAT 
    m 
:= MOUSE;         //MOUSE pauses the program
                        //displays the print terminal screen waiting for a tap on the screen
                        //when the screen is tapped, returns list of tap coordinates {{x1,y1},(x2,y2}...}
    
m1 := m(1);         //stores first element of the list {x1,y1} into m1
  
UNTIL SIZE(m1) > 0;   //exit loop when tap coordinates are found

  
mx := m1(1);          //store x1 coordinate
  
my := m1(2);          //store y1 coordinate

  
IF my ≥ 220 AND my ≤ 239 THEN          //is y1 coordinate between 220 and 239?

    
IF mx ≥ 0 AND mx ≤ 51 THEN           //Is tab 1 x coordinate found?
      
RETURN ("tab 1 was pressed "+x);      //returns text and number to the command line, but displays
                                            //print terminal screen.  User must press Esc key
    
END;                                    //to return to Home or program catalog screen.
    
    
IF mx ≥ 53 AND mx ≤ 104 THEN         //Is tab 2 x coordinate found?
      
Menu_Example_2();                     //Run the main program again
                                            //Contents of variables x,y,z were cleared.
    
END;

    IF 
mx ≥ 106 AND mx ≤ 157 THEN        //Is tab 3 x coordinate found?
      
RETURN;                               //displays print terminal screen.  
                                            //User must press Esc key to return to Home or program catalog screen.                               
    
END;                                    

    IF 
mx ≥ 159 AND mx ≤ 210 THEN 
      
//no action
    
END;

    IF 
mx ≥ 212 AND mx ≤ 263 THEN 
      
//no action
    
END;

    IF 
mx ≥ 265 AND mx ≤ 319 THEN 
      
//no action
    
END;

  
END;

END//end of program 


A revised program is shown below. I still can't cleanly exit the program with a single tap and return to the Home screen. Also, when repeating the program several times and then pressing the exit 2 tab, the WAIT period seems to be cumulative. The row of user tabs blocks any underlying text on the terminal screen. One cannot scroll the text up or down, while the user tabs are displayed.

PHP Code:
EXPORT UserTabs2()  //main program
BEGIN 

  LOCAL m
m1mxmy;   //tap variables
  
LOCAL x,y,z,z1;        //input variables and counter z1
  
LOCAL total,sum_xy;

  
z1:=0;  //zero WHILE loop counter or flag variable

  
INPUT( { {x,[0],{24,18,2}},
           {
y,[0],{24,18,3}},
           {
z,[0],{24,18,4}}},
         
"User Tabs Input Example",
         { 
"x = ",
           
"y = ",
           
"z = "});

  
//write to the print terminal
  
PRINT();             //clears print terminal buffer
  
PRINT("x = "+x);     //writes to print terminal buffer
  
PRINT("y = "+y);
  PRINT(
"z = "+z);

  
//This WHILE loop will repeat the tap procedure, until the user presses one of the active tabs.
  //After which, the tab procedures end the program.
  
WHILE z1==DO

    
DRAWMENU("x""repeat""exit""exit 2""total""Σxy");  //draws tabs on the screen
                                                                //these tabs are just pictures and have no special features.
    
WAIT(1);  //Displays print terminal screen with the user tabs, pauses for 1 second 
              //waiting for a command.  After one second, print terminal screen is still 
              //displayed (or active), and program continues.
              //WAIT(-1) will return in 60 sec OR a key or a mouse event.
  
    // This REPEAT-UNTIL loop will fetch the screen tap coordinates.  The screen tap 
    // coordinates can be within one of the user tabs, or outside of the user tabs,
    // such as in the middle of the screen.
    
REPEAT 
      m 
:= MOUSE;         //MOUSE pauses the program
                          //Displays the print terminal screen waiting for a tap on the screen
                          //When the screen is tapped, returns list of tap coordinates {{x1,y1},(x2,y2}...}
      
m1 := m(1);         //stores first element of the list {x1,y1} into m1
    
UNTIL SIZE(m1) > 0;   //exit loop when tap coordinates are found

    
mx := m1(1);          //store x1 coordinate
    
my := m1(2);          //store y1 coordinate

    // These nested IF statements check to see if the tap was within the user tab
    
IF my ≥ 220 AND my ≤ 239 THEN          //Was the screen tap within the row of user tabs?

      
IF mx ≥ 0 AND mx ≤ 51 THEN           //Was tab 1 pressed?
        
z1:=1;                             //flag to exit loop
        
RETURN ("tab 1 was pressed "+x);   //returns text and number to the Home screen, but displays
      
END;                                 //print terminal screen.  User must press Esc key to return to Home
    
      
IF mx ≥ 53 AND mx ≤ 104 THEN         //Was tab 2 pressed?
        
UserTabs2();                       //Runs the main program again, Variables x,y,z are cleared.
      
END;

      IF 
mx ≥ 106 AND mx ≤ 157 THEN        //Was tab 3 pressed?
        
z1:=1;                             //flag to exit loop  
        
RETURN;                            //WAIT(1) seems to be accumulative when repeating the program several times                
      
END;                                 //before pressing the exit tab

      
IF mx ≥ 159 AND mx ≤ 210 THEN        //Was tab 4 pressed?
        
z1:=1;                             //flag to exit loop
        
PRINT(" ");
        PRINT(
"x1 coordinate (mx) = "+mx);
        PRINT(
"y1 coordinate (my) = "+my);
        PRINT(
"while loop counter (z1) = "+z1);
        PRINT(
"Press Esc key to exit");
      
END;

      IF 
mx ≥ 212 AND mx ≤ 263 THEN        //Was tab 5 pressed?
        
total:=x+y+z;
        PRINT(
" ");
        PRINT(
"total = "+total);
      
END;

      IF 
mx ≥ 265 AND mx ≤ 319 THEN        //Was tab 6 pressed?
        
sum_xy:=x+y
        PRINT();             
//clear print terminal
        
PRINT("x = "+x);     
        PRINT(
"y = "+y);
        PRINT(
"z = "+z);
        PRINT(
"sum of x and y = "+sum_xy);
      
END;

    
END// nested IF statements

  
END  // WHILE loop

END//main program
     //When the program ends, the print terminal is displayed.
     //User must press Esc key to return to Home screen 
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)