Am Dienstag, 2. September 2008 12:06:09 schrieb Emil Tchekov:
> Forgot to gave you example (VB)
>
>
> sub main()
>
>       dim a as integer
>
>       a=1
>
>       debug.print a, pr1(a)
>       debug.print a, pr2(a)
>       debug.print a
>
> end sub
>
>
> private sub pr1(byval a)
>
>       a=2
>
>       return a
>
> end sub
>
>
> private sub pr2(byref a)
>
>       a=2
>
>       return a
>
> end sub
>
>
> result will be as follows
>
> 1   2
>
> 1* 2
>
> 2 (!)
>
>
> *As you can see on the first sub the var a is local to your sub, it was
> changed (returns 2), but the passed a has stil value 1
>
> (!) in the second procedure the passed var a was changed! (the a that was
> defined in the sub main!)

Hi Emil,

thanks for your reply! ...it helped to understand the concepts and the syntax. 
Meanwhile I got it running. Gambas wants the "Byref" twice! Once by calling 
the procedure and a second time in the header of the function.

Sub Main

        DIM sResult as String
        sResult = ""
        GetData(Byref sResult)
        Print sResult & "\n"
End


Public Sub GetData(ByRef sResult As String)
  
         sResult = "Hello"
 
End

Greetz
Stevie


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to