Has the behaviour of 'Shared' changed in version 4.0x?
Posted: Fri Nov 10, 2006 4:54 pm
Consider the following skeleton program.
This works fine in v3.94. When I Compile/Run it in v4.0x, however, I get:
Line 89 is the Shared statement in the Proc procedure, so I presume that P3 & P4 will get the same treatment.
The behaviour of Shared appears to have changed in v4.0x. If so, why?
Regards,
Lewis
Code: Select all
Declare.l Fn1(V1.l, V2.l, V3.l)
Declare Proc(P1.l, P2.l, P3.l, P4.l)
Declare.s Fn2(P1.l)
If OpenConsole()
Repeat
... ; Print & Input statements for variables V1, V2, V3
P1 = Fn1(V1, V2, V3)
Proc(P1, P2, P3, P4) ; P1 is bound & P2, P3, P4 are free on entry to Proc
; but P2, P3, P4 are bound on exit from Proc
... ; Process using the now bound variables P2, P3, P4
Print(Str(P2) + ", " + Str(P3) + " & " + Str(P4) + " evaluate to ")
Print(Fn2(P1))
PrintN("")
Print("Another? (y/n) ")
Repeat]
K = Left(Inkey(),1)
Until K = "Y" Or K = "y" Or K = "N" Or K = "n"
Print(K) : PrintN("") : PrintN("")
Until K = "N" Or K = "n"
EndIf
End
Procedure.l Fn1(V1, V2, V3)
; process V1, V2, V3 and store result in local long variable L
ProcedureReturn = L
EndProcedure
Procedure Proc(P1, P2, P3, P4)
Shared P2, P3, P4 ; allows us to change their values here
; local variables are defined with an .l suffix, none are named P2, P3, P4
... ; Compute P2, P3, P4 based on value of P1
EndProcedure
Procedure.s Fn2(P1)
; process P1 and store result in local string variable S
ProcedureReturn = S
EndProcedure
Code: Select all
Line 89: Local variable already declared: P2
The behaviour of Shared appears to have changed in v4.0x. If so, why?
Regards,
Lewis