Post Reply 
User defined touch-button menu (Softkeys)
06-30-2019, 09:06 AM
Post: #19
RE: User defined touch-button menu (Softkeys)
@Gene222

Hi,

I tried your code once more.


PHP Code:
EXPORT i_SB()
BEGIN
LOCAL a
,b,z,answeri_Wert;
LOCAL event,loop_1,loop_2,loop_3,loop_3_count;
//initialize continuous loop counter variables
loop_1:=1;
loop_2:=1;
loop_3:=1;
WHILE 
loop_1==DO
  
a:=0;  //clear variables
  
b:=0;
  
z:=0;
  WHILE 
loop_2==DO
    
INPUT({a,b,z});
    
i_Wert:=(1/(2*π))*(ATAN((a*b)/(z*(a^2+b^2+z^2)))+(a*b*z)/((a^2+b^2+z^2))*(1/(a^2+z^2)+1/(b^2+z^2)));
    
answer:=i_Wert;
    
loop_3_count:=0;   //initialize loop 3 cycle counter
    
WHILE loop_3==DO //loop 3
      
loop_3_count:=loop_3_count+1;
      
//if there are no tap or key events after 3 WAIT(-1) cycles (3 minutes), exit program
      
IF loop_3_count==4 THEN
        
//exit program
        
BREAK(3);  //exit loops 3, 2, and 1
      
END;
      
//draw G0 screen
      
RECT();
      
TEXTOUT_P("i-Wert nach Steinbrenner",10,15);
      
TEXTOUT_P("a = "+a,10,45);
      
TEXTOUT_P("b = "+b,10,60);
      
TEXTOUT_P("z = "+z,10,75);
      
TEXTOUT_P("i-Wert = "+i_Wert,10,105);
      
//TEXTOUT_P("Loop 3 WAIT(-1) counter = "+loop_3_count,10,135);
      
DRAWMENU("""""""exit""clear""↩");
      
//pause up to 60 seconds to get a screen tap or key press and store the tap or key data into "event"
      
event:=WAIT(-1);  
      
//key press handling procedues
      
IF TYPE(event)==0 THEN     //Is the variable "event" a real number?
        
IF event==4 THEN         //Was the "Esc" key pressed?
          //exit the program by going to end of loop 1
          
BREAK(3);              //exit loop 3, loop 2, loop 1
        
END;
      
END;
      
//mouse tap handling procedures
      
IF TYPE(event)==6 THEN     //Is the variable "event" a list.
        
IF event(1)==3 THEN      //Is the MOUSE event type a mouse click (i.e. screen tap)?
          
IF event(3) > 219 THEN //Was the y coordinate tap within the row of user tabs?
            
IF event(2≥ 0 AND event(2≤ 51 THEN     //tab 1  Is the x coordinate within tab 1?
              //no action                            
            
END;
            IF 
event(2≥ 53 AND event(2≤ 104 THEN   //tab 2
              //no action
            
END;
            IF 
event(2≥ 106 AND event(2≤ 157 THEN  //tab 3
              //no action          
            
END;
            IF 
event(2≥ 159 AND event(2≤ 210 THEN  //tab 4 "exit"
              //go to end of loop 1
              
BREAK(3);          //exit loops 3, 2, and 1
            
END;
            IF 
event(2≥ 212 AND event(2≤ 263 THEN  //tab 5 "clear"
              //go to end of loop 2, and then goes to the beginning of loop 1
              
BREAK(2);          //exit loops 3, and 2
            
END;
            IF 
event(2≥ 265 AND event(2≤ 319 THEN  //tab 6 "↩"
              //go to end of loop 3, and then goes to the beginning of loop 2
              
BREAK(1);          //exit loop 3
            
END;
          
END;
        
END;
      
END//if TYPE(event)==6
    
END//loop 3
  
END//loop 2
END//loop 1
RETURN answer;  //returns the answer to the home screen
END//main program 

Modified it a tiny bit. Just two questions:

1. The program returns only the last result to the stack when you exit it. I want to calculate several times and use each result for further calculations in RPN. Is there a way that all the previous results are returned to the stack for further use in RPN?
2. While the code works fine on the virtual calculator, I got problems on the real one. The following actions will result in a shutdown of the calculator ("Your calculator has a problem and will be rebooted in 3 seconds"):
a. hitting <enter> several times after a calculation
b. pressing exit after a calculation

Do you have any suggestions?

Thanks
Arch
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: User defined touch-button menu (Softkeys) - Arch - 06-30-2019 09:06 AM



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