Post Reply 
Help asked: systemRPL ^IFMain question
02-04-2016, 11:38 PM
Post: #6
RE: Help asked: systemRPL ^IFMain question
(02-04-2016 09:16 PM)brrm Wrote:  When I worked on it I ran into another problem.

When I use your code, it works as desired, but ONLY if I enter the decimal separator to force a real (i.e. type '7.' followed by <SUM>) it gives the correct answer.

If I omit the separator (i.e. type '7' followed by <SUM>) then the result is garbage.

I was able to fix this with CK&DISPATCH1.

CK&DISPATCH1 will do the conversion (as will CKREAL), but it also sets some other things that aren't desirable at the point in your code (protection word comes to mind). When I mentioned before that there was no error checking, this is part of what I was alluding to. Storing the value in the field in this manner bypasses the normal validation that IfMain does to make sure that the object is an acceptable type.

It may be a better approach to use the IfCheckFieldtype function that is part of the InputForm API. While I haven't tried all possible combinations of objects and field types, it did at least appear to convert a ZINT to a REAL automatically in this situation. It also returns a boolean that allows you to branch accordingly if the type wasn't acceptable.

When I was playing around with this earlier today, it seems that there's some fragility with this method of obtaining the data directly from the command line. I'm not sure, but I suspect that this comes from having several stacked "environments" active simultaneously. I tried the following code for the form's message handler and found that it was reasonably effective:
Code:
' ::
    BINT12 OVER#=case :: ( Configures menu softkeys )
        DROP
        { { "SUM" ::
            TakeOver
            EditLExists? IT ::
                EDITLINE$ InitEdLine
                DOSTR>
                FLASHPTR IfCheckFieldtype
                ITE
                ::
                    FLASHPTR IfSetCurrentFieldValue
                ;
                ::
                    # 202 JstGETTHEMSG FlashWarning
                    DO>STR
                    InitEdLine
                    CMD_PLUS
                    CMD_END_LINE
                ;
            ;
            Field1 FLASHPTR IfGetFieldValue
            Field2 FLASHPTR IfGetFieldValue
            Field3 FLASHPTR IfGetFieldValue
            %+ %+
            Field4 FLASHPTR IfSetFieldValue
            ; }
          { "CANCL" ::
              TakeOver
            FLASHPTR IfONKeyPress
            ; }
          { "OK" ::
              TakeOver
              FLASHPTR IfEnterKeyPress
              ; } }
        TRUE
    ;
    DROPFALSE
;

One of the potential problems that can occur is if the command line contains a string which will compile into multiple objects (ie. "123A" becomes % 123 and 'A' ). Things get a bit messier for that kind of scenario. Whatever you end up with, you'll want to run through a variety of scenarios to make sure it works the way you want.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Help asked: systemRPL ^IFMain question - DavidM - 02-04-2016 11:38 PM



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