This utility is a "linker" for Basic files. It scans a Basic program for LIBRARY commands. Then it looks for any routines (PROCs or FNs) that are used in the main program, and defined in a library. These are then appended to the main program.
This enables you to develop your programs using procedures from one or more (large) libraries. When you have tested your program, you can use BLink for the final assembly. The libraries may contain procedures that you do not need in your current project — if they are not used, BLink will not include them. Thus, you get a minimal stand-alone program.
!BLink is a Wimp application, which is only a front-end for "blink", a command-line utility.
The program requires RiscOS version 3.10 or later.
BLink is FreeWare. For conditions of use, read the copyright notice at the end of this file.
The desktop application
-----------------------
The program installs itself on the icon bar. To process a BASIC file, drag its icon from a Filer window to the icon bar icon. A "Save as:" box opens, allowing you to enter the leaf name of the resulting file. Then drag the icon from the box to a Filer window, or to an application (like !Edit).
(Note: the original file will be replaced by the result if you use the same leaf name and drag it to the same directory.)
The menu has, apart from the usual "Info" and "Quit", one entry: "Options" opens a window in which you can set the various crunching options (see below). The Options window is also opened when you click on the icon bar icon with Select.
The command-line program
------------------------
!BLink is a front-end to the command-line program "blink", residing inside this application. Command-line freaks can use it directly. The general command syntax is:
blink [options] infile [outfile | -]
where <infile> is name of the main program, and <outfile> is the name under which the output must be stored. If no <outfile> is provided, then <infile> is overwritten with the output. If you type a "-" for the <outfile>, BLink will not create an output file. This may be useful if you only want to check that all used routines are indeed present.
Options
-------
BLink has a number of options. The table below lists them, in their command-line form and in their !BLink equivalent. An explanation of their meaning is given further down in this file.
-b React to Blib commands
-e Look for EVAL'ed functions
-h Print a help text about the command syntax (not for !BLink)
-l<files> Include library files
-n Print Basic's line numbers
-r Include REMs before DEFinitions
-t Throwback errors/warnings
-u Report unused DEFs
-v Report on prgress ("verbose")
-vv Detailed progress report ("very verbose")
The format of the input
———————————————————————
When using BLink, the format of your program and libraries should follow these rules:
• The terminating "ENDPROC" (or "=<something>" for a FN) MUST be at the start
of a new line. Anything else will not be recognized by BLink. The reason for
this is that routines are sometimes "aborted", e.g. in case of errors:
INPUT "Enter a number: " a%
IF a% = 0 THEN PRINT "Invalid input!" : ENDPROC
REM rest of processing ...
This implies that you must be careful using libraries that have been treated
with a Basic cruncher: a cruncher usually concatenates lines, so the end of
a routine may not be on the start of a line anymore.
• You must not use any line numbers (GOTOs, GOSUBs etc.) in your program.
• Libraries may contain LIBRARY commands. These libraries will also be read.
• If a procedure is defined more than once, BLink will print a warning
message.
The format of the output
————————————————————————
• LIBRARY commands will be commented out by BLink. That is, after the
library has been scanned, "LIBRARY" is replaced with "REM{".
• The lines that are appended to the main program are renumbered; the
renumbering starts from the number of the last line of the main program,
with an increment of 1.
• Procedures in the main file are always included in the output, whether they
are used or not. If they are not used —— and the "-u" option is on —— then
BLink will print a warning message.
-b = React to Blib commands
———————————————————————————
This makes BLink look for commands in Blib style. ("Blib" is a system of Basic librares, written by Ian Palmer.) The Blib commands supported by BLink are:
*|start
*|stop
*|ifdef, *|ifndef, *|else and *|endif
*|extract
*|!
The Blib commands are not included in the output. If you want the Blib comments (*|!) to be included, use the "-r" option.
Note: you can mix definitions in Blib style (*|start ... *|stop) with standard
PROC/FN definitions.
-e = Look for EVAL'ed functions
———————————————————————————————
When checking which routines are used, BLink normally just scans for calls of PROCs and FNs. However, you can also use a FN by feeding it to EVAL, e.g.
x = EVAL("FNsquareroot(PI)")
With the "-e" option, BLink will look for strings like "FN<something>", with an EVAL preceding it, If such a string is found, this will be taken as a call to that FN.
-l = Include library files
——————————————————————————
Basically, BLink gets the name of the libraries that it should scan from the LIBRARY command. The string that is given after "LIBRARY" is taken as a literal filename. This means that constructions that must be evaluated by Basic, such as
LIBRARY MyDir$+".WimpLib"
won't work; BLink will print a warning message if it finds one. If your program uses this sort of thing, you must use the "-l" option to tell BLink the name of the library.
If there is more than one library of this kind, you can use this option several times on the command line. However, the maximum number of command-line options is 10. If you have a large nuber of small libraries, it is better to put them in a single "-l" option, with commas to separate the file names. For example, instead of
Error messages are printed with the number of the line on which they occur. By default, BLink prints the text-line number. If you want to get the Basic line number, use this option.
-r = Include REMs before DEFinitions
————————————————————————————————————
Sometimes, there are REM lines preceding a definition, describing what the routine does, e.g.:
REM Register as a Wimp task
REM taskname$ = name in Task Manager display
REM function result: task handle
REM
DEF FNwimp_initialise(taskname$)
...
With the "-r" option these REMs are included in the output. The lines are only included if there are no other lines between the last REM line and the DEF that follows.
In combination with the "-b" option (see above), the "-r" option has a different meaning.
-t = Throwback errors/warnings
——————————————————————————————
With this option, BLink will generate a throwback message for each error.
N.B.1: For users of the command-line version: throwback only works if you are running blink in a TaskWindow, or from the *-prompt (via F12).
N.B.2: If you are using !Zap, you should also set the "-n" option on to get the
correct line number in the throwback. For users of !StrongEd, the "-n" option should be off.
-u = Report unused DEFs
———————————————————————
Routines in the main program are always included, even if they are not used. With the "-u" option, BLink will check if the main program contains any such routines, and print a message for each routine that it finds.
Version history
———————————————
1.00 First released version
1.10 Additions:
* prints file names and line numbers with reported errors
* -l options can take list of libnames (instead of single name)
* -b, -e, -n, -t, -u and -vv options
* output can be inhibited with "-" as output name
1.11 Fixed bug that garbled *|Start and *|Stop Blib-commands when found
in main program
1.20 Added front-end application
Copyright notice
————————————————
This program is FreeWare. This means that I retain the copyright. You may freely copy and distribute it, provided that it is complete with all original files, and that you do not sell it. PD libraries may charge a nominal fee for the cost of duplication, postage etc. When you use the program, you do so entirely at your own risk.
Dick Alstein
Lijnslagerstraat 204
5625 BP Eindhoven
The Netherlands
e-mail: wsinda@win.tue.nl (old address, but still works)