SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 4 of 4
  1. #1
    Junior Member
    Join Date
    Jan 2004
    Location
    Toronto
    Posts
    13
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Passing parameters to another script

    I was wondering if there is a way to pass values to another script without declaring everything to be public? For example if I wanted to pass the value to another script like the one below

    Script1:

    Function Main

    var1 = "something"

    Run("Script2")

    End Function


    Script2:

    Function Main

    Msgbox("", var1)

    End Function


    Can you pass values like you would a regular function, such as Run("Script1", var1)?

  2. #2
    Senior Member
    Join Date
    Jun 2002
    Location
    farmington hills, MI, US
    Posts
    713
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Passing parameters to another script

    In the Run command you can add parameters which would be your variable. Then in script 2 you would want to use the cmdLine command to retrieve the parameter. It would look something like this.

    Function Main

    d = 10
    Run( "Script2" , d )

    End Function

    Script2
    Function Main

    d = CmdLine( 2 )

    msgbox "", d

    End Function

  3. #3
    Junior Member
    Join Date
    Jul 2003
    Location
    Brentwood, TN
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Passing parameters to another script

    Be careful if your variable is a string containing spaces. The Run command sees spaces as separators for command line arguments. For example, script2 will see "something" as CmdLine(2) and "else" as CmdLine(3).

    Script1:

    Function Main

    var1 = "something else"

    Run("Script2", var1)

    End Function

    I get around this by substituting underscores for spaces before calling Run and using a function to convert them back in the script being called.

    Someone please correct me if I'm wrong or sees a better way to deal with this situation.

  4. #4
    Senior Member
    Join Date
    Jun 2002
    Location
    farmington hills, MI, US
    Posts
    713
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Passing parameters to another script

    This should work:

    var1 = chr(34) +"something else" + chr(34)

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 10.71%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 01:45 PM.

Copyright BetaSoft Inc.