[REBOL] Re: Rebol View, function behaving differently when called diectly or from other funtion
From: anton:wilddsl:au at: 26-Aug-2006 13:54
Hi Yvan,
The quick solution is to put UNVIEW just before
Formular: view layout ...
eg:
Videoform: func ["Creates Input form for new video record"][
unview
Formular: view layout [
...
Another solution uses a modal window using INFORM (probably better
solution):
Videoform: func ["Creates Input form for new video record"][
inform Formular: center-face layout [
text "Title" FTitel: field
text "Producer" FProduzent: field
button #"^M""OK" [
OK: TRUE
;Title has to be entered
if (empty? FTitel/text) [
OK: FALSE
FTitel/edge: make FTitel/edge [color: red]
focus FTitel
]
if OK [
Formfilled: true
hide-popup Formular ; <----
]
]
]
Formular ; return value
]
INFORM windows should be closed properly using HIDE-POPUP.
----
Some extra notes, maybe not relevant in your final code:
- Note: in the following line, [block!] does not force video-record to be a
block:
/local video-record [block!]
Just making sure you understand it's only useful as a comment.
Only arguments to a function are type-checked.
- The following comment in videoform makes me wonder if you realise that
there *is* a return value:
; Missing return code (?)
The returned value is the value evaluated last in the function. In the
case
of videoform, it is the window face returned by:
Formular: view layout ...
- So it seems you are expecting video-record to be a block, but in
create-new-video
you do this:
video-record: Videoform
which sets video-record to the returned window face object, which is
perhaps
not what you want. (I understand that's maybe not the final code, though.)
- Debugging tips:
- Use PROBE. You can usually insert it anywhere without side-effects, eg:
if (empty? probe FTitel/text) [ ...
- Use ?? which prints nicely molded output, eg:
?? Formfilled
prints:
Formfilled: true
Regards,
Anton.