The second example (EX2.BAS) is a general purpose screen dump displaying program, using a parameter file to control its action. Note how variables are INPUT from the data file, with the EOF function allowing automatic variation in the size of the file. It is important that the screen dump displayed by this program was saved with the screen in a known position in memory, otherwise the result will be 'skewed'. This is ensured by the saving program executing a MODE command and thereafter being careful not to cause the screen to scroll.

10 DIM colour(15) : REM Provision for 16 colours

20 OPENIN “param.dat”

30 INPUT #9,filename$,screenmode

40 i=0

50 WHILE NOT EOF

60 INPUT #9, colour(i)

70 INK i, colour(i)

80 i=i+1

90 WEND

100 CLOSEIN

110 MODE screenmode:BORDER 0

120 LOAD filename$

2.4.2 Pre-empting a Garbage Collection.

If the program performing data file transactions has a number of string variables, particularly string arrays, it will speed the OPENing of files if the computer is persuaded not to perform a garbage collection at that time. Garbage collection is the process by which the BASIC clears away and tidies up the memory space used for strings in order to dynamically allocate a buffer for the file transfer.

If a program does indeed operate a number of string variables and arrays, incorporate the lines below into the program, and a file buffer will be permanently allocated, which will prevent garbage collection when subsequent files are opened. Note that the lines below should be incorporated after any SYMBOL AFTER commands in the program.

OPENOUT "DUMMY"

MEMORY HIMEM-1

CLOSEOUT

2.5 Reference guide to AMSDOS commands.

Refer to Chapter 8 in your CPC464 User Instruction manual if you are in any doubt about the notation used, or the effect of particular commands when used with cassette.

AMSTRAD Disc Drive & Interface DDI-1 Manual

Chapter 2. 6

Page 40
Image 40
Amstrad DDI-1 manual Reference guide to Amsdos commands, Pre-empting a Garbage Collection, While not EOF, Wend Closein