Home   Archive   Permalink



Help with error

This is the error I'm getting:
    
** Script Error: Cannot use path on none! value
** Where: btn-save
** Near: db/:counter/5: FN/text
    
Here is the code:
    
do %/opt/rebol/sqlite.r
if not exists? %customer.db [ connect/create %customer.db ]
connect/direct %customer.db
db: SQL "select * from customer"
disconnect
counter: 1
window: layout [
    
h2 "Account Information"
    
    text "Please enter your account details here."
    
    across
    label "First Name: " FN: field db/:counter/5
    label "Last Name: " LN: field db/:counter/7
    return
         label "Spouse: " SN: field db/:counter/8
    return
    Label "Address: " ADDR: field db/:counter/1
    return
    label "City: " CITY: field db/:counter/2
    label "State: " STATE: field 40 db/:counter/10
    label "Zip: " ZIP: field 100 db/:counter/11
    return
    return
    label "Home Phone: " HPHONE: field 100 db/:counter/6
    label "Cell Phone: " CPHONE: field 100 db/:counter/3
    return
    label "Spouse Phone: " SPHONE: field 100 db/:counter/9
    return    
     label "Email" tab Em: field db/:counter/4
     return
     button "Add" [btn-add]
     button "Save" [btn-save]
     button "Next" [btn-next]
     return
     button "Delete" [btn-delete]
     button "Close" [btn-close]
     button "Previous" [btn-previous]
]
    
btn-save: func[][
    db/:counter/5: FN/text
    db/:counter/7: LN/text
    db/:counter/8: SN/text
    db/:counter/1: ADDR/text
    db/:counter/2: CITY/text
    db/:counter/10: STATE/text
    db/:counter/11: ZIP/text
    db/:counter/6: HPHONE/text
    db/:counter/3: CPHONE/text
    db/:counter/9: SPHONE/text
    db/:counter/4: Em/text
    SQL reduce ["insert into customer values (?,?,?,?,?,?,?,?,?,?,?)" FN/text LN/text SN/text
            ADDR/text CITY/text STATE/text ZIP/text HPHONE/text CPHONE/text SPHONE/text Em/text]
    ]
    
btn-next: func[][
     if (counter < (length? db)) [
    counter: counter + 1
    FN/text: db/:counter/5
    LN/text: db/:counter/7
    SN/text: db/:counter/8
    ADDR/text: db/:counter/1
    CITY/text: db/:counter/2
    STATE/text: db/:counter/10
    ZIP/text: db/:counter/11
    HPHONE/text: db/:counter/6
    CPHONE/text: db/:counter/3
    SPHONE/text: db/:counter/9
    Em/text: db/:counter/4
    show window
    ]
    ]
    
btn-previous: func[][
     if (counter > 1) [
    counter: counter - 1
    FN/text: db/:counter/5
    LN/text: db/:counter/7
    SN/text: db/:counter/8
    ADDR/text: db/:counter/1
    CITY/text: db/:counter/2
    STATE/text: db/:counter/10
    ZIP/text: db/:counter/11
    HPHONE/text: db/:counter/6
    CPHONE/text: db/:counter/3
    SPHONE/text: db/:counter/9
    Em/text: db/:counter/4
    show window
    ]
]
    
btn-add: func[][
    FN/text: ""
    LN/text: ""
    SN/text: ""
    ADDR/text: ""
    CITY/text: ""
    STATE/text: ""
    ZIP/text: ""
    HPHONE/text: ""
    CPHONE/text: ""
    SPHONE/text: ""
    Em/text: ""
    show window
    counter: (length? db) + 1
    ;append db to-block remold [FN/text LN/text Em/text]
    ]
    
btn-delete: func[][
     remove db counter
     Switch counter
     [
         1 [
             counter: counter - 1
                 FN/text: ""
                 LN/text: ""
        SN/text: ""
        ADDR/text: ""
        CITY/text: ""
        STATE/text: ""
        ZIP/text: ""
        HPHONE/text: ""
        CPHONE/text: ""
        SPHONE/text: ""
             Em/text: ""
         ]
     ] /default [
        counter: counter - 1
    FN/text: db/:counter/5
    LN/text: db/:counter/7
    SN/text: db/:counter/8
    ADDR/text: db/:counter/1
    CITY/text: db/:counter/2
    STATE/text: db/:counter/10
    ZIP/text: db/:counter/11
    HPHONE/text: db/:counter/6
    CPHONE/text: db/:counter/3
    SPHONE/text: db/:counter/9
    Em/text: db/:counter/4
     ]
     show window
]
    
btn-close: func[][
    Unview
]

posted by:   jrichards       9-Dec-2010/6:54:29-8:00



Somehow your db/:counter has a value none.
This can happen if your counter value changed (by prev/next or delete buttons may be) and if there is no record with that counter value.
    
try to probe its value.
and also I suggest you to copy all the empty strings "" in your functions.
     f: func [] [FN/text: copy ""]
or use clear function instead.
     f: func [] [clear FN/text]
    
otherwise you will have problems.

posted by:   Endo       10-Dec-2010/8:47:07-8:00