PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → Call to Global Procedure resetting variable
Call to Global Procedure resetting variable
Iniciado por guest, 15,feb. 2018 11:57 - 3 respuestas
Publicado el 15,febrero 2018 - 11:57
WD22

Hi,

I have a global procedure, say GP_A, which calls another global procedure, GP_B.

In GP_A I am declaring an integer variable called nVar1, giving it a value of e.g. 913. I then call GP_B passing nVar1 as a parameter. GP_B returns a result which is another integer signalling either success or failure of GP_B.

So my code, in GP_A, reads

nVar1 = 913
IF GP_B(nVar1) <> 0 then
//fail code block
End

Info(nVar1)

This code worked fine in WD15, but since I upgraded to WD22 the info statement returns a value of zero, i.e. nVar1 has been reset/overrriden somehow during the call to GP_B.

Can anyone tell me why this might be happening?

GP_B uses either Result 0 or Result -1 to terminate if that helps.

Cheers
Reg
Publicado el 15,febrero 2018 - 12:11
Hi,

Quote
SolutionJ-Reg

Can anyone tell me why this might be happening?

Not without seeing the REAL code, no...

Best regards
Publicado el 15,febrero 2018 - 12:15
Most probably you are passing nVar1 "by reference"
so your procedure looks like GP_B(nVar)
and you are changing the value of nVar in GP_B, which means it also changes in the calling procedure GP_A

You should define the variable "by copy" like this
GP_B(LOCAL nVar)
Now nVar is in the scope of GP_B only.

But as Fabrice says, we need your actual code to see it this is the case.
Publicado el 15,febrero 2018 - 12:21
Hi Aire,

Your suggestion worked, many thanks.

Regards
Reg