Page 1 of 1

Structure field name confuse variable name

Posted: Wed Sep 07, 2022 8:55 pm
by bfernhout
I am trying to program a packman version for study class.
When i use a variable called Direction en i use a structure e.g. Pinky()'\Direction. the Pinky()\Direction is seen as a variable Direction.

Code example

Code: Select all

#Left =1
#Right = 2

Global Direction.i = 0

Structure Pink
  Direction.i
Endstructure

Global NewList Pinky.Pink()

Addelement (Pinky())

pinky()\Direction = #Left

Debug Pinky()\Direction 	;Result in 0
debug Direction			;Result in 0
Two differend variables but only the global created variable is reconized.

Re: Structure field name confuse variable name

Posted: Wed Sep 07, 2022 8:56 pm
by bfernhout
Sorry to give the version its PB 6.00 LTS 64 bits

Re: Structure field name confuse variable name

Posted: Wed Sep 07, 2022 9:07 pm
by Paul
Works fine here..
Debug Pinky()\Direction ;Result in 1
Debug Direction ;Result in 0

Re: Structure field name confuse variable name

Posted: Wed Sep 07, 2022 10:58 pm
by mk-soft
All ok here ...

Window, Linux, macOS

Re: Structure field name confuse variable name

Posted: Fri Sep 09, 2022 4:14 pm
by bfernhout
This topic mayt be closed. I did not notice that the program was clearing the variable in the structure.

When in debug mode the variable is not reconiced as a variable from the structure. That the only problem. I had a long piece of code and needed to reset the value a couple of times.
That was done on another Procdure so when my program runs it gave me the 0 value what was right.

Bart Fernhout.