Re: run .sav file with -args [message #73649 is a reply to message #73511] |
Mon, 15 November 2010 09:27   |
ben.bighair
Messages: 221 Registered: April 2007
|
Senior Member |
|
|
On 11/15/10 11:53 AM, Truong Le wrote:
> On Nov 14, 8:42 pm, Truong Le<truong...@gmail.com> wrote:
>> On Nov 14, 8:28 pm, David Fanning<n...@dfanning.com> wrote:
>>
>>
>>
>>> Truong Le writes:
>>>> It complains that the sayhello.sav function/procedure is undefined
>>>> but the sayhello.sav file does exist. Please let me know if the way I
>>>> execute my
>>>> procedure using the .sav file is correct.
>>
>>> Have you tried specifying the complete path to the file?
>>
>>> Cheers,
>>
>>> David
>>
>>> --
>>> David Fanning, Ph.D.
>>> Fanning Software Consulting, Inc.
>>> Coyote's Guide to IDL Programming:http://www.dfanning.com/
>>> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
>>
>> when I type
>>
>> idl sayhello.sav -args param1 param2
>>
>> there is a directory widget the pop-up which allows me to select the
>> sayhello.sav,
>> so I am sure the path is correct.
>
> I read other posting and realize that I can't run the .sav file with -
> args.
> Here is an example what I try to accomplish.
>
> I have a procedure that takes command line arguments as follow:
>
> pro test
>
> ; parse the parameters
> numArgs = 2
> par = COMMAND_LINE_ARGS(COUNT=numArgs)
>
> print, par[0]
> print, par[1]
> end
>
> when I ran this procedure from the dos command line using idlde by
> doing
> idlde -args hello hi
>
> and execute the test procedure it print both "hello" and "hi"
>
> I ran the idlde build project and this creates a test.sav file
>
> I need to know how I can execute idl -vm = test.sav from the unix and
> passing
> in the two arguments that I need. Is this task not possible?
>
> Thanks
Hi,
I suspect that the spaces you have inserted around "=" might be part of
the issue.
Here's how I run it from command line.
Minke:~ ben$ idl -vm=cmd_args.sav -args hello world
IDL Version 7.1, Mac OS X (darwin x86_64 m64). (c) 2009, ITT Visual
Information Solutions
arg[0] = hello
arg[1] = world
Here's my test routine
PRO cmd_args
par = COMMAND_LINE_ARGS(COUNT=numArgs)
IF (numArgs NE 0) THEN BEGIN
for i = 0, numArgs-1 do $
print, "arg[" + StrTrim(i,2) + "] = " + par[i]
ENDIF ELSE BEGIN
print, "No arguments passed"
ENDELSE
END
I made the SAV file this way...
IDL> .full_reset
IDL> .comp cmd_args
% Compiled module: CMD_ARGS.
IDL> SAVE, /ROUTINES, filename = "cmd_args.sav"
Cheers,
Ben
|
|
|