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

Home » Public Forums » archive » Re: pointers and IF statement
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: pointers and IF statement [message #46337 is a reply to message #46331] Wed, 16 November 2005 12:27 Go to previous message
btt is currently offline  btt
Messages: 345
Registered: December 2000
Senior Member
JJMeyers2@gmail.com wrote:
> Hello,
>
> I am trying to learn pointers and I had a problem while writing a
> program.
> My program is comparing two lists of data (list1,list2) and is trying
> to find in which positions the data match, but because that might be in
> more than 2 positions I am using the pointers to store the data. In the
> case that the program does not find a match I want to be able to
> substitute with another value.
> So my program goes like this:
>
> match1=ptarr(number,/allocate_heap)
> FOR i=0,number-1 DO BEGIN
> *match1[i]=WHERE(list1 GT list2(i))
> IF *match1[i] EQ -1 THEN BEGIN
> *match1[i]=WHERE(list1-list2(i) EQ min(list1-list2(i))
> ENDIF
> ENFOR
>
> When i try to run this i get:
> Expression must be a scalar or 1 element array in this context: <BYTE
> Array[2]>.
> and I can not figure out how to correct the problem.
>

I would suspect that *match[i] is not a scalar as you are assuming.
That is why you get the error asking for a scalar.

Perhaps you want

IF (*match1[i])[0] EQ -1 THEN BEGIN

note the indexing of the vector stored in *match[i].

Sante,
Ben
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: IDLgrModel rotation axis's origin
Next Topic: Re: IDLgrModel rotation axis's origin

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

Current Time: Sat Oct 11 04:29:23 PDT 2025

Total time taken to generate the page: 0.72161 seconds