I'm struggling to understand address in spin. I want to define a array of structures.
but my code below just output this
it's like ToDayWeather's pointer is not a stand alone copy but just point to the address of We_Tmin
what am i doing wrong?
but my code below just output this
Day: Dem
Tmin: 5
TMax: 10
Condition: Conditions pluvieuses
Icon: Rain.gif
Day: Dem
Tmin: 5
TMax: 10
Condition: Conditions pluvieuses
Icon: Rain.gif
it's like ToDayWeather's pointer is not a stand alone copy but just point to the address of We_Tmin
what am i doing wrong?
CON
_clkmode = xtal1 + pll16x 'Use crystal * 16
_xinfreq = 5_000_000 '5MHz * 16 = 80 MHz
CR = 13
weatherParamCount = 5
OBJ
PC : "Parallax Serial Terminal Extended"
VAR
' weather structure
long We_Tmin ' temperature Min
long We_Tmax ' temperature Max
long We_Day ' pointer to day
long We_Condition ' pointer to condition
long We_Icon ' pointer to Icon
' DayWeather ptr
long ToDayWeather
long Tomorrow
PUB Main
PC.Start(115_200) ' Start Parallax Serial Terminal
PC.clear
InsertDayRec(@ToDayWeather,12,40,string ("Auj"), string("Conditions bonnes"),string("Wind.gif"))
InsertDayRec(@Tomorrow,5,10,string ("Dem"), string("Conditions pluvieuses"),string("Rain.gif"))
Print_ptrDayWeather(ToDayWeather)
Print_ptrDayWeather(Tomorrow)
PUB InsertDayRec(ptrDayWeather, Tmin, Tmax,ptrDay,ptrCondition,ptrIcon)
We_Tmin := Tmin
We_Tmax := Tmax
We_Day := ptrDay
We_Condition := ptrCondition
We_Icon := ptrIcon
'long[ptrDayWeather] := @We_Tmin
longmove(long[ptrDayWeather],@We_Tmin,weatherParamCount)
PUB Print_ptrDayWeather (ptrDayWeather)
PC.str(string(CR,CR,"Day: "))
PC.str( long[ptrDayWeather][2] )
PC.str(string(CR,"Tmin: "))
PC.dec( long[ptrDayWeather][0] )
PC.str(string(CR,"TMax: "))
PC.dec( long[ptrDayWeather][1] )
PC.str(string(CR,"Condition: "))
PC.str( long[ptrDayWeather][3] )
PC.str(string(CR,"Icon: "))
PC.str( long[ptrDayWeather][4] )