Thread: echo output
View Single Post
Old 08-13-2007   #3 (permalink)
Oisin Grehan


 
 

Re: echo output

On Aug 13, 7:34 am, Jens Diekers
<JensDiek...@discussions.microsoft.com> wrote:
> Hello again,
>
> i think i have another basic question.
>
> i will make a array like this:
>
> $mn = 123
> $x = echo $mn, ($mn)STRING...
>
> i want that my out looks like this:
> 123
> 123STRING..., but the STRING... is interpreted as the third part of the
> array. It looks like this
> 123
> 123
> STRING...
>
> What can i do?
>
> THX


Personally, I like to use this syntax for simple variable
substitution:

PS> $s = "string"
PS> "${s}test"
stringtest

Note the use of curly braces to delimit the variable name. However,
this doesn't work for grabbing an object's property:

PS> "${s.length}test"
test

Doh.

So in this case, I use a new evaluation context like so:

PS> "$($s.length)test"
6test

They're ordinary brackets this time, not the curly ones.

Hope this helps,

- Oisin

My System SpecsSystem Spec