Re: Expression question [message #54264] |
Wed, 30 May 2007 16:29 |
jkj
Messages: 48 Registered: April 2007
|
Member |
|
|
On May 30, 4:05 pm, shd <usenet_in...@yahoo.com> wrote:
> Code:
> =========================
> pro shd_test
>
> st = {a:0, b:0}
>
> arr = [st, st, st, st, st]
>
> help, st
> help, arr[0]
> help, (arr[0]).a
> help, arr.a
> help, (arr.a)[0]
>
> st.a = 1
> arr[0] = {a:1, b:0}
> (arr[0]).a = 1
> ;(arr.a)[0] = 1
> end
> ===========================
>
> Output:
> ===========================
> IDL> shd_test
> ST STRUCT = -> <Anonymous> Array[1]
> <Expression> STRUCT = -> <Anonymous> Array[1]
> <Expression> INT = 0
> <Expression> INT = Array[5]
> <Expression> INT = 0
> Attempt to store into an expression: Structure reference.
> Execution halted at: TEST_ODDITY 15 C:\Dev\IDL\projects\test
> \test_oddity.pro
> $MAIN$
>
> ===========================
>
> I can assign a value to "arr[0]" and not "(arr[0]).a". I also tried
> "(arr.a)[0]" and got a similar error. What am I missing here?
try this:
arr[0].a = 1
arr[1].b = 2
arr[2].a = 3
arr is an array of structures, so arr[i] allows you to access the ith
structure
-Kevin
|
|
|
|