public variables 
Author Message
 public variables

Hi,

I have written the following script

test
wscript.echo digit

function test
digit=10

After running the script, the wscript.echo digit display blank, how can I
declare a digit as public variable ?

Thanks



Mon, 15 Aug 2005 16:18:46 GMT  
 public variables


Quote:
> Hi,

> I have written the following script

> test
> wscript.echo digit

> function test
> digit=10

> After running the script, the wscript.echo digit display blank, how can I
> declare a digit as public variable ?

> Thanks

To answer your specific question, in the global code declare the variable; and
don't declare it in the procedure.  Like this:

    dim digit
    test
    wscript.echo digit

    function test
        digit = 10
    end function

It looks like you used a contrived example, but let me point out that a
function will return a value when executed, so you might as well use it.  This
also makes it easy to avoid having variables with broad scope all over:

    wscript.echo test

    function test
        test = 10
    end function

--
Please respond in the newsgroup so everyone may benefit.
 http://dev.remotenetworktechnology.com
(email requests for support contract information welcomed)
 ----------
 Subscribe to Microsoft's Security Bulletins:
 http://www.microsoft.com/technet/security/bulletin/notify.asp



Mon, 15 Aug 2005 20:46:25 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Public variables in a web page

2. public variables

3. Public Variables?

4. Setting Access public variable using vbscript/WSH

5. working with functions, subroutines, private and public variables

6. defining global/public variables

7. Public variables definition

8. HTML and public variables

9. Public Variables in VBScript

10. changing data of public variable [object]

11. Exchange public folders

12. Accessing Public Folder Resources?

 

 
Powered by phpBB® Forum Software