Re: How to "interpolate a string"

From: Bryan Oakley (oakley_at_bardo.clearlight.com)
Date: 10/05/04


Date: Tue, 05 Oct 2004 17:31:03 GMT

Sektor van Skijlen wrote:
> Sorry, maybe it's simple, but nothing comes to my mind :)
>
> Say, we have something like that
>
> set one 1
> set two 2
> set three 3
>
> set x {$one $two $three}
>
> and x contains $one $two $three
>
> how to make "1 2 3" using only the current value of x, in other words,
> to force appropriate substitutions on this expression?
>
>

The correct technique depends on whether you intend to create a list or
a string. To create a proper list no matter what the contents of one,
two and three, do:

     set x [list $one $two $three]

To create a string you can do this:

     set x "$one $two $three"

For a small subset of all possible values of one, two and three, the two
approaches will produce seemingly identical results. For many real-world
values the two will give different but equally useful results (equally
useful in different contexts, that is).



Relevant Pages

  • Re: Large text file import: MVP question
    ... Simple solutions give fast processing ... One thing you have to keep in mind. ... througput time than from the basic Net namespace. ... change, with mid, split, tolower, or whatever will result in a new string. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: How to return a variable length substring from a function ?
    ... F90 program with output that emulates a variable length string ... I use the function in two contexts where the target length in ... the calling program is *not* fixed, and one context where the target ... Also, they are obsolescent. ...
    (comp.lang.fortran)
  • Re: FEATURE SUGGESTION: Accept default value for to_f and to_i
    ... does string to number conversions, eg. a SQL results to a Fixnum. ... would come a close second best in my mind). ... configuration where you are reading a value from a string source eg. xml ... In that example, you asked for a nil default, and thats what you got. ...
    (comp.lang.ruby)
  • Re: IsDate("ISomeTimesHateProgrammingMarch2005") = True
    ... You are (to my mind) quite right to be puzzled. ... This string isn't ... English phrase' has a meaning or effect completely different than the ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Error 91
    ... NOT reccomend showing the standard error box to a user that can create major ... > I am using a piece of vba code to 'Find' a cell containing a string. ... > dialog that Excel displays, when the data is not found, when doing the Find ... >> When you lose your mind, ...
    (microsoft.public.excel.programming)