![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello, i have to create a calculator with progress 9, but i have no idea how to add firm worth to the buttons and how to display the numbers and signs. |

#3
| |||
| |||
|
|
"Amberstar" <member39548 (AT) dbforums (DOT) com> wrote in message news:3370349.1063616481 (AT) dbforums (DOT) com... Hello, i have to create a calculator with progress 9, but i have no idea how to add firm worth to the buttons and how to display the numbers and signs. with v8 : press keys "2" "+" "2" "Berechne" "-" "5" "Berechne" my code must be optimized ![]() /********************** Define Widgets**********************/ define button eins label "1" size-chars 6 by 1 TRIGGERS: ON CHOOSE RUN calc-process ("1"). END. define button zwei label "2" size-chars 6 by 1 TRIGGERS: ON CHOOSE RUN calc-process ("2"). END. define button drei label "3" size-chars 6 by 1 TRIGGERS: ON CHOOSE RUN calc-process ("3"). END. define button vier label "4" size-chars 6 by 1 TRIGGERS: ON CHOOSE RUN calc-process ("4"). END. define button fuenf label "5" size-chars 6 by 1 TRIGGERS: ON CHOOSE RUN calc-process ("5"). END. define button sechs label "6" size-chars 6 by 1 TRIGGERS: ON CHOOSE RUN calc-process ("6"). END. define button sieben label "7" size-chars 6 by 1 TRIGGERS: ON CHOOSE RUN calc-process ("7"). END. define button acht label "8" size-chars 6 by 1 TRIGGERS: ON CHOOSE RUN calc-process ("8"). END. define button neun label "9" size-chars 6 by 1 TRIGGERS: ON CHOOSE RUN calc-process ("9"). END. define button nnull label "0" size-chars 6 by 1 TRIGGERS: ON CHOOSE RUN calc-process ("0"). END. define button plus label "+" size-chars 6 by 1 TRIGGERS: ON CHOOSE RUN calc-process ("+"). END. define button minus label "-" size-chars 6 by 1 TRIGGERS: ON CHOOSE RUN calc-process ("-"). END. define button mal label "*" size-chars 6 by 1 TRIGGERS: ON CHOOSE RUN calc-process ("*"). END. define button geteilt label "/" size-chars 6 by 1 TRIGGERS: ON CHOOSE RUN calc-process ("/"). END. define button komma label "," size-chars 6 by 1 TRIGGERS: ON CHOOSE RUN calc-process (","). END. define rectangle rtc-border size-chars 50 by 13 no-fill. define button btn-exit label "Exit". define variable a as decimal. define variable b as decimal. define variable field1 as character . define button rechne label "Berechne" TRIGGERS: ON CHOOSE RUN calc-process ("="). END. /*******************Define Frames********************************/ define frame frame1 rechne at row 13 column 32 eins at row 9 column 20 zwei at row 9 column 30 drei at row 9 column 40 vier at row 7 column 20 fuenf at row 7 column 30 sechs at row 7 column 40 sieben at row 5 column 20 acht at row 5 column 30 neun at row 5 column 40 nnull at row 11 column 20 plus at row 11 column 50 minus at row 9 column 50 mal at row 7 column 50 geteilt at row 5 column 50 komma at row 11 column 40 rtc-border at row 2 column 13 btn-exit at row 14 column 63 field1 at row 3 column 22 no-labels with three-d center side-label title "Taschenrechner". /************Main Logic***************************************/ DEF VAR t-operand AS DECIMAL. DEF VAR t-optype AS CHAR. display rtc-border with frame frame1. enable all with frame frame1. PROCEDURE calc-process: DEF INPUT PARAMETER t-command AS CHAR NO-UNDO. DO WITH FRAME frame1: CASE t-command: WHEN "1" OR WHEN "2" OR WHEN "3" OR WHEN "4" OR WHEN "5" OR WHEN "6" OR WHEN "7" OR WHEN "8" OR WHEN "9" OR WHEN "0" THEN DO: field1:SCREEN-VALUE = field1:SCREEN-VALUE + t-command. END. WHEN "+" THEN DO: ASSIGN t-optype = "+" t-operand = DECIMAL(field1:SCREEN-VALUE) field1:SCREEN-VALUE = "". END. WHEN "-" THEN DO: ASSIGN t-optype = "-" t-operand = DECIMAL(field1:SCREEN-VALUE) field1:SCREEN-VALUE = "". END. WHEN "=" THEN DO: CASE t-optype: WHEN "+" THEN DO: t-operand = t-operand + DECIMAL(field1:SCREEN-VALUE). END. WHEN "-" THEN DO: t-operand = t-operand - DECIMAL(field1:SCREEN-VALUE). END. END CASE. ASSIGN field1:SCREEN-VALUE = STRING(t-operand) . END. /* = */ END CASE. END. END PROCEDURE. wait-for choose of btn-exit. /dmi |
![]() |
| Thread Tools | |
| Display Modes | |
| |