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

Home » Public Forums » archive » Re: Find all user-defined structure definitions
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Find all user-defined structure definitions [message #84591] Tue, 30 July 2013 07:17 Go to next message
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
On Tuesday, July 30, 2013 4:08:17 PM UTC+2, David Fanning wrote:
> Helder writes:
>
>
>
>> I realize that one can find all the structure definitions using help:
>
>>
>
>> HELP, /STRUCTURES
>
>>
>
>> However, I get 469 element string array out (with the output keyword) after a .reset_session. I then have to search through for my structure. This looks ugly to me.
>
>>
>
>> Is there an easier way to know if a structure has been defined already?
>
>> If I use Tag_Names() or N_Tags(), I get an error if it has not been defined.
>
>>
>
>> So far my solution looks like:
>
>>
>
>> Help, /Structures, Output=HelpOut
>
>> Index=Where(StrPos(HelpOut,'MYSTRUCTURE') GE 0, Count)
>
>> IF Count EQ 0 THEN print, 'create structure'
>
>
>
> Why do you care if your structure has been defined already?
>
>
>
> Cheers,
>
>
>
> David
>
>
>
>
>
>
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")

Well, I have this big program that calls many times an object where a structure is defined in the init method. If this object is used within this big program, the structure is already defined and can simply be used in the definition of the property, if not it has to be redefined.
I don't like the idea to redefine it anyway... I find it cleaner to define it once and if it is not defined, I redefine it.

I just realized, I can use the object definition. In principle I can define my structures i a file named MyStructure__Define and then simply call {MyStructure} and I'm sure this will be defined anywhere in the same way. Have to check about speed though... Might search through directories for a while
Re: Find all user-defined structure definitions [message #85395 is a reply to message #84591] Tue, 30 July 2013 07:21 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Helder writes:

> I just realized, I can use the object definition. In principle I can define my structures i a file named MyStructure__Define and then simply call {MyStructure} and I'm sure this will be defined anywhere in the same way. Have to check about speed though... Might search through directories for a while.

If it is already defined, it won't search though directories. It will
only search if it is NOT already defined.

By putting your structure definitions in one file, you make sure you
know how that structure is defined. This should be at the top of your
Best Programming Practices list.

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: Find all user-defined structure definitions [message #85397 is a reply to message #85395] Tue, 30 July 2013 08:01 Go to previous message
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
On Tuesday, July 30, 2013 4:21:09 PM UTC+2, David Fanning wrote:
> This should be at the top of your Best Programming Practices list.

Working on getting that list sorted out...

Thanks for the tip,
Helder
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Find all user-defined structure definitions
Next Topic: Writing a modified .txt file issue

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

Current Time: Wed Oct 08 15:05:55 PDT 2025

Total time taken to generate the page: 0.00735 seconds