Editing fields of a record in forms?
[1/2] from: yvan_iigs::gmx::net at: 22-Aug-2007 10:02
Hallo,
Hello,
Why is the code below not working?
What it should do is the following:
1. I have a block a with a string in it
2. Edit-ActorRole should open a form with the value of the string in block a
and let the user edit it if he wants.
3. The edited string should be returned to block b, letting block a
untouched
for example:
a: ["dada"]
b: Edit-ActorRole a
but the value of b is not changed and the script crashes.
REBOL []
Edit-ActorRole: func [ actor-block [block!]
/local l-act-role-block
l-actor-block ]
[
l-act-role-block: copy [] ;make sure it is empty, will
contain the return value
l-actor-block: copy actor-block ;copy content of actor-block to
l-actor-block so that actor-block keeps untouched
;Check if l-actor-block is empy, if yes feed with zero String ""
if (l-actor-block/1 = none) [append l-actor-block ""]
Formular: view/new layout
[
text "Actor 1:" Fact1: field l-actor-block/1
button #"^M""OK"
[
;as soon as OK is clicked l-actor-block is cleared and then refilled with
the values from the Fields
l-actor-block: copy []
if not (Fact1/text = "") [append l-actor-block Fact1/text]
append/only l-act-role-block l-actor-block
]
]
return l-act-role-block
]
Mit freundlichen Gr=FCssen
[2/2] from: anton::wilddsl::net::au at: 23-Aug-2007 1:19
Hi,
VIEW/NEW does not WAIT.
Read source of VIEW and DO-EVENTS to see this.
?? view
?? do-events
You could WAIT after opening your window, eg:
view/new layout [...]
DO-EVENTS ; <---
return l-act-role-block,
OR you could pop a requester, like REQUEST does.
?? request
See modified code below.
Regards,
Anton.
Edit-ActorRole: func [
actor-block [block!]
/local
l-act-role-block
l-actor-block
rtn
result
][
rtn: func [value][result: value hide-popup]
; make sure it is empty, will contain the return value
l-act-role-block: copy []
; copy content of actor-block to l-actor-block so that
; actor-block keeps untouched
l-actor-block: copy actor-block
; Check if l-actor-block is empy, if yes feed with zero String ""
if (l-actor-block/1 = none) [
append l-actor-block ""
]
;Formular: view/new layout [
inform layout [
text "Actor 1:" Fact1: field l-actor-block/1
button #"^M" "OK" [
;as soon as OK is clicked l-actor-block is cleared and
;then refilled with the values from the Fields
l-actor-block: copy [] ; <- this creates a new empty block
if not (Fact1/text = "") [
append l-actor-block Fact1/text
]
append/only l-act-role-block l-actor-block
rtn l-act-role-block
]
]
;return l-act-role-block
return result
]
a: ["dada"]
b: Edit-ActorRole a
;----------------------------------------