[Gambas-user] ByRef
Hello List! I've switched to development version 3.0 and I'm trying to get rid of this ByRef thing. I wonder, if someone could explane the syntax to me! Thanks in advance!! 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=100url=/ ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] ByRef
Hello Stevie, If this is similar to the ByRef from VB, there is following to be said: In Subroutine or Function that expects parameters passed from other part of your program there are two possibilities to pass them By Value (ByVal) or by Reference (ByRef). First one means that your Sub gets only the Value and does NOT change the variable that was passed in. Passing by Reference is almoust the same as the pointer concept from C language, INTERN the address of the var is passed so the Value CAN be changed inside the Subroutine. Hereby you must be carefull, sometime passing ByRef can spare time and ressources, but it can also be (used without deeper mean) a source of hardly to track bugs... kind regards Emil -Ursprungliche Nachricht- Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Auftrag von [EMAIL PROTECTED] Gesendet: Dienstag, 2. September 2008 11:28 An: mailing list for gambas users Betreff: [Gambas-user] ByRef Hello List! I've switched to development version 3.0 and I'm trying to get rid of this ByRef thing. I wonder, if someone could explane the syntax to me! Thanks in advance!! 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=100url=/ ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user - 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=100url=/ ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] ByRef
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!) -Ursprungliche Nachricht- Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Auftrag von [EMAIL PROTECTED] Gesendet: Dienstag, 2. September 2008 11:28 An: mailing list for gambas users Betreff: [Gambas-user] ByRef Hello List! I've switched to development version 3.0 and I'm trying to get rid of this ByRef thing. I wonder, if someone could explane the syntax to me! Thanks in advance!! 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=100url=/ ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user - 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=100url=/ ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] ByRef
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=100url=/ ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user