fill-in fields basics

ownager

New Member
So hi everyone,

first of all i worked through the first chapter of the progress tutorial and wanted to test my skills so i wanted to create a simple calculator that adds und subtracts 2 integer.

Now i got some weird behaviour i can't explain myself. I will try not to post all my code hopefully it is sufficient to get help. First the definitions:

Code:
DEFINE VARIABLE firstArg AS INTEGER INITIAL 0.
DEFINE VARIABLE secondArg AS INTEGER INITIAL 0.
DEFINE VARIABLE addResult AS INTEGER INITIAL 0.
I don't think i need to post the Button defines since they are not the problem. Now the related frame

Code:
DEFINE FRAME frame1
    BackRect AT ROW 1 COLUMN 1
    firstArg AT ROW 3 COLUMN 2
    secondArg AT ROW 3 COLUMN 20
    addResult AT ROW 3 COLUMN 40
    firstTextArg AT ROW 2 COLUMN 2
    secondTextArg AT ROW 2 COlUMN 20
    resultText AT ROW 2 COLUMN 40
    WITH NO-BOX.
The display and enable stuff

Code:
DISPLAY firstArg NO-LABEL secondArg NO-LABEL addResult NO-LABEL 
firstTextArg NO-LABEL secondTextArg NO-LABEL resultText NO-LABEL WITH FRAME frame1.

ENABLE firstArg secondArg addResult WITH FRAME frame1.
I skipped the text defines since they are simply just labels. So my first issue: Is there any possibillity to make the reading of firstArg/secondArg and the writing of addResult easier than that?

Code:
ON CHOOSE OF cSUM
    DO:
        DO WITH FRAME frame1:         
            ASSIGN addResult:SCREEN-VALUE =    
            String(INTEGER(firstArg:SCREEN-VALUE) +
            INTEGER(secondArg:Screen-Value)).
            DISPLAY addResult:SCREEN-VALUE.
        END.
    END.
cSum is the Button for adding the two integers. The second problem, if i do as postet above the addResult:Screenvalue does not only appear in the fill-in Field , it also appears above the fill-in field. Third, as you see in the framedefinition above i use a rectangle with a 1 char edge. Bug the bound is not compelte, at the spot where the addResult-field is located there is a white cut. If i remove the trigger above the Border is continious with no flaws.
And fourth, i need to click the cSum button twice to get the results shown, is that a correct behaviour?
I hope i could made the problems clear since english isn't my native language.

greetings
 
Greetings,Simple math here.DEFINE VARS for the 2 values gathered by the widgedts (fillins).ASSIGN the SCREEN-VALUE of the widgets to the vars.Math function var1 - var2 = resulte.g.DEFINE VARIABLE iX AS INTEGER NO-UNDO.DEFINE VARIABLE iY AS INTEGER NO-UNDO.DEFINE VAIRABLE iR AS INTEGER NO-UNDO.DO WITH FRAME {&FRAME-NAME}: ASSIGN iX = widgetName:SCREEN-VALUE iY = widgetName:SCREEN-VALUE ./* calculation */iR - iX - iYResultWidgetName:SCREEN-VALUE = iR.END. /* frame */Hope you can pick up from here.
 
I thank you alot. The NO-UNDO statement makes the variables appear like "real" variables in other languages like c , am i right?

And now just one problem is left, when i press the add/subtract button in the first place nothing happens. Is that because the the focus is set first and nothing else is done?

greetings
 
Back
Top