comp.lang.idl-pvwave archive - RDF feed
type: channel
description: Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
items: Re: not sure what to call this request

Re: not sure what to call this request
type: item
description: Chad Bahrmann wrote: > > I am not sure what to call this request: > > Is this possible in IDL...I can not seem to make it work...If not any work > arounds? > > IDL> vars=['tsoil_W'] > IDL> data={vars[0]:{attname:STRARR(6)}} > > data={vars[0]:{attname:STRARR(6)}} > ^ > % Syntax error. > > without having to do > data={tsoil_W:{attname:STRARR(6)}} > because ultimately I will have a 26 vars that I would like to build > structures for What exactly do you want to do? Be able to access structures components without referencing the tag name? Off the top of me head, you could try: IDL> vars = [ 'tsoil_W', 'tsoil_X', 'tsoil_Y', 'tsoil_Z' ] First create the structure with the first component: IDL> data = CREATE_STRUCT( vars[0], {attname:STRARR(6)} ) IDL> HELP, data.tsol_w, /STRUCT ** Structure <823df34>, 1 tags, length=72, data length=72, refs=2: ATTNAME STRING Array[6] Now you've got yer structure started, concatenate away..... IDL> FOR i = 1, N_ELEMENTS( vars ) - 1 DO data = CREATE_STRUCT( data, vars[i], {attname:STRARR(6)} ) IDL> HELP, data, /STRUCT ** Structure <823f38c>, 4 tags, length=288, data length=288, refs=1: TSOIL_W STRUCT -> <Anonymous> Array[1] TSOIL_X STRUCT -> <Anonymous> Array[1] TSOIL_Y STRUCT -> <Anonymous> Array[1] TSOIL_Z STRUCT -> <Anonymous> Array[1] So now if you want to know what the attributes of, say, tsoil_X are: IDL> loc = WHERE( vars EQ 'tsoil_X' ) IDL> HELP, data.(loc[0]), /STRUCT ** Structure <823e91c>, 1 tags, length=72, data length=72, refs=2: ATTNAME STRING Array[6] Pretty cool I reckon. And the above way is probably one of the more brain dead ways of doing it. I mean, it uses concatenation *and* a loop..... sheesh :o) paulv -- Paul van Delst Religious and cultural CIMSS @ NOAA/NCEP purity is a fundamentalist Ph: (301)763-8000 x7274 fantasy Fax:(301)763-8545 V.S.Naipaul
creator: Paul Van Delst[1]
date: 2002-04-24T22:18:39-00:00

Re: not sure what to call this request
type: item
description: starr=['yes','you','can'] & result = execute('print,"'+starr[0]+' '+starr[1]+' '+starr[2]+'"') Chad Bahrmann wrote: > I am not sure what to call this request: > > Is this possible in IDL...I can not seem to make it work...If not any work > arounds? > > IDL> vars=['tsoil_W'] > IDL> data={vars[0]:{attname:STRARR(6)}} > > data={vars[0]:{attname:STRARR(6)}} > ^ > % Syntax error. > > without having to do > data={tsoil_W:{attname:STRARR(6)}} > because ultimately I will have a 26 vars that I would like to build > structures for > > >
creator: Robert Stockwell
date: 2002-04-24T23:48:51-00:00