Home   Archive   Permalink



changed program and it won't work

Hi
I have changed this program and now it won't work. I have been absent from rebol for a while and I'm sure someone will spot my error.
    
When I make an error entry (say I enter an alpha in a decimal field) the error isn't getting recorded in errfld and errmsg. This was working when errfld and errmsg were an array with positions 1/1 and 1/2. Now it doesn't work. I'm hoping someone with experience can spot this quickly and tell me what is going on here.
    
Thx.

posted by:   john       8-Oct-2014/10:17:39-7:00



R E B O L []
fldblk: [vi to-integer vdc to-decimal vdt to-date vtm to-time vmn to-money]
    
errchk: func [fldblk errfld errmsg ][
    foreach [fld tp] fldblk [
        ;print errblk
        ;print i
        f: get fld
        ;print rejoin [tp " " f/text]
        if error? try [do rejoin [tp " " f/text]] [ errfld: fld errmsg: "Invalid entry" ]
    ]
]
view gui: layout[
    vi: field
    vdc: field
    vdt: field
    vtm: field
    vmn: field
    
    button "val" [
        errfld: ""
        errmsg: ""
        errchk fldblk errfld errmsg
        either errfld == "" [
            alert "Good Entry"
        ][
            alert reform ["Errors " errmsg]
            ;print to-string errfld
            focus get errfld
            print errmsg
            return
        ]
    ]
]


posted by:   john       8-Oct-2014/10:19:04-7:00



Hi John,
    
Try this:
    
R E B O L []
fldblk: [vi to-integer vdc to-decimal vdt to-date vtm to-time vmn to-money]
        
errchk: func [fldblk][
     errfld: ""
     errmsg: ""
     foreach [fld tp] fldblk [
         f: get fld
         if error? try [do rejoin [tp " " f/text]] [errfld: form fld errmsg: "Invalid entry" ]
     ]
     reduce [errfld errmsg]
]
view gui: layout[
     vi: field
     vdc: field
     vdt: field
     vtm: field
     vmn: field
     button "val" [
         errs: errchk fldblk
         either errs/2 = "" [
             alert "Good Entry"
         ][
             alert reform ["Errors " errs/1]
             focus do errs/1
             print errs/2
             return
         ]
     ]
]

posted by:   Nick       8-Oct-2014/23:11:22-7:00



Hi Nick,
    
Once again you have come to the rescue. Thx pal.
    


posted by:   John       9-Oct-2014/11:06:27-7:00



The money (vmn) field accepts very long numbers. But, if one were to later use to-money on an entry greater than 15 digits, a math error will occur. So this error would not be captured.
    
Using a number greater in length than 9 digits in vi, the integer field, produces an an error alert. Sometimes. Except when 10 digits are used as the first entry to the field. If later applying to-integer to an entry longer than 9 digits a math error results. This error is captured - sometimes.
    
The integer field error alert seems almost right, but shouldn't the money field generate an error when the length of the entry exceeds 15 in a way similar to integer field entry?
    
Then again, why is vi and the to-integer function is limited to a length of 9 (or 10) and to-money limited to 15?
    
Apologies in advance if I got this wrong. I found it confusing.

posted by:   Sam       9-Oct-2014/21:41:24-7:00