Home   Archive   Permalink



variable scope?

Hi, I have just about got my type testing and error collecting and focusing program working. It puts errors in a table and focuses on the first error in the table . The problem I am having is that when I do an error in the table and then clear the errors by entering valid data in all of the fields , the table retains the last error. Why is that? Here is the code:
R E B O L []
fldblk:[vi to-integer vdc to-decimal vdt to-date vtm to-time vmn to-money]
errblk: array [5 2]
errchk: func [fldblk errblk ][
    i: 0
    foreach [fld tp] fldblk [
        print errblk
        print i
        f: get fld
        ;print rejoin [tp " " f/text]
        if error? try [do rejoin [tp " " f/text]] [i: i + 1 errblk/:i/1: fld errblk/:i/2: "Failed to convert"]
    ]
]
view gui: layout[
    vi: field
    vdc: field
    vdt: field
    vtm: field
    vmn: field
    
    button "val" [
        errblk copy []
        errchk fldblk errblk
        either errblk/1/1 == none [
            alert "Good Entry"
        ][
            alert reform ["Errors " errblk/1/2]
            print to-string errblk/1/1
            focus get errblk/1/1
            print errblk
            return
        ]
    ]
]


posted by:   John     23-Apr-2014/16:08:51-7:00



Oops , problem solved. I wasn't acually initalizing the errblk with copy[] because it wasnt' errblk: and copy[] isn't enough. Need to make it errblk: array [5 2] copy []
    
R E B O L []
fldblk:[vi to-integer vdc to-decimal vdt to-date vtm to-time vmn to-money]
    
errchk: func [fldblk errblk ][
    i: 0
    foreach [fld tp] fldblk [
        ;print errblk
        ;print i
        f: get fld
        ;print rejoin [tp " " f/text]
        if error? try [do rejoin [tp " " f/text]] [i: i + 1 errblk/:i/1: fld errblk/:i/2: "Failed to convert"]
    ]
]
view gui: layout[
    vi: field
    vdc: field
    vdt: field
    vtm: field
    vmn: field
    
    button "val" [
        errblk: array [5 2] copy []
        errchk fldblk errblk
        either errblk/1/1 == none [
            alert "Good Entry"
        ][
            alert reform ["Errors " errblk/1/2]
            print to-string errblk/1/1
            focus get errblk/1/1
            print errblk
            return
        ]
    ]
]

posted by:   John     23-Apr-2014/17:12:16-7:00