Although Object Icon has a separate translation and execution process, it is possible (at least on Unix-like systems) to run a program like a script file.
To do this, create a source file in the usual way, but prefix it with the following line, suitably adjusted to reflect the location of your
objecticon directory :-
For example :-
#!/home/rparlett/objecticon/bin/oiscript import io procedure main(a) every write(!a) end
Next, make the source file executable :-
$ chmod +x script.icn
It can now be run directly :-
$ ./script.icn 1 2 3 1 2 3
The implementation of the above is entirely contained in the
oiscript file, which is just a simple shell script.
This script tries to minimize the startup time of the program by caching the translated the executable files produced by
oit. These are stored in a temporary directory (by default
/tmp/oixcache), and are named according to the MD5 hash value of the source file. So, for example, after running
/tmp/oixcache contains :-
$ ls /tmp/oixcache/ -l total 90,112 -r-xr-xr-x 1 rparlett rparlett 89,082 Aug 18 13:23 13b4874fd6f8f76f8a0cb986a2b93737
When a script file is run, its MD5 hash value is calculated, and if a matching file in
/tmp/oixcache is found, that is run directly, without needing to run
oit. If it is not found, then
oit is run and a new cache file created.
The location of the cache directory can be altered by setting the environment variable
oiscript file can be copied to another location and modified as you wish. Then you just have to alter the opening '#!' line in your
.icn file to point to the modified script.