Document the trick for setting globals from widgets
Closed this issue · 3 comments
nicolaspayette commented
to setup-globals-from-widgets
xw:ask xw:widgets xw:with [ not member? xw:kind ["TAB" "NOTE"] ] [
run (word "set " xw:key " " maybe-quote xw:get xw:key)
]
end
to-report maybe-quote [ value ]
report ifelse-value is-string? value
[ (word "\"" value "\"") ]
[ value ]
end
nicolaspayette commented
@jbadham, maybe you'll want to use the maybe-quote
reporter in your code.
nicolaspayette commented
Handling lists:
xw:ask xw:widgets with [ xw:kind != "NOTE" ]
[ run (word "set " xw:key " " format xw:get xw:key)
]
to-report format [ value ]
report ifelse-value is-string? value
[ (word "\"" value "\"") ]
[ ifelse-value is-list? value
[ reduce word (sentence "[" (map format value) "]") ]
[ value ]
]
end
nicolaspayette commented