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

Home » Public Forums » archive » Looping over parameters without EXECUTE()
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Looping over parameters without EXECUTE() [message #43804] Mon, 02 May 2005 09:10 Go to previous message
Wayne Landsman is currently offline  Wayne Landsman
Messages: 117
Registered: January 1997
Senior Member
The one case where I haven't figured out how to remove EXECUTE() from a
program (to allow use with the Virtual Machine) is where one wants to
loop over supplied parameters. For example, to apply the procedure
'myproc' to each supplied parameter (which may have different data
types) one can use EXECUTE() to write each parameter to a temporary
variable:

************************************************

pro doit,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11

;Loop over input parameters
Np = N_params()
colname = 'p' + strtrim(indgen(Np)+1,2)

for i=0,Np-1 do begin
result = execute('p=' + colname[i] )
myproc,p
endfor
**********************************************
Is there a way to avoid EXECUTE() here -- say to identify the 4th
parameter as e.g., $4 ? Of course, one can always avoid the loop and
explicitly write out the call for each parameter:

myproc,p1
myproc,p2
....
but this probably becomes unreasonable at around 20 parameters.

One solution is to have the program read an array of pointers rather
than multiple parameters. But this has the disadvantages of losing
backwards compatibility, as well as making the program somewhat more
complicated to use. My current default solution is to make a pointer
keyword available and say that data must be passed this way instead of
via parameters, if the user wants to use the VM.

Thanks, --Wayne
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Adding flexibility at run time question
Next Topic: Re: Adding flexibility at run time question

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

Current Time: Wed Oct 08 13:31:30 PDT 2025

Total time taken to generate the page: 0.00379 seconds