Last issue we dealt with how XCHANGE came to be released to Public Domain. As promised, here is the second part of the article written by Gunther Strube & Erling Jacobsen. Owing to the amount of interest shown in this program it was felt that we were doing a service to all XCHANGE users by publishing this information.
XCHANGE occupies 183K of program space. When it has been read from disc into memory (and has begun to run) It allocates half of the available memory for its working space, but never less than 64K. Letting XCHANGE grab 2MB in a 4MB machine is really not necessary. You can force XCHANGE to only allocate a specific amount of working memory by specifying a parameter:
EX flp1_xchange;"120"
would allocate 120K of working memory for XCHANGE. With this facility it has finally been possible to control the unnecessary greed for memory of the PSION programs. The QRAM package contained the ‘Grabber’ utility to control the maximum memory allocation. This is no longer needed with XCHANGE.
The default devices of XCHANGE
The old PSION programs always used a static definition of the default devices, e.g. flp1_ for help information and flp2_ for data files and printer driver information. To alter these parameters you had to use a specific configuration tool and re-save the program file. This is no longer needed with XCHANGE. When XCHANGE is executed it automatically copies the DATA_USE and PROG_USE parameter to the corresponding default data device and help device. If you wanted XCHANGE to fetch its information from particular source on a harddisc, just preset the DATA_USE and PROG_USE parameters before executing XCHANGE. An example:
DATA_USE win1_xch_files_
PROG_USE win1_xch_
The above settings would set the XCHANGE default device to win1_xch_docs_ to fetch documents, etc., and set the help device at win1_xch_. During the usage of XCHANGE you can always specify an explicit filename with a complete path specification, e.g. win1_letters_deal2_doc to save the file ‘deal2_doc’.
The XCHANGE printer driver
The old PSION program used the printer driver name ‘printer_dat’ to identify the current installed printer driver. In XCHANGE the name has been changed to ‘xchange_dat’. On the XCHANGE program disc you will find a utility, ‘Pedit’, to modify and create new printer drivers. The file ‘Printerset_dat’ contains a library of printer drivers. Both an executeable version and source text of the utility is supplied on the disc. The printer drivers is of the same structure as the original ‘printer_dat’ files. You only need to rename them to be used by XCHANGE. Also included on the disc you will find a utility to display the contents of the current printer driver. The utility is named as ‘Prinfo_bas’. In QUILL one tends to use different printer drivers on the same printer to obtain various effects. We have included a utility to quickly exchange one printer driver with another. Please have a look at the ‘Replace_bas’ file. The ‘Prinfo’ and ‘Replace’ should be compiled to obtain the best results, e.g. by putting them under hotkeys (needs HotKey System II installed).
XCHANGE export/import file format
In XCHANGE QUILL and XCHANGE ABACUS you can export and import files with a special ASCII file format. The commands were implemented to transfer QUILL documents or ABACUS spreadsheets between IBM XCHANGE and XCHANGE on the THOR/QL. The two QUILL documents ‘AbacusTransfer’ and ‘QuillTransfer’ describe this format. The ASCII export file format of a QUILL document contains all print types, margin settings, tabulators and text layouts throughout the document. For the first time in the history of QUILL you are be able to write a proper translator to import QUILL documents into other wordprocessors like Text87Plus4 or Perfection without loss of the document layout. This one is for you, Software 87 & Digital Precision.
The XCHANGE Task Sequensing Language (TSL)
One of the new features available to users already familiar with the PSION programs is the TSL in XCHANGE. With that you can program XCHANGE to do all kinds of tasks for you with a TSL (command) file. The TSL file is a simple ASCII (text) file that can be programmed in QUILL (then EXPORTED) or you favorite text editor. Provided on the XCHANGE disc is a set of tutorial files which can be used to learn about the various aspects of XCHANGE or for a study of how the TSL files are made. TSL is a powerful tool for the advanced XCHANGE user. Enjoy the tutorials. Unfortunately the ‘xchange_tsl’ file is missing. Please contact the English XCHANGE User Group (we do not know their address) to get the missing tsl file. They might have more tutorial files for you. Before executing the TSL files you must set the default data device to point at the tsl files. The help device must also be set correctly if you are executing the ‘begin_tsl’ file. All four XCHANGE tasks have tutorials. An introduction of XCHANGE has been provided in the ‘begin_tsl’ file. This will at the end automatically call the ‘menu_tsl’ file which contains a menu selection of which tutorial you might want to execute. To execute a tsl file you must first have defined the default device to the tsl tutorial files. Then activate the <F3> key in the XCHANGE main window to activate the <T>sl command. Specify the filename without the ‘_tsl’ file specififier.
The following is a list of the TSL commands and key codes available in XCHANGE:
TSL key codes:
Many key presses – e.g. ENTER cannot be represented in the simple, direct way. For such cases you use special codes surrounded by square brackets. The full set of codes is shown in the following table. Bear in mind that each member of the Xchange family does not use every code in this list.
[CR] Carriage Return (Enter) [esc] Escape [sp] Space [f1] .. [f10] Function key 1 .. 10 [tab] Tabulator (Tab) [btab] Backward tabulator (SHIFT TAB) [lt] Move cursor leftward [rt] Move cursor rightward [up] Move cursor upward [dn] Move cursor downward [wlt] Move cursor one word leftward [wrt] Move cursor one word rightward [bpr] Move cursor to beginning of current paragraph (SHIFT up) [epr] Move cursor to end of current paragraph (SHIFT down) [eln] Move cursor to end of current line (END/ALT right) [bln] Move cursor to beginning of current line (HOME/ALT left) [dlt] Delete one character leftward (BACKSPACE/CTRL left) [drt] Delete one character rightward (DEL/CTRL right) [dwlt] Delete one word leftward (SHIFT BACKSPACE/CTRL SHIFT left) [dwrt] Delete one word rightward (SHIFT DEL/CTRL SHIFT right) [dbln] Delete to beginning of line (SHIFT HOME/CTRL ALT left) [deln] Delete one word rightward (SHIFT END/CTRL ALT right)
The TSL commands is available:
&c The remaining text on the line is a comment. The text is ignored when the
tsl program is running, e.g. :
&c This is a comment
&d Display text in the XCHANGE control area (top window). E.g.:
&d Press any key
The text will only be shown if the TSL text display is enabled (see &p).
&e The end-of-program statement.
This will terminate the tsl command file status. Control is returned to
keyboard command input.
&g Get character - wait until a key is pressed from the keyboard.
The key pressed may be tested by &= .
&i Wait for text to be typed at the keyboard.
The text, terminated by pressing ENTER, is passed to the XCHANGE task.
Use this command when tsl is programmed to cater for various input, e.g.
typing of files names when XCHANGE prompts for them in acivated commands
by tsl. E.g.:
[f3]nqui[cr]qtmp[cr] Create a new quill task [f3][f3]s[cr]
search from current position &i
input of string
&j Jump to the point in the program marked by the following label.
Please note that a label must begin with the '@' symbol at the beginning
of the line. With this facility it is easy to implement loops:
@loop_identifier
tsl command ...
&j loop_identifier
&p Enables or disables the display of text in the control area (using the &d
command). The following parameters is used:
&p 1 enables display. This is the intial state of TSL.
&p 0 disables display, allowing the normal control area
contents to be shown.
With &p 0 all &d commands will be ignored. &p 1 is also useful just to
clear the control area.
&x Wait for predefined letter/symbol to typed at the keyboard. The following
parameter would define which key need to be typed for the command to
succeed (and TSL to execute the next command). This command distinguishes
between upper and lower case letters.
&y Same as &x, but letters are case independent.
&w Wait for the following number of tenths of a second. To halt tsl
execution for two seconds use &w 20.
&= c label Jump to the point in the TSL program marked by the following
<label>, if the specified character <c> is equal to the one pressed in
response to the most recent keypress. E.g. :
&= q quill would be executed to jump to the label '@quill' if the lower case
letter 'q' were pressed from the keyboard (using the &g command). Please
note the the special key codes are may be used.
TSL labels A label marks a point in the TSL program as a destination for a
jump (by a &j or a &= command). The label must start with a @ symbol
followed by a sequense of letters defining the label name, and must be
the first and only item on that line. You must not include the leading @
symbol when you refer to the label in an &j or &= command.
Symbols The following characters/symbols have special meaning:
& marks a command @marks a program label [starts a special key code ]ends a
special key code ^the following character becomes a normal one. This
allowes you to use any of the above without its special meaning:
^& ^@ ^[ ^] ^^
An example of a TSL program
The following example shows a simple TSL program. You could create the program with almost any text editor, provided that it has the ability to produce a file comtaining plain text, without embedded control characters, and with a LF (line feed) or a CR (carriage return) character at the end of each TSL command line. If you use QUILL to write the program you should use the Export option of the Files command. Please remember to explicitly specify the _tsl extension otherwise an _exp is used as default.
[f3]neas[cr]Salepc[cr]
&p 1
&d CST THOR PC with the powerful TSL language
&d could be used to display sales curves...
&d
&w 80
salgz88=1000+800*cos(cell/4)
[cr]
salgthor=1000+500*sin(cell/4)
[cr]
[f3]v[cr]3[cr]
[esc]
&p 0
[f2]
&e
Compatibility of Archive Object programs (_pro file format)
The XCHANGE ARCHIVE object file format differs from the original QL ARCHIVE object format. To load QL ARCHIVE programs into XCHANGE ARCHIVE you have load them as ASCII files (_prg file format). You can then re-save them with the <object> option.
Machine code interface in XCHANGE ARCHIVE
In XCHANGE ARCHIVE it is now possible to execute MC6800 machine code. With this option you have the ability to exploit QDOS from ARCHIVE. This should give you the possibility to use graphics and sound within your ARCHIVE programs. It is interfaced to an ARCHIVE program be means of an additional usr() function and a usr qualifier to the load program command.
The machine code must be relocatable, that is, it must use only PC-relative addressing modes. In addition to the code, the file must contain a six-byte header. Bytes 0 to 3 must contain “pcm0” and bytes 4 and 5 must be a word given the length of the following code. It is the user’s respsonsibility to ensure that the file has the correct header. The machine code program (in image form, exactly as it would appear in memory) must follow the header, with its entry point at the byte immediatly following the header. The code must end with a return from subroutine (RTS) instruction.
To load the machine code module into XCHANGE ARCHIVE, it is necessary to use the load command:
load usr <s.expr>
where <s.expr> is a string expression which evaluates to the file name. Unless an extension is explicitly included in the filename, the default extension of _pmc is assumed. After having been loaded, the machine code may be executed with the numeric function:
usr(<n.expr>,<s.expr>)
The first argument is converted to an integer and loaded into register d0 before jumping to the entry point of the machine code. You may use this value in any way you please but the the intension is to provide a facility to vector one of a number of different routines in the machine code. In this sense the argument becomes a function number. The second argument is a string expression which must evaluate to the name of an existing ARCHIVE string variable. All XCHANGE ARCHIVE string variables have a leading length byte. The usr() function transfers the address of this length byte to address register A0 before juming to the code.
After having allocated a string variable, e.g. a$, the corresponding usr() call might be:
let res = usr(2,"a$")
On the return from the machine code routine, the contents of register d0 are converted to ARCHIVE’s floating point form and returned as the value of the usr() function. The second argument can clearly be used to pass information in either direction between ARCHIVE and the machine code routine. It is your responsibility to ensure that the machine code does not write to any memory location outside the region allocated to the string (the length byte should be regarded as being outside this region). The machine code may make free use of the registers; the usr() function preserves and restores all registers automatically across the machine code.
It is not possible to specify exactly the space available on the stack, but it will typically be of the order of 1K. You should therefore avoid excessive use of the stack, such as for large buffer areas or for heavily recursive processes.
The following is an example of how to have a 32K binary startup screen for an ARCHIVE application:
HEADER: DC.B "pmc0"
DC.W SCRDATA - START + #32768 ; code & screen image
; Machine code to move image to screen memory
START: MOVE.L #131072,A0 ; A0: ptr to scr. memory
LEA SCRDATA(PC),A1 ; A1: ptr to scr in buffer
MOVE.L #32767,D1 ; D1: size of scr. LOOP:
MOVE.W(A1)+,(A0)+ ; move image to scr memory
DBRA D1, LOOP
RTS ; Return to ARCHIVE.
SCRDATA: DS.B #32768 ; screen image from here...
END
As seen in the above source text it is necessary to store the screen image right after the machine code. The code is then saved as a whole, ready to be loaded into ARCHIVE (machine code + 32K).
END