comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Undefined variables in structures
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Undefined variables in structures [message #62437] Wed, 10 September 2008 02:16 Go to previous message
Joost Aan de Brugh is currently offline  Joost Aan de Brugh
Messages: 16
Registered: July 2008
Junior Member
Hello all,

What is the most plausible way to undefine variables in a structure.
Sometimes, you need undefined variables to put into optional arguments
if the procedure checks with N_Elements(..) ne 0.

For example:
plot,....,color=fsc_color(colorname,filename=consts.COLOR_FI LENAME),...
If I do not want to use an own color file, I need to undefine
consts.COLOR_FILENAME. Note that "" as filename is an error.

Several attempts
1
if consts.COLOR_FILENAME eq "" then void =
Temporary(consts.COLOR_FILENAME)
; does not work in a struct. consts.COLOR_FILENAME remains ""

2
temp_color_filename = consts.COLOR_FILENAME
if consts.COLOR_FILENAME eq "" then void =
Temporary(temp_color_filename)
plot,...,color=fsc_color(color,filename=temp_color_filename) ,...
; Not the way to go. Makes the code messy, especially when more
variables have to be undefined this way

3
if consts.COLOR_FILENAME eq "" then
plot,...,color=fsc_color(color),... else
plot,...,color=fsc_color(color,filename=consts.COLOR_FILENAM E)
; Not the way to go. Will create a huge if-then-else pyramid when
using several optional arguments.

4
plot,...,color=fsc_color(color,filename=consts.COLOR_FILENAM E eq ""?
undefined:consts.COLOR_FILENAME),...
; No pyramid because of the ? : construction But this is very hacky,
because I am using a nonsense name (undefined).

5 ; The way I now just thought of.
Make it a pointer and during startup
if *const.COLOR_FILENAME eq "" then void =
Temporary(*consts.COLOR_FILENAME)
and then simply
plot,...,color=fsc_color(color,filename=*consts.COLOR_FILENA ME)
; This does work. I can dereference the pointer, because it is a valid
pointer to an undefined heap variable. It is still a little bit
tricky, but the least evil of these possibilities (in my opinion).

Are there people with more experience with these kinds of
constructions and know a better way to do this.
(Actually, I was already formulation this question before I thought
about the pointer)
[Message index]
 
Read Message
Read Message
Previous Topic: Re: Segmentation in ENVI
Next Topic: write_tiff integer format

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 14:20:29 PDT 2025

Total time taken to generate the page: 0.72094 seconds