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

Home » Public Forums » archive » Re: AND statements
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: AND statements [message #14494 is a reply to message #14451] Mon, 01 March 1999 00:00 Go to previous messageGo to previous message
steinhh is currently offline  steinhh
Messages: 260
Registered: June 1994
Senior Member
In article <36da962e.18718769@146.80.9.44> philaldis@geocities.com
(Phil Aldis) writes:

> So, to avoid that you have to do some pretty messy code. Say for
> example I've got :
>
> IF Ptr_Valid(ThisPointer) THEN BEGIN
> IF Size(*ThisPointer, /type) EQ 10 THEN BEGIN

Yep, that's right. You do get used to it, though, even if you're
grown up with C style logical operators, taking advantage of the
non-evaluation of unnecessary parts for every little scrap of
efficiency improvement.

> However, I want to execute the same bit of code if it fails the
> Ptr_Valid and the Size(*ThisPointer, type0 EQ 10, so as far as I can
> see, (and I realise that I may be missing something pretty blatent),
> you have to use flags

[..snip..]

> While obviously this is not the end of the world, there could be more
> complex examples, and the code does look messy.

Yes, though you learn to rewrite those statements somewhat,
like this:

flag = NOT ptr_valid(thispointer)
IF NOT flag then flag = size(*thispointer,/type) EQ 10

IF NOT flag THEN BEGIN
;; Pointer is valid and points to type 10
END ELSE BEGIN
;; Pointer is not valid or doesn't point to type 10
END

There could be some improvement with the ?: construct:

flag = NOT (ptr_valid(thispointer) ? size(*thispointer,/type) eq 10 : 0b)

should be equivalent to the first two lines in my example.
In fact, you could rewrite your original code like this:

if (ptr_valid(ptr) ? size(*ptr,/type) eq 10 : 0b) then print,*ptr $
else flag=1b

I'm not sure whether *I* would use the ?: construct in cases like
this.... it looks more messy to me, in fact..

Regards,

Stein Vidar
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: image scaling with object graphics
Next Topic: TRANSREAD - read ASCII tables

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

Current Time: Sat Oct 11 04:40:17 PDT 2025

Total time taken to generate the page: 0.79476 seconds