Structure Containing Structure: question about parentheses [message #55253] |
Thu, 09 August 2007 08:36 |
larkn10
Messages: 10 Registered: July 2006
|
Junior Member |
|
|
Hi All,
I have a question about using parentheses with structures that are
members of a structure. I include a sample program below that
demonstrates the behaviors.
Basically I have no problem if I run the command
state.str.c = 50
But if I run the command
(state.str).c = 50
then I get the error:
Attempt to store into an expression: Structure reference.
Execution halted at: TESTSTRUCT 32 C:\teststruct.pro
$MAIN$
Can someone explain this behavior to me?
Thanks!
-Larry
___________________________________________________________
pro testStruct
;CREATE STRUCTURE str
str = {a:1,b:2,c:3,al:90,be:90,ga:90}
print,str.c
print,(str).c
str.c = 15
print,str.c
print,(str).c
(str).c = 25
print,str.c
print,(str).c
;CREATE STRUCTURE state WHICH INCLUDES str
state = {num:90,let:'e',str:str}
print,state.str.c
print,(state.str).c
str.c = 15
print,state.str.c
print,(state.str).c
help,state.str
help,(state.str)
;THE PROGRAM WILL FAIL AT THE NEXT LINE. WHY????
(state.str).c = 25
print,state.str.c
print,(state.str).c
end;testStruct
|
|
|