As unlikely as that is, I ask of you: what is the wise, serious, professional way of handling that situation and making sure that
worse things won't happen at sea?
OK, how about this:
bind $::SRw <Return> {set ::PINPUT "$pname::::::::::::::::$pfile"}
Howdy. I have this pop-up dialog that prompts for two pieces of
information: a name (arbitrary string) and a button that will
invoke a file browser so the user can select a file. Then:
bind $::SRw <Return> {set ::PINPUT "$pname|$pfile"}
then:
vwait ::PINPUT
catch {destroy $::SRw}
return $::PINPUT
It works.
But then I use the ::PINPUT variable, splitting it on the pipe |
symbol to identify the two pieces of information. And then I think,
what if the user uses the pipe symbol in $name?
OK, how about this:
bind $::SRw <Return> {set ::PINPUT "$pname::::::::::::::::$pfile"}
And then I think, what if the user's cat walks on the keyboard and
the user actually enters that kind of string?
OK, how about this:
bind $::SRw <Return> {set ::PINPUT "$pname|=MagicSeparator=|$pfile"}
And then I think, what if the user is possessed by Satan and actually
uses that Magic Separator in $name?
As unlikely as that is, I ask of you: what is the wise, serious,
professional way of handling that situation and making sure that
worse things won't happen at sea?
]
Rich suggested making it a list. You can do that or make ::PINPUT an array:
set ::PINPUT(state) waiting
bind $::SRw <Return> {
set ::PINPUT(pname) $pname
set ::PINPUT(pname) $pfile
set ::PINPUT(state) done
}
then:
vwait ::PINPUT(state)
catch {destroy $::SRw}
return [array get ::PINPUT]
Where you go to use it, do:
array set resultArray $returnValue
Or use the dict command to access the pieces.
On Fri, 20 Dec 2024 23:13:44 -0600, Gerald Lester wrote:
Rich suggested making it a list. You can do that or make ::PINPUT an array: >>**************************
set ::PINPUT(state) waiting
bind $::SRw <Return> {
set ::PINPUT(pname) $pname
set ::PINPUT(pname) $pfile
set ::PINPUT(state) done
}
then:
vwait ::PINPUT(state)
catch {destroy $::SRw}
return [array get ::PINPUT]
Where you go to use it, do:
array set resultArray $returnValue
Or use the dict command to access the pieces.
It's good to know that I was even wronger than I thought.
I have been using a list as Rich suggested, but the use of an array
is very interesting, rather Tcl-ish.
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 1,007 |
Nodes: | 10 (0 / 10) |
Uptime: | 60:51:54 |
Calls: | 13,152 |
Calls today: | 2 |
Files: | 186,574 |
D/L today: |
1,799 files (806M bytes) |
Messages: | 3,312,978 |