Advertisement
idsystems

CPP2_Practica04_IfElse

Aug 5th, 2015
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.74 KB | None | 0 0
  1. /* Prac04
  2. Basado en el Ejercicio 11 de CuadernoPracticas
  3. para practicar la sentencia IF...ELSE */
  4. #include <radc++.h>
  5.  
  6. //Declarar las variables globlales
  7. int i = 1; int j = 2;
  8.  
  9. //create new form
  10. Form frmForma("Condicional IF..ELSE", 5,5,250,200);
  11.  
  12. //create new text box
  13. Label lbli("Introduce valor de i:", AUTO_ID, 10,15, 100, 25, frmForma);
  14. NumberBox txtVali("2", AUTO_ID, 120, 15, 50, 25, frmForma);
  15. Label lblj("Introduce valor de j:", AUTO_ID, 10,45, 100, 25, frmForma);
  16. NumberBox txtValj("3", AUTO_ID, 120, 45, 50, 25, frmForma);
  17. ReadOnlyBox txtResult("Resultado:", AUTO_ID, 10, 75, 200, 25, frmForma);
  18.  
  19. Button cmdDecide("Identifica", AUTO_ID, 10,110, 50, 25, frmForma);
  20.  
  21. //create new control procedure for form, procedure1 is procedure name
  22. FormProcedure procedure1 (FormProcArgs) {
  23.  
  24.         //capture event ON_CLOSE which is fired when form is closed, [X] is clicked
  25.         ON_CLOSE() {
  26.             //exit application
  27.             Application.close();
  28.         }
  29.         ON_COMMAND_BY(cmdDecide) {
  30.            i = val( txtVali.text);
  31.            j = val( txtValj.text);                      
  32.            if (i>j)
  33.               //frmForma.caption = "i es mayor que j";
  34.               txtResult.text = "Resultado: i es mayor que j";
  35.             else
  36.                 txtResult.text = "Resultado: i es menor que j";
  37.         }
  38.         //capture text change event, means text hs been changed
  39.         //ON_TEXT_CHANGED ( text1 ) {
  40.         //  frmForma.caption = "Changed : " + text1.text;
  41.         //}
  42.      
  43.         //always return 0
  44.         return 0;      
  45. }
  46.  
  47. //rad c++ main program
  48. rad_main()
  49.            txtVali.text = str(i);
  50.            txtValj.text = str(j);
  51.         //attach the created procedure with form
  52.         frmForma.procedure = procedure1;
  53.        
  54.         //set focus to textbox when program starts
  55.         txtVali.focus();
  56.  
  57. rad_end()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement