SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 6 of 6
  1. #1
    Senior Member
    Join Date
    Jun 2001
    Location
    United Kingdom
    Posts
    150
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Passing Arrays to functions

    Does anyone know if you can pass array's to functions i.e.

    My_Function(String, Interger, Array[])

    or do you just have to use public arrays to pick them up in other scripts.

    Cheers

    Simon

    ------------------

  2. #2
    Senior Member
    Join Date
    Jun 2001
    Location
    United Kingdom
    Posts
    150
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Passing Arrays to functions

    Found it.

    I was trying to pass the array using
    array_function(myarray[]) but you
    have to pass it without the square
    brackets and collect it with them.

    I've included an example in case any
    one else comes looking for it.


    Function Main

    var myarray[]

    myarray[1]="one"
    myarray[2]="two"

    array_function(myarray)

    End Function

    Function array_function(myarray[])

    msgbox("array output", myarray[2])

    End Function

    ------------------

  3. #3
    Junior Member
    Join Date
    Nov 2002
    Location
    Warren County, NJ, USA
    Posts
    16
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Passing Arrays to functions

    According to QARun's help, you can't pass an array to a function. I'd have thought you could.

  4. #4
    Senior Member
    Join Date
    Jun 2001
    Location
    United Kingdom
    Posts
    150
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Passing Arrays to functions

    There was no mention of it in the help but the above example works fine.

    Another undocumented feature...

    ------------------

  5. #5
    Senior Member
    Join Date
    Nov 2000
    Location
    Michigan, USA
    Posts
    840
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Passing Arrays to functions

    In the help for QARun Language, subject Function...End Function it shows how to list arrays in the argument list for a function (hit F1 inside a script).

    If I understand the table of valid function definitions and arguments, QARun help incorrectly says that you must pass the array by reference. But as the above valid code demonstrates, you do not.
    A problem is a difference between what is perceived and what is desired, that
    we want to reduce
    (Dewey 1933)

  6. #6
    Senior Member
    Join Date
    Dec 2001
    Location
    DFW-Texas-USA
    Posts
    124
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Passing Arrays to functions

    It has been my experience that the documentation is more along the lines of a list of suggestions. Many things can be done that are not in the manual and some things that are in the manual do not function as documented.

    As QA/Testers, is it not our nature to see if an application works as documented and if the documentation can be challenged?

    ------------------
    Pete
    psid001@aol.com

 

 

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.00%
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 09:49 PM.

Copyright BetaSoft Inc.