Structure field name confuse variable name

Just starting out? Need help? Post your questions and find answers here.
User avatar
bfernhout
Enthusiast
Enthusiast
Posts: 130
Joined: Mon Feb 26, 2018 10:41 pm
Location: Netherlands
Contact:

Structure field name confuse variable name

Post 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.
From my first self made computer till now I stil like computers.
User avatar
bfernhout
Enthusiast
Enthusiast
Posts: 130
Joined: Mon Feb 26, 2018 10:41 pm
Location: Netherlands
Contact:

Re: Structure field name confuse variable name

Post by bfernhout »

Sorry to give the version its PB 6.00 LTS 64 bits
From my first self made computer till now I stil like computers.
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1285
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Re: Structure field name confuse variable name

Post by Paul »

Works fine here..
Debug Pinky()\Direction ;Result in 1
Debug Direction ;Result in 0
Image Image
User avatar
mk-soft
Always Here
Always Here
Posts: 6291
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Structure field name confuse variable name

Post by mk-soft »

All ok here ...

Window, Linux, macOS
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
bfernhout
Enthusiast
Enthusiast
Posts: 130
Joined: Mon Feb 26, 2018 10:41 pm
Location: Netherlands
Contact:

Re: Structure field name confuse variable name

Post 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.
From my first self made computer till now I stil like computers.
Post Reply