Re: I can't get this to output how I want



Steven Platt wrote:

What is wrong with this thing?  Maybe I am too used to PHP.

Const EXAMPLE_BYTES = 32210195968
Const BYTES_IN_MEG = 1048576
Const MEGS_IN_GIG = 1024

WScript.Echo EXAMPLE_BYTES & " is " & bytesToGigs( EXAMPLE_BYTES ) & " in gigs"

Function bytesToGigs( someNumber )
 WScript.Echo (someNumber / BYTES_IN_MEG) / MEGS_IN_GIG
End Function

I want the output to be something like:
32210195968 is 29.9980826377869 in gigs

Right now I get output like:
29.9980826377869
32210195968 is  in gigs

Weird, huh? Thanks for the replies, guys.
Hi,

You need to assign the value to the function name inside the
function to make the function return anything:

Function bytesToGigs( someNumber )
 bytesToGigs = (someNumber / BYTES_IN_MEG) / MEGS_IN_GIG
End Function



--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx
.


Loading