Clinton L. Jeffery
February 28, 2006
Unicon Technical Report #7a
Abstract
![]() |
http://unicon.sourceforge.net/utr/utr7.htm Department of Computer Science New Mexico State University Las Cruces, NM 88003 |
This implementation of Unicon is an open source project under the GNU license; it may be copied and used with few restrictions. The Unicon Project makes no warranties of any kind as to the correctness of this material or its suitability for any application. The responsibility for the use of Unicon lies entirely with the user.
The basic reference for Version 11 of Unicon is the book
Programming with Unicon [1]. This book is available from the Unicon
Project web site at http://unicon.org. The graphics
facilities are detailed in a separate report [2].
Windows Unicon and the Ui environment are open source products based on
the volunteer work of many people; final responsibility for this release
rests with Clinton Jeffery of
New Mexico State University. Send requests, and bug reports to
jeffery@cs.nmsu.edu. General Unicon language questions can be
sent to unicon-group@lists.sourceforge.net, which is a
moderated low-volume mailing list (only list members can post messages
to the list).
setup.exe, prefixed by whatever drive letter and
path you copied setup.exe into, to install Windows Unicon.
During installation, you will be asked for a drive and directory into which
the Unicon files will be installed, which defaults to
C:\UNICON. Files will be installed into
several subdirectories of the location you specify.
Installation also results in the creation
of a Windows Unicon program group with a set of icons that allow you read
on-line documentation, uninstall the software, and launch Windows Unicon.
Within the directory that Unicon was installed, the most important subdirectory
is the bin directory, which contains the Unicon system binaries.
Several executable binary files are required to use Unicon, including
the executor and the
compiler that produces virtual machine code files for the executor. The
executor and compiler are normally invoked by the integrated
development environment called Ui, a simple
editor/project builder that provides a visual
interface to the program development process. Applications that provide a
graphical interface are usually constructed by means of a visual interface
builder called IVIB, a drawing program that generates Unicon code for a
program's interface. The following table summarizes the contents of the
bin directory:
bin directory, normally
C:\UNICON\BIN
usually must be added to your PATH specification. This
is done through the Control Panel, or the autoexec.bat
file, depending on your version of Windows.
You can easily select an existing Unicon source file, or name a new one.
If you click "Open" without choosing a name, you will be given the default
name of "noname.icn". Unicon source files generally must use the extension
.icn and should be plain text files without line numbers or
other extraneous information. Editing your program occurs within the main
Ui window, which might look like this:
The top area shows program source code, while the bottom portion shows messages such as compiler errors. You can change the font and the number of lines used to show messages from the Edit menu.
When you are done editing your program, you can save it, compile it, or just "make" (save, compile and link an executable) and run your program with menu options. The Arguments command in the Run... menu let's you specify any command-line arguments the program should be given when it is executed.
Run-time errors also result in a message for which the source line is
highlighted. The message for a run-time error includes Unicon's standard
traceback of procedures from main() to the procedure in which
the error occurred. When the error messages get long, you can either
increase the number of lines for the message window (as was done here) or
scroll through the message window's entire text using the scrollbar.
.icn source file, Ui switches the editor and compile and
link commands to work on a different program.
Project files are plain text files with extension .icp. They
list source files, one file per line. When you open a project file, Ui goes
into "project mode", and adds the source files in the project to your File
menu, allowing you to switch easily between files in the project. If you
subsequently open a source file not in the project, Ui asks if you want to
add that source file to the project, or switch out of project mode and edit
that file as a separate program. In general, project files allow you to
"make" large projects efficiently. Underneath the covers, Ui invokes the
other Unicon program executables to do the work of compiling and running
programs, described below.
When Ui "makes" a program executable, it recompiles those modules listed in
the project file whose modified time is newer than their corresponding
object files. On the other hand, Ui knows nothing about link declarations
embedded in source files, and recompilation will not be triggered by such
dependencies. When you use Ui, you should generally use link statements for
library files (such as Unicon Program Library modules), and use
.icp files for your own sources. Files listed in the .icp file
must not also be referenced in a link statement; linking the same module
twice causes link errors. For projects, the executable .bat
that is produced by "make" is named after the first program in the project
file.
The font in the edit window can be picked from the Font... command in the Edit menu. The number of lines to use for messages can be picked with the Message window... menu item in the Edit menu.
The font and message line options, as well as a default window width and
height, may be specified in a file called WI.INI
that Ui reads when it starts up. The file WI.INI
from the current directory is used, unless a WICONINI environment
variable is set, in which case it is taken to be the pathname of
the initialization file that Ui is to use. An example WI.INI
file is the following:
width=800 height=800 font=times,28 msglines=3
unicon prog.icn
The extension .icn is optional on the command line, since the compiler
assumes the .icn extension by default. For example, it is
sufficient to use
unicon prog
Windows Unicon also includes a compiler (wicont) and virtual-machine
interpreter (wiconx) that can be invoked from the command-line,
but are usually invoked by Ui. These executables, unlike the command-line
versions, do not require an MS-DOS console window, and thus are useful
for creating programs like Ui that are launched from a shortcut or menu.
The instructions below
refer to icont and iconx, but generally would also be true for wicont
and wiconx.
The Windows icode files that result of compilation have the extension .exe,
for example, the above compilation would produce a file prog.exe.
The program may then be executed as:
prog
Alternatively, unicon can be instructed to execute the icode file after
translation by appending a -x to the command line, as in
unicon prog.icn -x
If unicon is run with the -x option, the file prog.exe is left and can be
run subsequently using an explicitly named executor as described above.
unicon hello
hello
Note that this can be done in one step with
unicon hello -x
unicon roman -x
and provide some Arabic numbers from your console.
If these tests work, your installation is probably correct and you should have a running version of Windows Unicon.
prog text.dat log.dat
runs the icode file prog.exe, passing its main procedure a list of two
strings, "text.dat" and "log.dat". The program also can be translated and
run with these arguments with a single command line by putting the arguments
after the -x:
unicon prog -x text.dat log.dat
These arguments might be the names of files. For example, the main procedure
might begin as follows:
procedure main(args)
in := open(args[1]) | stop("cannot open file")
out := open(args[2], "w") | stop("cannot open file")
.
.
.
unicon prog1 prog2
translates the files prog1.icn and prog2.icn and produces one icode file,
prog1.exe. In addition to supplying files on the command line, files may be
linked or included using appropriate commands in the source file.A name other than the default one for the icode file produced by unicon can be specified by using the -o option, followed by the desired name. For example,
unicon -o probe prog
produces the icode file named probe.exe rather than prog.exe. If the -c option is given to unicon, the translator stops before producing an icode file and an intermediate ``ucode'' file with the extension .u is left for future use (normally they are deleted). For example,
unicon -c prog1
leaves prog1.u, instead of producing prog1.exe. These ucode
files can be used in a subsequent unicon command by using the .u name. This
saves translation time subsequently. For example,
unicon prog2 prog1.u
translates prog2.icn and combines the result with the ucode files from a
previous translation of prog1.icn.
Ucode files also can be added to a program using the link declaration.The informative messages from the translator can be suppressed by using the -s option. Normally, both informative messages and error messages are sent to standard error output.
The -t option causes &trace to have an initial value of -1 when the icode file is executed. Normally, &trace has an initial value of 0.
The option -u causes warning messages to be issued for undeclared identifiers in the program.
Environment variables are particularly useful in adjusting Unicon's storage requirements. Particular care should be taken when changing default values: unreasonable values may cause Unicon to malfunction.
The following environment variables can be set to adjust Unicon's execution parameters. Their default values are listed in parentheses after the environment variable name:
set ICONFONT=Lucida Sans Typewriter
A:\ICON\TEST.ICN
A:/ICON/TEST.ICN
The goal of the native facilities is not to provide the entire Windows repertoire, any more than the entire X Window repertoire is provided to UNIX users. Instead, features have been chosen that are (1) important to the Windows look and feel, (2) general enough to be implementable on other platforms, and (3) can co-exist or be integrated with existing IPL facilities. These facilities, and the "Wu" IDE that uses and demonstrates them, may be more accessibility-friendly than Unicon's normal GUI interface.
WinMenuBar(W, ["&File", "&Open", "&Save", "E&xit"], ["&Edit", "C&ut", "&Paste", "C&opy"], ["&Help", "&About"])This function converts approximately the top text line of the window into a menu bar. The appearance of the above example is given in Figure 5. When menu items are selected, they are produced as entire strings (such as
"&Open") by Event().
WinScrollBar(W, "sb_1", x, y, wd, ht)This function places a scrollbar with a particular size and position, which default to a standard size on the right edge of the window. The appearance of a typical scroll bar is illustrated in Figure 6. When scroll bar activity takes place, the scroll bar's string id is produced (in this case,
"sb_1") by Event(), and
&x and &y are both set to the scroll bar's
position.
WinButton(W, "hello", x, y, wd, ht)This function places a button with a particular size and position. The size defaults to a standard size large enough display the button's label. The appearance of a pair of buttons is illustrated in Figure 7. When a button is pressed, the button's string label is produced (in this case,
"hello") by Event().
stat() and
is no longer built-in.
You can add the library declaration "link fattrib" to your
program if you don't want to change your fattrib() calls.
| Defaults: | wd | width of text in system font + 10 pixels |
| ht | height of text in system font * 7/4 |
system("cmd /C /Q " || command)
![]() |
![]() |
![]() |
![]() |
![]() |
Clinton Jeffery
Department of Computer Science
New Mexico State University
Las Cruces, NM 88003
U.S.A.
(505) 646-3480 (voice)
(505) 646-1002 (fax)
jeffery@cs.nmsu.edu
In order to minimize response times, the preferred method for reporting
problems is by e-mail. I would also like to hear suggestions and success
stories from satisfied users; e-mail is great but letters and postcards are
even better for this kind of feedback. Think of TROUBLE.TXT as a
"registration" for your free software.
Bob Goldberg, Steve Schiavo, and Bryan Ross wrote prototype program launchers that inspired the Ui integrated development environment.
Much of this work was made possible by support from the National Library of Medicine Specialized Information Services division, under the direction of Phillip Thomas.
2. Gregg M. Townsend, Ralph E. Griswold, and Clinton L. Jeffery, Graphics Facilities for the Unicon Programming Language Version 9.3, The Univ. of Arizona Icon Project Document IPD281, 1996.