SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 6 of 6
  1. #1
    SQA Council
    Join Date
    Mar 2001
    Posts
    14,438
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    How to Declare Function Returning an array?

    User Yuesong Wang (yuesong22044@yahoo.com.nospam) posted:

    Hi,

    Can I declare a function that returns an (dynamic)
    array? How?

    I tried to use variant instead but seems that Robot
    does not allow array to be a variant.

    Basically what I want to do is one function creates
    and populates a dynamic array and others take that
    array as a parameter, but I can't make it work...

    Thanks!

    Yuesong

    __________________________________________________

  2. #2
    SQA Council
    Join Date
    Mar 2001
    Posts
    14,438
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to Declare Function Returning an array?

    User rjpowers (rjpowers@townisp.com.nospam) posted:

    You cannot declare a function to return an array.

    Since Robot will pass an array by reference, you can pass an empty array as
    an argument and your Function can fill that array for you.

    Richard



  3. #3
    SQA Council
    Join Date
    Mar 2001
    Posts
    14,438
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to Declare Function Returning an array?

    User Tom Roberts (testmachine2k@yahoo.com.nospam) posted:

    In your function declare the array as a ByRef
    parameter and it will be populated as you create and
    modify it.

    --- Yuesong Wang <yuesong22044@yahoo.com> wrote:
    ************************************************** **************************
    ************************************************** ***************************


    __________________________________________________

  4. #4
    SQA Council
    Join Date
    Mar 2001
    Posts
    14,438
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to Declare Function Returning an array?

    User (lgoodwin@russell.com.nospam) posted:

    Not true. Arrays can be dimensioned as any SQABasic data type, including
    Variant.

    Luke


    ---

  5. #5
    SQA Council
    Join Date
    Mar 2001
    Posts
    14,438
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to Declare Function Returning an array?

    User Tim Gerrells (tim@intellocity.com.nospam) posted:

    Yuesong:

    Function FillArray(sArray() As String) As Long
    Dim i As Long

    i = 0
    If Format(Now, "dddd") = "Tuesday" Then
    For i = 1 to 100
    ReDim Preserve sArray(i)
    sArray(i) = "Iteration #" + CStr(i)
    Next i
    End If

    FillArray = i
    End Function

    One idea to avoid error handling for arrays that conditionally are not
    filled is to return the number of array elements actually filled in, in the
    return value.

    ---

  6. #6
    SQA Council
    Join Date
    Mar 2001
    Posts
    14,438
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to Declare Function Returning an array?

    User Yuesong Wang (yuesong22044@yahoo.com.nospam) posted:

    Thanks for all the replies.

    Yuesong

    --- Tim Gerrells <tim@intellocity.com> wrote:
    ************************************************** **************************
    ************************************************** ***************************


    __________________________________________________

 

 

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 13.64%
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 10:44 PM.

Copyright BetaSoft Inc.