Our version of this now-famous program is a system function that returns a scalar containing the text “Hello World!”:

#include <stdio.h>
#include "idl_export.h"
IDL_VPTR hello_world(int argc, IDL_VPTR argv[])
return(IDL_StrToSTRING("Hello World!"));

This is about as simple as an IDL system routine can be. The function IDL_StrToSTRING(), returns a temporary variable which contains a scalar string. Since this is exactly what is wanted, hello_world() returns the variable.

After compiling this function into a sharable object (named, for example, hello_exe), we can link it into IDL with the following LINKIMAGE call:

LINKIMAGE, 'HELLO_WORLD', 'hello_exe', 1, 'hello_world', $ 

Now we can issue the IDL command:


IDL displays:

Hello World!