Hi Lewis,

You're forgetting, like I often do, the parentheses for the method [.Sort()].

...
   XXX = TestFunction().Sort()
   DoPrint(XXX.Sort())
   DoPrint(TestFunction().Sort())

   For Each S In XXX.Sort()
     Print S
   Next
   Print "-------"

   For Each S In TestFunction().Sort()
     Print S
   Next
...


Lee
__________

"Artificial Intelligence is no match for natural stupidity."

On 01/07/2015 05:55 PM, Lewis Balentine wrote:
> I was playing around trying to learn how to pass string arrays back and
> forth.
> I then looked at the array.sort function. The prototype in the Wiki
> indicates that it returns an "string[]".
>
>         Function Sort([Mode As Integer]) As String[]
>
> However it seems that I can not use the returned values(s) where I would
> normally use an array. It appears to to me to operate more as a SUB than
> a FUNCTION in that it resorts the array but does not return something
> that I can use in another function or procedure. Is my interpretation of
> the prototype wrong-headed ?
>
> Regards,
>
> Lewis Balentine
>
> '================================================
> Private Function TestFunction() As String[]
>     Return ["TEST:abcdefghij", "TEST:1234567890", "TEST:ABCDEFGHIJ"]
> End
>
> Private Sub DoPrint(XXX As String[])
>     Dim S As String
>     For Each S In XXX
>       Print S
>     Next
>     Print "------"
> End
>
>
> Public Sub Main()
>     ' From Gambas Wiki:
>    '     Function Sort([Mode As Integer]) As String[]
>    '     Sort the array.
>    '
>     Dim XXX As String[] = ["XXX:abcdefghij", "XXX:1234567890",
> "XXX:ABCDEFGHIJ"]
>     Dim S As String
>
>     ' All of the following work as expected
>     DoPrint(XXX)
>     DoPrint(TestFunction())
>     XXX.Sort
>     DoPrint(XXX)
>     XXX = TestFunction()
>     XXX.Sort
>     DoPrint(XXX)
>
>     ' None of the following works: Type Mismatch, wanted string[] got
> function instead
>     ' xxx = TestFunction().sort
>     ' DoPrint(XXX.sort)
>     ' DoPrint(TestFunction().sort)
>
>     ' For Each S In XXX.Sort                '  not an object
>     '   Print S
>     ' Next
>     ' Print "-------"
>
>     ' For Each S In TestFunction().sort       '  not an object
>     '   Print S
>     ' Next
>
>     Quit
> End
>
> ' [System]
> ' Gambas = 3.6.2
> ' OperatingSystem = Linux
> ' Kernel = 3.13.0 - 24 - generic
> ' Architecture = x86_64
> ' Distribution = Linux Mint 17 Qiana
> ' Desktop = MATE
> ' Theme = QGtk
> ' Language = en_US.UTF - 8
> ' Memory = 15994 M
> ' [Libraries]
> ' Cairo = libcairo.so.2.11301.0
> ' Curl = libcurl.so.4.3.0
> ' DBus = libdbus - 1. so.3.7.6
> ' GStreamer = libgstreamer - 0.10.so.0.30.0
> ' GStreamer = libgstreamer - 1.0.so.0.204.0
> ' GTK + 3 = libgtk - 3. so.0.1000.8
> ' GTK += libgtk - x11 - 2.0.so.0.2400.23
> ' OpenGL = libGL.so.1.2.0
> ' Poppler = libpoppler.so.44.0.0
> ' Qt4 = libQtCore.so.4.8.6
> ' SDL = libSDL - 1.2.so.0.11.4
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming! The Go Parallel Website,
> sponsored by Intel and developed in partnership with Slashdot Media, is your
> hub for all things parallel software development, from weekly thought
> leadership blogs to news, videos, case studies, tutorials and more. Take a
> look and join the conversation now. http://goparallel.sourceforge.net
> _______________________________________________
> Gambas-user mailing list
> Gambas-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>

------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to