Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

What echo has do with Return value?

Closed Thread
 
Thread Tools Display Modes
Old 12-21-2006   #1 (permalink)
I really want to know
Guest


 

What echo has do with Return value?

#In this script I call function what has echos in it and another witch does
not have echos. Both should return value $false = False [int]0 or something
like that?!

function tester
{
echo "I return this and:"
return $false
}

function testerNoEcho
{
return $false
}

$testing2 = (tester)

'Tests:'

'1'
echo $testing2
'2'
echo ("($testing2)")
'3'
echo "($testing2)"
'4'
echo ($testing2)
'5'
echo "$testing2"
'6'


If ($testing2 -eq $false)
{
echo "YAY it worked!"
}
else
{
echo "oups, what happened?"
}


$testing2 = (testerNoEcho)

'Tests:'

'1'
echo $testing2
'2'
echo ("($testing2)")
'3'
echo "($testing2)"
'4'
echo ($testing2)
'5'
echo "$testing2"
'6'



If ($testing2 -eq $false)
{
echo "YAY it worked!"
}
else
{
echo "oups, what happened?"
}


#This script outputs:

Tests:
1
I return this and:
False
2
(I return this and: False)
3
(I return this and: False)
4
I return this and:
False
5
I return this and: False
6
oups, what happened?
Tests:
1
False
2
(False)
3
(False)
4
False
5
False
6
YAY it worked!


#Why does it return THE return value AND echos from function
#It is supposed to return THE return value right?
#Or how I can get function return value without getting all echos messing it
up
Old 12-21-2006   #2 (permalink)
Gaurhoth
Guest


 

Re: What echo has do with Return value?

echo is an alias for write-output.

Write-Output writes objects to the success pipeline. Try using write-host instead.

PS ps:\> get-help write-output
PS ps:\> get-help write-host

gaurhoth

"I really want to know" <I really want to know@discussions.microsoft.com> wrote in message news:0F3A6E14-D87F-4225-B5D3-860772B34A60@microsoft.com...
> #In this script I call function what has echos in it and another witch does
> not have echos. Both should return value $false = False [int]0 or something
> like that?!
>
> function tester
> {
> echo "I return this and:"
> return $false
> }
>
> function testerNoEcho
> {
> return $false
> }
>
> $testing2 = (tester)
>
> 'Tests:'
>
> '1'
> echo $testing2
> '2'
> echo ("($testing2)")
> '3'
> echo "($testing2)"
> '4'
> echo ($testing2)
> '5'
> echo "$testing2"
> '6'
>
>
> If ($testing2 -eq $false)
> {
> echo "YAY it worked!"
> }
> else
> {
> echo "oups, what happened?"
> }
>
>
> $testing2 = (testerNoEcho)
>
> 'Tests:'
>
> '1'
> echo $testing2
> '2'
> echo ("($testing2)")
> '3'
> echo "($testing2)"
> '4'
> echo ($testing2)
> '5'
> echo "$testing2"
> '6'
>
>
>
> If ($testing2 -eq $false)
> {
> echo "YAY it worked!"
> }
> else
> {
> echo "oups, what happened?"
> }
>
>
> #This script outputs:
>
> Tests:
> 1
> I return this and:
> False
> 2
> (I return this and: False)
> 3
> (I return this and: False)
> 4
> I return this and:
> False
> 5
> I return this and: False
> 6
> oups, what happened?
> Tests:
> 1
> False
> 2
> (False)
> 3
> (False)
> 4
> False
> 5
> False
> 6
> YAY it worked!
>
>
> #Why does it return THE return value AND echos from function
> #It is supposed to return THE return value right?
> #Or how I can get function return value without getting all echos messing it
> up

Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
WScript.Echo PaulM VB Script 3 07-18-2008 02:33 AM
Miccrophone echo Joanne Vista hardware & devices 2 06-07-2008 09:26 AM
echo cancellation gram Vista General 0 11-14-2007 12:05 PM
echo output Jens Diekers PowerShell 2 08-13-2007 09:07 AM
Any Way To Get Rid Of The Echo? Arny Krueger Vista music pictures video 1 11-22-2006 10:03 AM








Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50