java调用idl,科学网—IDL混合编程 - 杨杭的博文

混合编程是同时使用多种语言实现一个业务化系统的编程方式,目的是为了充分发挥不同语言的优势。这种编程方式下需要各个语言提供方便的扩展和外部接口调用方法。本部分主要是讲解IDL调用外部语言与其他常用语言调用IDL的方式。

一、IDL功能扩展

1.调用可执行程序

1.1 SPAWN

IDL可以直接调用外部可执行程序。例如IDL直接调用win系统中的画图程序:

spawn, 'mspaint'   ;启动DOS命令行界面

spawn, 'mspaint',/noshell ;不启动DOS命令行界面

除可执行程序外,还可以调用其他外部文件,调用时会执行默认程序打开文件:

SPAWN, 'D:\IDLPROJ\IQA\veg.txt'   ;启动DOS命令行界面

SPAWN, 'D:\IDLPROJ\IQA\veg.txt',/hide  ;不启动DOS命令行界面

Syntax

SPAWN [, Command [, Result] [, ErrResult] ]

Keywords (all platforms): [, COUNT=variable] [, EXIT_STATUS=variable] [ ,/NOSHELL] [, /NULL_STDIN] [, PID=variable] [, /STDERR] [, UNIT=variable {Command required, Result and ErrResult not allowed}]

UNIX-Only Keywords:[, /NOTTYRESET] [, /SH]

Windows-Only Keywords:[, /HIDE] [, /LOG_OUTPUT] [, /NOWAIT]

仅调用DOS命令行界面(To simply spawn a shell process from within IDL, enter the command):

IDL> SPAWN

在Windows系统中,IDL的SPAWN命令其实就是在执行CMD命令。

注意:直接利用SPAWN启动外部程序或文件时,如果路径中含有空格,则启动失败。

如果程序路径中含有空格解决办法是用""把路径引用:

SPAWN, '"D:\test blank\veg.txt"'  ;启动后DOS界面不退出

SPAWN, 'start "" "D:\test blank\veg.txt"'   ;启动后DOS界面退出

SPAWN, 'start "" "D:\test blank\veg.txt"' ,/hide  ;不启动DOS界面

start:

SPAWN, 'D:\test blank\veg.txt'  ;程序不报错

SPAWN, 'start D:\test blank\veg.txt'  ;程序报错,见下图,因为路径中含有空格

e1b25a3fb428967214529ba41882481f.bmp

1.2 OnLine_Help

OnLine_Help是一个帮助启动程序,调用格式为:

Syntax

ONLINE_HELP [, Value] [, BOOK=‘filename’] [, /FULL_PATH] [, TITLE = 'title']

Windows-Only Keywords: [, /CONTEXT]

BOOK:指定下面四种类型的帮助文件:ExtensionFile TypeBehavior.html.htmHTMLOpens the specified HTML file in IDL's help viewer. If the Value argument is present, it is treated as an anchor value and appended to the URL for the specified HTML file. In most cases, this will cause the browser to position the file content so that the specified anchor is at the top of the viewing window. If the anchor is not present in the HTML file, the browser generally ignores it quietly.

Note:See Displaying HTML and PDF Files under UNIX for additional information.

.chmWindows HTML HelpOpens the specified Windows HTML Help file. If the Value argument is present, the Index tab of the HTML Help viewer is positioned to display the closest matching value. See also the CONTEXT keyword.

.hlpWindows HelpOpens the specified Windows Help file. If the Value argument is present, the Index tab of the Help viewer is positioned to display the closest matching value. See also the CONTEXT keyword.

.pdfAcrobatOpens the specified PDF file in the system default PDF viewer. The Value argument is quietly ignored.

Note:See Displaying HTML and PDF Files under UNIX for additional information.

NoneAny typeSearches the directories specified by the !HELP_PATH environment variable for a file whose base name matches the specified value, in this order:.adp,.chm(Windows only),.hlp(Windows only),.pdf,.html,.htm. The first file found is opened and the Value argument interpreted as described by this table.

Note:Topics in the IDL help system will not be found by this mechanism.

2.调用DLL

Dynamic Link Library,动态链接库。DLL是一个可由多个程序同时使用的代码或数据的库,动态库提供进程调用外部功能函数的标准方法。通过使用DLL,程序可以由相对独立的组件组成,程序在运行时将各个模块动态的加载到主程序中。由于模块是彼此独立的,而且模块只在相应的功能被请求时才加载,所以程序的加载速度很快。

通过CALL_EXTERNAL命令IDL能够调用特定的DLL,从而实现IDL调用其他语言已有功能模块。

Syntax

Result = CALL_EXTERNAL(Image, Entry [, P0, ..., PN-1] [, /ALL_VALUE] [, /B_VALUE | , /D_VALUE | , /F_VALUE | , /I_VALUE | , /L64_VALUE | , /S_VALUE | , /UI_VALUE | , /UL_VALUE | , /UL64_VALUE] [, /CDECL] [, RETURN_TYPE=value] [, /UNLOAD] [, VALUE=byte_array] [, WRITE_WRAPPER=wrapper_file] [, /AUTO_GLUE] [, CC=string] [, COMPILE_DIRECTORY=string] [, EXTRA_CFLAGS=string] [, EXTRA_LFLAGS=string] [, /IGNORE_EXISTING_GLUE] [, LD=string] [, /NOCLEANUP] [, /SHOW_ALL_OUTPUT] [, /VERBOSE] )

关键参数:

Image

The name of the file, which must be a sharable library (UNIX), or DLL (Windows), which contains the routine to be called.

Entry

A string containing the name of the symbol in the library which is the entry point of the routine to be called.

P0, ..., PN-1

The parameters to be passed to the external routine. All array and structure arguments are passed by reference (address). The default is to also pass scalars by reference, but the ALL_VALUE or VALUE keywords can be used to pass them by value. Care must be taken to ensure that the type, structure, and passing mechanism of the parameters passed to the external routine match what it expects. There are some restrictions on data types that can be passed by value, and the user needs to be aware of how IDL passes strings. Both issues discussed in further detail below.

3.调用DLM

4.调用COM和ActiveX

5.调用Java

二其他语言调用IDL

转载本文请联系原作者获取授权,同时请注明本文来自杨杭科学网博客。

链接地址:http://blog.sciencenet.cn/blog-346157-1161712.html

上一篇:IDL程序发布与部署

下一篇:IDL基础语法汇总

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值