Injecting data into VID?
[1/5] from: joel:neely:fedex at: 27-Apr-2001 8:38
(Sorry about the cryptic subject... Best I could do in a hurry!)
Consider the following dinky bit of code:
8<--------------------
test1: make object! [
firstNames: ["John" "Jane" "Bob"]
lastNames: ["Smith" "Doe" "Doaks"]
ui: layout [
across
vh2 "Names:"
return
firstName: choice "John" "Jane" "Bob" [sayName]
lastName: choice "Smith" "Doe" "Doaks" [sayName]
return
fullName: text " " 200
return
button "Close" [unview]
]
sayName: function [] [theName] [
fullName/text: theName: join firstName/text [" "
lastName/text]
print mold theName
show fullName
]
run: function [][][
sayName
view center-face ui
]
]
test1/run
8<--------------------
The drawback of listing the first and last name choices as literal
strings in the definition of 'ui is that other parts of the code
might need to work with the same lists. However, saying
8<--------------------
; ...
firstName: choice firstNames [sayName]
lastName: choice lastNames [sayName]
; ...
8<--------------------
doesn't work. Is there a way to accomplish the goal of setting up
a data structure (e.g. firstNames) and using some operation on
that structure to initialize a 'choice list?
-jn-
[2/5] from: joel:neely:fedex at: 27-Apr-2001 9:03
One bit of clarification (mea culpa...)
Joel Neely wrote:
...
> 8<--------------------
> test1: make object! [
<<quoted lines omitted: 25>>
> test1/run
> 8<--------------------
If I use
8<--------------------
; ...
firstName: choice texts firstNames [sayName]
lastName: choice texts lastNames [sayName]
; ...
8<--------------------
then the choice buttons get populated from the blocks, but
when the window first appears, the choice buttons are
unlabeled and the full name text is
none none
This implies to me that using 'texts is somehow different
from supplying the literal sequence of strings in-line. (Is
this a "bug" or a "feature"? ;-)
I'd be content, however, if I knew what code to place before
sayName
view center-face ui
to force each choice to set itself to the first alternative.
-jn-
[3/5] from: joel:neely:fedex at: 27-Apr-2001 9:21
("Hate to keep replying to my own questions!" he grumbled to
himself...)
I suppose another approach is to build the user interface spec
explicitly, prior to invoking 'layout
8<--------------------
test1: make object! [
firstNames: ["John" "Jane" "Bob"]
lastNames: ["Smith" "Doe" "Doaks"]
uiSpec: [
across
vh2 "Names:"
return
firstName: choice _FIRSTNAMES [sayName]
lastName: choice _LASTNAMES [sayName]
return
fullName: info " " 200
return
button "Close" [unview]
]
replace/case uiSpec '_FIRSTNAMES firstNames
replace/case uiSpec '_LASTNAMES lastNames
ui: layout uiSpec
sayName: function [] [theName] [
fullName/text: theName: join firstName/text [" "
lastName/text]
print mold theName
show fullName
]
run: function [][][
sayName
view center-face ui
]
]
test1/run
8<--------------------
Any suggestions for a tidier approach?
-jn-
[4/5] from: allenk::powerup::com::au at: 28-Apr-2001 1:19
Hi Joel,
>From what I understand of your question, I think this is what you are after.
With choice you have a choice :-) Choice "string" "string" "string" or or
provide a data block by using..
Choice data block!.
Cheers,
Allen K
test1: make object! [
firstNames: ["John" "Jane" "Bob"]
lastNames: ["Smith" "Doe" "Doaks"]
ui: layout [
across
vh2 "Names:"
return
firstName: choice data firstNames [sayName]
lastName: choice data lastNames [sayName]
return
fullName: text " " 200
return
button "Close" [unview]
]
sayName: function [] [theName] [
fullName/text: theName: join firstName/text [" "
lastName/text]
print mold theName
show fullName
]
run: function [][][
sayName
view center-face ui
]
]
test1/run
[5/5] from: joel:neely:fedex at: 27-Apr-2001 11:52
Thanks, Allen!
Allen Kamp wrote:
> Hi Joel,
>
> From what I understand of your question, I think this is what you are after.
>
> With choice you have a choice :-) Choice "string" "string" "string" or or
> provide a data block by using..
> Choice data block!.
>
That's what I was looking for.
-jn-
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted