|
Pages: [1]
|
 |
|
Author
|
Topic: how to convert the value to integer? (Read 271 times)
|
cheryl
Guest
|
REBOl[]
list-names: func[] [db-select * person] ;names: [[1 "martin"] [2 "stella"] [3 "joe"]] form-style: stylize[ new: txt with [size: 150x50 font: [align: 'right]] inp: field with [size: 240x24]
]
do %db.r add: layout [ styles form-style backdrop effect [gradient 1x1 0.0.0 0.0.180] new "Please enter a new ID" Red id: inp 165x24 new "Please enter a new name" Red na: inp 165x24 button black "test" [save-data] ;button black "Add" [db compose/deep[insert into person values [ 20 (na/text) ]]] ;button black "Cancel" [quit] ] save-data: does[ data: reduce [id/text] change: to-integer data print change ]
view layout [
button "new info" [inform add] ;button "delete" ]
I not sure whether the code was correct as I having the error and not sure how to convert the value to integer.. Thank you
|
|
|
|
|
Logged
|
|
|
|
|
CarlRead
|
TO-INTEGER is the right word to use. Your problem lies in the use of REDUCE. REDUCE returns a block so if id/text is "123", DATA will reference ["123"] and not "123". Two solutions, depending on what you expect id/text to contain: data: copy id/text ; The COPY may not be needed
data: first reduce [id/text]
Note also you've used ADD and CHANGE as global words. REBOL already uses these and so you may eventually hit a conflict. ie, require the REBOL versions later as your script developes. It's perfectly OK to redefine REBOL's default words, but is obviously best only when you really want to. If you want to prevent this happening accidently, add PROTECT-SYSTEM to your %user.r script and you'll get an error if a script attempts to redefine a system function.
|
|
|
|
|
Logged
|
- Carl Read
|
|
|
|
|
Pages: [1]
|
|
|
 |