SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 4 of 4

Thread: Returning array

  1. #1
    Member
    Join Date
    Dec 2003
    Location
    Hyderabad
    Posts
    83
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Returning array

    Hi,

    I have a function and that should return an array.

    Its returning one element of source array.
    How should i go about this.

    thanks.
    Lee

  2. #2
    Member
    Join Date
    Jan 2002
    Posts
    61
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Returning array

    Even I tried to return an array, it is throwing some error message. I followed method, may be it is round about way, but it workds. Store all the array elements in a string variable with some delimiter (', &) which ever you feel that it wont affect your functionality. Return that string from the function. Then using "split" function (a string function), you can get the array. ( Refer split function's syntax).

  3. #3
    Member
    Join Date
    Dec 2003
    Location
    Hyderabad
    Posts
    83
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Returning array

    Hi Ramesh,

    Thanks for the info.
    Can you just guide how to append the string using delimiter.

    thanks.
    Lee

  4. #4
    Senior Member
    Join Date
    May 2001
    Location
    Ankh-Morpork
    Posts
    2,882
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Returning array

    You cannot return an array via the return() command. However, you can declare an array as an "out" or "inout" parameter in the function declaration. Simplistic example:
    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">public function make_array(out arr[])
    {
    arr[0] = &quot;zero&quot;;
    arr[1] = &quot;one&quot;;
    arr[2] = &quot;two&quot;;
    }
    ## use it:
    make_array(test_array);
    for(ix = 0; ix in test_array; ix++)
    {
    printf(&quot;test_array[%d] = %s&quot;, ix, test_array[ix]);
    }</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">
    web site | [url=http://www.ebookworm.us/[/url]

    [i]...Sound trumpets! Every trumpet in the host! / Sixty thousand, on these words, sound, so high the mountains sound, and the valleys resound.&lt;/i] (The Song of Roland)

 

 

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

Copyright BetaSoft Inc.