This is a little trick that i often use with Subs and Functions that must work
in different modes, to make the code more readable.
I pass a parameter ByVal as Asciiz*2 and call the function with a string literal.
The Asciiz string clips off the first character, which is subsequently processed.
I now find that PBCC4 and 5 handle this in a different way.
Although the workaround is simple, the issue interests me,
and i would like to understand it. Therefore two questions :
1. Is this technique legal ?
2. Comparing PBCC4 and PBCC5 with the code below, i get the following reults:
Parameter value : "Load"
Result PBCC4 : Byref "Load", ByVal "L"
Result PBCC5 : ByRef "L", ByVal "Lo"
Does anyone understand the logic of this.
Especially the last case where two characters are passed puzzles me a bit.
Arie Verheul
in different modes, to make the code more readable.
I pass a parameter ByVal as Asciiz*2 and call the function with a string literal.
The Asciiz string clips off the first character, which is subsequently processed.
I now find that PBCC4 and 5 handle this in a different way.
Although the workaround is simple, the issue interests me,
and i would like to understand it. Therefore two questions :
1. Is this technique legal ?
2. Comparing PBCC4 and PBCC5 with the code below, i get the following reults:
Parameter value : "Load"
Result PBCC4 : Byref "Load", ByVal "L"
Result PBCC5 : ByRef "L", ByVal "Lo"
Does anyone understand the logic of this.
Especially the last case where two characters are passed puzzles me a bit.
Arie Verheul
Code:
[FONT="Courier New"][SIZE="2"]#DIM ALL '---------------------------------- SUB Test1 (S AS ASCIIZ*2) PRINT "ByRef",S END SUB '---------------------------------- SUB Test2 (BYVAL S AS ASCIIZ*2) PRINT "ByVal",S END SUB '---------------------------------- FUNCTION PBMAIN () AS LONG Test1 "Load" Test2 "Load" WAITKEY$ END FUNCTION '----------------------------------[/SIZE][/FONT]
Comment