'inform' inside a function
For a little project, and also for my education, I want to make a function to which I can pass a block of stuff and have it pop up a window with a text-list of that stuff, and then return what is picked from the text-list. An abbreviated sample is shown below. It does not seem to return what is picked (or "none" if nothing is picked), but instead returns some REBOL source code. I include a test function, GET-EMAIL-X, to show that my calling methodology is correct, so the problem must be in my use of the "inform" function inside of a function. I wonder if this can be done, or if I am doing something wrong.
R E B O L 
;; This is what I want to do but it does not return the right result.
GET-EMAIL: func [
inform ADDR-LIST: layout [
ADDRS: text-list 300x400 data EMAIL-LIST [
PARSED-EMAIL: first ADDRS/picked ":"
button "Close" [
;; This shows the test code is correct because it does return a result.
GET-EMAIL-X: func [
return first EMAIL-LIST
;; return none
;;Uncomment to test
;RESULT: GET-EMAIL-X [ ;; This does what is expected.
RESULT: GET-EMAIL [ ;; RESULT will have some sort of source code.
print "probe RESULT to see what happens."
posted by: Steven White 23-Oct-2018/16:58:01-7:00
'request-list does that:
request-list "Pick an email" ["email@example.com" "firstname.lastname@example.org"]
If you 'source request-list', you can see how the return values are managed and customize the function as needed:
request-list: func [
"Requests a selection from a list."
alist [block!] /offset xy /local rslt list-lay
list-lay: layout [
text-list data alist [rslt: value hide-popup]
btn-cancel #"^[" [rslt: none hide-popup]
either offset [inform/offset list-lay xy] [inform list-lay]
I don't want to harp on it, but I think it's important to point out that all this can be gotten without any third party documentation.
posted by: Nick 24-Oct-2018/11:07:23-7:00
Well, then, there is a head-slapping moment. Regarding that concept of third-party documentation, some time ago, frustrated by the lack of documentation for VID, I wrote my own third-party documentation. Not that VID was undocumented, but the documentation that I could find was not organized to my liking for a reference manual.
So after reading your above note, I went to MY OWN documentation, and THERE IS WAS, a section on request-list.
What more can a guy do...
posted by: Steven White 24-Oct-2018/14:51:12-7:00