Proper way to split a string?

Liste des GroupesRevenir à cl tcl 
Sujet : Proper way to split a string?
De : luc (at) *nospam* sep.invalid (Luc)
Groupes : comp.lang.tcl
Date : 17. Dec 2024, 05:37:49
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20241217013749.5e0897be@lud1.home>
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?

--
Luc
>


Date Sujet#  Auteur
17 Dec 24 * Proper way to split a string?5Luc
17 Dec 24 +- Re: Proper way to split a string?1Rich
21 Dec 24 +- Re: Proper way to split a string?1Emiliano
21 Dec 24 `* Re: Proper way to split a string?2Luc
21 Dec 24  `- Re: Proper way to split a string?1Rich

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal