Private Subroutines

Discussion in 'ASP General' started by Victor, Aug 25, 2006.

  1. Victor

    Victor Guest

    In ASP, if I define a subroutine as private

    Private Sub mySubroutine(arg1, arg2)

    I understand that the variables I define inside the subroutine are local only to the
    subroutine. If the same variable is defined outside the subroutine, it won't conflict
    (right?)

    What about variables that are defined outside the subroutine, but not inside? Are they
    available inside the subroutine?

    Thanks,

    Vic
     
    Victor, Aug 25, 2006
    #1
    1. Advertising

  2. Victor wrote:
    > In ASP,


    I assume you mean "vbscript", not "ASP"

    > if I define a subroutine as private
    >
    > Private Sub mySubroutine(arg1, arg2)
    >
    > I understand that the variables I define inside the subroutine are
    > local only to the subroutine. If the same variable is defined outside
    > the subroutine, it won't conflict (right?)


    Test it:

    >
    > What about variables that are defined outside the subroutine, but not
    > inside? Are they available inside the subroutine?
    >

    Yes, variables assigned outside subroutines are global.

    Here's a simple test:
    <%
    Dim x
    x=1
    response.write "outside - before call to foo: " & x & "<BR>"
    foo
    response.write "outside - after call to foo: " & x & "<BR>"
    foo2
    response.write "outside - after call to foo2: " & x & "<BR>"

    sub foo()
    dim x
    x="inside foo"
    response.write x & "<BR>"
    end sub

    sub foo2()
    Response.Write "inside foo2 - initial value of x: " & x & "<BR>"
    x=x+1
    Response.Write "inside foo2 - final value of x: " & x & "<BR>"
    end sub
    %>


    Do you have the vbscript documentation? If not, you can get it here:
    http://tinyurl.com/7rk6

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows [MVP], Aug 25, 2006
    #2
    1. Advertising

  3. Victor

    Victor Guest

    "Bob Barrows [MVP]" <> wrote in message
    news:%...
    :
    > Do you have the vbscript documentation? If not, you can get it here:
    > http://tinyurl.com/7rk6
    >


    Bob, this has been a BIG help to me today, THANKS!

    Are there .CFM files for database stuff, like SQL? I've been looking, can't find them.

    Thanks again,

    Vic
    (very new)
     
    Victor, Aug 25, 2006
    #3
  4. Victor wrote:
    > "Bob Barrows [MVP]" <> wrote in message
    > news:%...
    >>
    >> Do you have the vbscript documentation? If not, you can get it here:
    >> http://tinyurl.com/7rk6
    >>

    >
    > Bob, this has been a BIG help to me today, THANKS!
    >
    > Are there .CFM files for database stuff, like SQL? I've been looking,
    > can't find them.
    >

    Which database?

    SQL Server (Books OnLine - aka BOL) documentation can be found here:
    http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp

    For Access, you need to use the online help.

    Or are you asking for sql language help in general? I know of no generic
    online source of sql assistance.
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows [MVP], Aug 26, 2006
    #4
  5. Victor

    Victor Guest

    "Bob Barrows [MVP]" wrote...
    > Victor wrote:
    > > "Bob Barrows [MVP]" wrote...
    > >>
    > >> Do you have the vbscript documentation? If not, you can get it here:
    > >> http://tinyurl.com/7rk6
    > >>

    > >
    > > Bob, this has been a BIG help to me today, THANKS!
    > >
    > > Are there .CFM files for database stuff, like SQL? I've been looking,
    > > can't find them.
    > >

    > Which database?
    >
    > SQL Server (Books OnLine - aka BOL) documentation can be found here:
    > http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp
    >
    > For Access, you need to use the online help.
    >
    > Or are you asking for sql language help in general? I know of no generic
    > online source of sql assistance.


    SQL Server or SQL Language. Actually, I'm partial to the MS help file format because
    it's easy to use and very easy search, and I can efficiently use them when my laptop is
    on battery and not connected to the internet.

    > --
    > Microsoft MVP - ASP/ASP.NET
    > Please reply to the newsgroup. This email account is my spam trap so I
    > don't check it very often. If you must reply off-line, then remove the
    > "NO SPAM"
    >
    >
     
    Victor, Aug 30, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. qazmlp
    Replies:
    19
    Views:
    812
    Daniel T.
    Feb 4, 2004
  2. DaveLessnau
    Replies:
    3
    Views:
    437
    Howard
    May 16, 2005
  3. Jeremy Bowers
    Replies:
    3
    Views:
    531
    Steven Bethard
    Jan 24, 2005
  4. Daniel Finnie
    Replies:
    3
    Views:
    198
    Logan Capaldo
    Dec 16, 2006
  5. Frank Meyer

    Private methods not so private?

    Frank Meyer, Aug 1, 2007, in forum: Ruby
    Replies:
    14
    Views:
    274
Loading...

Share This Page