简体   繁体   English

在Windows命令行上使用IDL

[英]Using IDL on Windows command line

I am trying to start an IDL programme from the Windows command line. 我正在尝试从Windows命令行启动IDL程序。 Lets say I have the following programme: 可以说我有以下程序:

PRO hello  
print, "Hello, I am a IDL script!"  
a=bytarr(100,200)  
outname='g:\testimage.tif'  
WRITE_TIFF, outname, a  
END   

I want to execute this programme using IDL -e .RUN from the command line as following: 我想从命令行使用IDL -e .RUN执行此程序,如下所示:

C:\Users\lein_pa>idl -e ".RUN G:/05_Software/01_IDL/IDLWorkspace/Default/hello.pro"  
IDL Version 8.2, Microsoft Windows (Win32 x86_64 m64). (c) 2012, Exelis Visual Information Solutions, Inc.  
Installation number: xxxxx.  
Licensed for use by: xxx  

% Compiled module:HELLO.  
C:\Users\lein_pa> 

As you can see HELLO.pro will be compiled, but no message "Hello, I am a IDL script!" 如您所见,将编译HELLO.pro,但没有消息“您好,我是IDL脚本!”。 appears on the shell and also testimage.tif is not written to the disk. 出现在外壳上,并且testimage.tif也未写入磁盘。 When I start this programme from the IDL IDE everything works fine. 当我从IDL IDE启动此程序时,一切正常。

Can please someone help me? 可以请人帮我吗? What am I doing wrong? 我究竟做错了什么?

You could keep the file with the same name, but change it to a batch-like file by commenting out the PRO hello and END since everything in your routine could just as easily be run from the command line. 您可以使用相同的名称,但可以通过注释PRO helloEND将其更改为类似批处理的文件,因为例程中的所有内容都可以从命令行轻松运行。

Then to start everything, try: 然后开始一切,尝试:

C:\Users\lein_pa>idl -e G:/05_Software/01_IDL/IDLWorkspace/Default/hello.pro

On unix-based systems, this would start IDL and immediately run the batch file hello.pro. 在基于UNIX的系统上,这将启动IDL并立即运行批处理文件hello.pro。 If you need the double quotes for a Windows based machine, then add those accordingly. 如果您需要在基于Windows的计算机上使用双引号,请相应地添加双引号。

Keep in mind, if you make this routine more complicated but keep it as a batch file, then be careful with loops as you will need to use $ and & $ at the end of lines to include them in loops. 请记住,如果使此例程更复杂,但将其保留为批处理文件,则请谨慎使用循环,因为您将需要在行末使用$& $将它们包括在循环中。 I am quite certain that one could run actual programs/functions on startup, but it's just as easy to type in the function name after startup if it's necessary. 我非常确定一个人可以在启动时运行实际的程序/函数,但是如果需要,在启动后键入函数名称也很容易。 Typically one wants to use a startup batch routine to set personal preferences/defaults that you wish to use or commonly use when in IDL. 通常,您希望使用启动批处理例程来设置您希望在IDL中使用或常用的个人偏好设置/默认设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM