Chapter 13: Aubit4GL Packages Up Chapter 13: Aubit4GL Packages Section 13.2: channel 

13.1 Packages

Packages are shared libraries that contain callable code..
Normally - you call these with code like :
call channel::open_file("fin","/etc/passwd","r")
call channel::open_file("fout","./passwd.new","w")
...
call channel::read(lv_in,[lv_rec.*]) returning b
You could import those functions so they can be called without the channel:: prefix by creating a package and then importing it in the 4gl
IMPORT PACKAGE channel
or its synonym :
USE channel
This channel_package file would be just a text file normally in the directory:
$AUBITDIR/etc/import
which contains the library and function names:
channel open_file
channel open_pipe
channel set_delimiter
channel close
channel fgl_read
(You can specify a list of directories to search by using the A4GL_CLASSPATH environment variable)
You can have functions from many libraries in a single package. That is why you need to have the library name as well as the function names.
To create these shared libraries:
$ 4glpc -as-dll module.4gl -o module.so
To use the channel library:
MAIN
  DEFINE lv_s char(200)
  CALL channel::open_pipe("pipename","ls -l","r")
  WHILE channel::read("pipename",lv_s)
CODE
    A4GL_trim_nl(lv_s); 
ENDCODE
    DISPLAY lv_s
    END WHILE
  CALL channel::close("pipename")
END MAIN
Here it runs the command ls -l and reads the output. (You might want to open a pipe for writing, in which case the last parameter would be a "w", but you cannot open a pipe for both reading and writing).
"pipename" is just a name associated with the pipe and could be anything so long as it is unique within your program.
The string (lv_s) should be long enough to contain the string - and includes any trailing newlines. In the example we trimmed this by dropping to C and calling the Aubit4GL builtin: A4GL_trim_nl()
Note : the CODE and ENDCODE keywords must be the only things on their respective lines - no leading or trailing spaces or tabs.
But between the CODE and ENDCODE there can have as many spaces and newlines as you like!)
 Chapter 13: Aubit4GL Packages Up Chapter 13: Aubit4GL Packages Section 13.2: channel