home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Archive Magazine 1996
/
ARCHIVE_96.iso
/
text
/
hints
/
volume_01
/
issue_10
< prev
next >
Wrap
Text File
|
1995-02-16
|
15KB
|
424 lines
Å BASIC Editor. If you type öEDIT.ò instead of just öEDITò, it gets
you back into the editor at the same place you left it. This can be very
useful when editing long programs. It even seems to work if you load and
save other programs in the interim as long as you get the original
program back into memory. Also, you can say EDIT Fred and it will take
you to the first occurrence of the word öFredò in the file. So, with
judicious use of REM statements, you can jump into the program at just
the right place every time. If you want to find DEFPROCfred, EDIT fred
will probably bring you to PROCfred rather than the definition itself,
but REM !FRED above the top of the procedure would allow you to type
EDIT !FRED (note, all uppercase, which is easier to type) to drop you
straight to the desired place in the program.
1.10
Å Artisan ÿ fast load and save. If you have typed in the Fastload/Save
module from the March issue of Archive, *COPY FastRm onto the Artisan
disk and then LOAD öART3ò, list line 270 and add *RMLOAD FastRm|M and
then re-save it. Now LOAD öART5ò change line 2540 to OSCLIöFastLoad ò+f$
and line 2620 to OSCLIòFastSave ö+f$. Then re-save it. You now have a
new and improved disc facility for Artisan.
1.10
Å 305, 310, 410 or 440? Following on from the hint in the May issue
(page 7) it╒s all very well to know what the page size is, 8k or 32k,
but to differentiate between a 305 and a 310 or between a 410 and a 440,
you need to know how much memory is available. One way of doing this is
to set up a local error trap and do a *Configure Spritesize 128. If the
machine has 1 Mbyte or less it will generate a öConfigure parameter too
bigò error. If it still generates an error when you use *Configure
Spritesize 64 then the software knows it is running in a 305. We have
not had chance to check this on a 305 or a 410, so please will someone
let us know if it does not work.
1.10
Å System DeltaPlus. If you want to use two drives, issue the following
two commands from the card index:
1.10
*dir :1
1.10
*set Delta$WPPrefix :0.$
1.10
Then don╒t specify the drive number in the data file name.
1.10
Å View 3 & Viewstore 1.1. Various folk are still having problems with
these. If so, try the following as suggested by Sean Kelly ÿ thanks.
1.10
Viewstore 1.1. Locations &ABE2, &ABE3 and &ABE4 should all be set to the
value &EA.
1.10
View 3. Set locations &A8D6, &A8D7 and &A8D8 to the value &EA. Also,
there are four places where you get LDA#&82, JSR Osbyte (i.e. &A9, &82,
&20, &F4, &FF). This is used to check for the second processor on the
BBC. So to fool it, you have to change each of these to: LDX#&FF,
LDY#&FF, NOP. You can either do this by poking &A2, &FF, &A0, &FF, &EA
into each of the sets of locations: &8834 to &8838, &88D8 to &88DC,
&895C to &8960 and &AF8D to &AF91. (I checked these locations against
the B3.0 version in the Master 128╒s and it bore no resemblance to it.
Apparently it refers to the A3.0 version. Ed.)
1.10
Å Improved sound. If you have the colour monitor that comes with the
Archimedes, you can use the Audio Input at the back of the monitor (a
phono socket) to take a signal from the Headphones output (3.5 mm stereo
jack) from the Archimedes. Just use one of the channels or combine them
with 100R resistors. (If you╒re not quite sure how to do this, we╒ll try
to give more details next month.) This give a much better sound and
provides you with a volume control.
1.10
Next two hints are from Peter Kiggins╔
1.10
Å When using a SWI from BASIC which either takes or returns a string,
it is not necessary to use pointers to strings. The SYS command knows
that a pointer has been returned by the SWI and copies the relevant text
into the string. For example, instead of
1.10
$TxtPtr%=Number$
1.10
SYSöOS_ReadUnsignedò,FromBase%,TextPtr% TO ,,Decimal%
1.10
you can use the more readable and easier
1.10
SYSöOS_ReadUnsignedò,FromBase%,Number$ TO ,,Decimal%
1.10
And to read the command line which started the program, all thatæs
required is
1.10
SYS öOS_GetEnvò TO Command_line$
1.10
Å BASIC commands TWIN and TWINO can be used without Acornæs (editor)
TWIN. How? When TWIN is executed, BASIC first converts the current
program from internal tokenised format to plain text format; then it
calls TWIN with the location of the text as a command line string. So
all that is required is a program called TWIN which reads the command
line and saves the relevant chunk of memory:-
1.10
10 REM >twin
1.10
20 REM*** fails with very short pieces of text ***
1.10
30 SYS öOS_GetEnvò TO command_line$
1.10
40 posat%=INSTR(command_line$,ö@ò)
1.10
50 poscomma%=INSTR(command_line$,ö,ò,posat%)
1.10
60 possemic%=INSTR(command_line$,ö;ò,poscomma%)
1.10
70 start$=ö&ò+MID$(command_line$,posat%+1,poscomma%-(posat%+1))
1.10
80 finish$=ö&ò+MID$(command_line$,poscomma%+1,possemic%-(poscomma%+1))
1.10
90 INPUTöEnter file name: ò file$
1.10
100 OSCLI(ösave ò+file$+ö ò+start$+ö ò+finish$)
1.10
110 OSCLI(ösettype ò+file$+ö &FFFò)
1.10
The point of all this is that the BASIC Editor can now be used to
produce text files ÿ for wordprocessing, compiling, etc.
1.10
Å Auto-Booting ÿ some of the commercial auto-boot programs donæt take
into account the filing system! This can be very annoying if you have a
ROM podule and your system is set to start up in the RFS. The answer is
(i) the software developers should produce proper auto-boot programs; or
(ii) if you already have bought a program ÿ put *CON.FILE.ADFS in auto-
boot program!
1.10
Hard Disc Auto-Booting ÿ some readers are lucky enough to have hard
discs. However, life with a hard disc is not all a bed of roses! Having
copied your application programs to the hard disc, you run into problems
with the auto-booting routines. Here is a one of many possible solu
tions. Indeed this program could be used for those of us with floppies,
who have more than one application on a disc.
1.10
10 REM >$.!BOOT
1.10
20 REM **************************
1.10
30 REM * Multiple Auto-Booting *
1.10
40 REM * written by Adrian Look *
1.10
50 REM * 22nd June 1988 *
1.10
60 REM **************************
1.10
70
1.10
80 SYS öOS_Byteò,161,16 TO ,,misc_flags
1.10
90 auto_boot=(misc_flags AND %10000)
1.10
100 file$=öbootò
1.10
110 file=OPENIN(file$):CLOSE #file
1.10
120 IF file=0 THEN PROCmenu
1.10
130 file=OPENIN(file$)
1.10
140 INPUT #file,boot$
1.10
150 CLOSE #file
1.10
160 IF auto_boot THEN OSCLI(öREMOVE ò+file$)
1.10
170 OSCLI(öRUN ò+file$)
1.10
180 END
1.10
190
1.10
200 DEFPROCmenu
1.10
210 REM **** your own code ****
1.10
220 REM
1.10
230 REM should exit with file$
1.10
240 REM containing the filename
1.10
250 REM of the program to be run.
1.10
260 REM
1.10
270 REM e.g. PRINT #file,filename$
1.10
280 ENDPROC
1.10
The program checks whether a file (file$) is on the disk. If it is, then
the program reads the filename contained in file$ and runs it! Other
wise, the program should create file$ ÿ as indicated.
1.10
This method also allows you to write library programs which will: create
file$ and then run the boot program. Thus by running these library files
you can also initiate your application programs ÿ without the need for a
menu!
1.10
Å Quazer Fix. If you are using Quasar 1.40, here is a cheat, (for
those who like such things!) which allows you to keep going a bit
longer. Firstly, *LOAD QuazCode 9000 and then rename Quazcode as, say,
OldCode. Now if you want to set the number of lives, you need to change
location &3D058. It should currently contain 2, so to change the number
of lives to, say 10, put ?&3D058=10. Now if you want to avoid being
killed when you collide, change the contents of location &3D90B from &E2
to &F2 by puting ?&3D90B=&F2. Finally, *SAVE QuazCode 9000 +36520.
1.10
ÅPasswords if you want them. Quazer Passwords: 2 Lizards, 3 Spiders, 4
Pedantic, 5 Analysis, 6 Larkin, 7 Company, 8 Manual,9 Trading
1.10
Hoverbod passwords: 2 Minervas, 3 SirBarry, 4 ZotyBlob, 5 Flumpies, 6
Squidgee, 7 Wobblies, 8 Posskett
1.10
1.10
The following Hints & Tips were sent in by Mike Harrison (of Watford
Digitiser fame). He╒s also sent us various other bits of information
which appear elsewhere in this issue and the next issue. Many thanks
Mike.
1.10
Writing modules
1.10
(Ref. issue 5, page 45) SWIs in modules must always use the ÉXæ version
of the SWI and, where appropriate, check for an error and exit,
preserving the value of r0 returned by the SWI (i.e. donæt restore the
old value of R0 if it had been saved). e.g.
1.10
.a_module_routine
1.10
STMFD R13!,{r0-2 ,14} \or however many registers you need to save
1.10
SWI öXOS_SomethingOrOtherò
1.10
STRVS R0,[R13] \overwrite old r0 with error pointer
1.10
LDMVSFD R13!,{r0-2 ,PC}
1.10
\ the last 2 statements could alternatively have been :
1.10
\
1.10
\ ADDVS R13,R13,#4 : LDMVSFD R13!,{r1-2 ,PC}
1.10
For short routines, or where several SWIs are used, the following is
neater..
1.10
.a_short_routine
1.10
STMFD R13!,{r0-5 ,14}
1.10
SWI öXOS_SomeSwiò
1.10
SWIVC öXOS_SomethingElseò
1.10
SWIVC öXOS_YetAnotherSwiò
1.10
STRVS R0,[R13]
1.10
LDMFD R13!,{r0-5 ,PC}
1.10
In this example, all code after first SWI should be conditional on V
clear, so if any SWI gives an error, the code will Édrop throughæ to the
end.
1.10
Remember that some SWIs may return errors you donæt expect ÿ e.g.
OS_WriteC could return an error when output is *Spooled, setting the
screen mode could give ÉBad Modeæ etc. ÿ some thought is required to
ensure that module code will be reliable in all environments.
1.10
When setting up offsets in headers and command tables, it is much easier
to specify them when using offset assembly (OPT 4/6/7) ÿ set O% to the
code buffer, and P% to 0. Offsets can then be included directly with
EQUD (e.g. EQUD moduletitle). Warning ÿ if you are still using Basic
1.00, there is a bug in ALIGN when using offset assembly. Version 1.02
is OK.
1.10
The following assembler macro is useful when building keyword tables in
modules (it assumes the use of offset assembly, as described above):
1.10
DEF FNcommand(I%,A$)
1.10
[ OPTpass : EQUS A$ : EQUB0 :
1.10
ALIGN
1.10
EQUD EVAL(A$)
1.10
EQUD I%
1.10
EQUD EVAL(A$+ösyntaxò)
1.10
EQUD EVAL(A$+öhelpò)
1.10
]:=pass
1.10
OPT FNcommand(öNewCmdò,N) will create a table entry, using the labels
.NewCmd .NewCmdhelp and .NewCmdsyntax (N is the information word).
1.10
Note that Épassæ is the name of the pass variable ÿ change this if you
use a different name.
1.10
Podule manager/Clock slowdown
1.10
(Ref. issue 7, page 44) The problem here is that SWIs are passed to
modules with interrupts disabled, so if the SWI takes a significant
amount of time to complete, the clock will slow down (the mouse pointer
will also become sluggish). I canæt see why the podule manager should
need interrupts off, so itæs probably an unintended Éfeatureæ ÿ SWI code
which takes time to execute SHOULD enable interrupts, unless they have
to be off. (The digitiser module only runs with interrupts off when
absolutely necessary!) When interrupts have been disabled for signifi
cant amounts of time, the seconds count of the real-time clock gets out
of step with the minutes, which then donæt roll over at 59 secs ÿ this
looks weird if you donæt know about it!
1.10
System Devices
1.10
(Ref. issue 6, page 41) There is a very interesting feature, which I
havenæt seen documented, concerning device oriented filing systems. When
you set the printer type using *FX5,n where n is greater than 2, the OS
looks for a system variable called printertype$n ÿ n being the value
used for FX5. This variable holds the name of the output file or device
to which printer output should be sent. The Econet module, NetPrint,
uses this to set printer type 4 to önetprint:ò. What happens is that
when you do <ctrl-B>, a file is opened, with the name given in this
system variable, and <ctrl-C> closes the file. While this would normally
send output to a hardware device, it can also use the name of a normal
file; e.g.
1.10
*set printertype$5 outfile
1.10
*fx5 5
1.10
Will cause subsequent printer output to be written to the file öoutfileò
ÿ handy for debugging, and for saving data to print on other machines.
Note that this will only work if a program does VDU2, sends ALL its
output, then does VDU3. If it keeps turning the printer on and off all
the time with VDU2/3, only the last part of the output will be in the
file, as VDU2 re-opens the file, discarding its previous contents.
(Econet users know only too well the problems caused by software not
handling the printer correctly!)
1.10
Just for fun, try :
1.10
*set printertype$5 vdu:
1.10
*fx5 5
1.10
<Ctrl-B>
1.10
All vdu output will appear ttwwiiccee!! ÿ once via the normal route, and
again via the printer stream.
1.10
Use of SYS
1.10
(Ref. issue 9, page 47) The following is a bomb-proof version of OSCLI
in BASIC, which will report errors without entering BASICs error handler
(it can also be used for other SWIs ÿ e.g. OS_File to trap filing errors
neatly)
1.10
DEFPROCoscli(OS$)
1.10
LOCAL flag%,error%
1.10
SYSöXOS_CLIò,OS$ TO error% ; flag%
1.10
IF flag% AND 1 THEN P.öError : ò;:SYSöOS_Write0ò,error%+4
1.10
REM the error number can be read using !error%
1.10
ENDPROC
1.10
It works by reading back the V flag and error pointer returned by the X
version of the SWI
1.10
TWIN
1.10
(Ref. issue 7, page 7) You can warm start Twin using *Twin -warm, using
the same version of Twin, of course ÿ *GO may cause problems if the code
has been corrupted, (or youæve forgotten the address!). There is a bug
in all the versions of Twin Iæve seen (Iæm not sure what version has
been released), which means that when exiting from TWIN to BASIC, the
event vector is messed up, so if you overwrite the address where Twin
was run, and enable events, the machine crashes. This can be avoided by
doing QUIT, *BASIC, and OLD.
1.10
In one issue, there was a tip for entering ARMBE automatically at the
line in error ÿ hereæs a similar routine if you prefer using TWIN to
edit BASIC programs ÿ It uses the TWINO8 option to strip line numbers
(which you donæt need to use, DO YOU!!). If the error wasnæt Escape,
pressing <Y> will enter TWIN at the line where the error occurred. Note
that it assumes lines are numbered in 10s ÿ this will be the case if the
program has been edited in TWIN without line numbers, but not if lines
have been inserted/deleted from the BASIC prompt ÿ in this case, enter
TWIN, and exit again, or do RENUMBER.
1.10
ON ERROR PROCERR
1.10
...
1.10
...
1.10
DEFPROCERR
1.10
REPORT:PRINTö at line òERL
1.10
IF ERR=17 END
1.10
PRINTöEDIT ?ò:IF GET$=öYò ELSE END
1.10
*FX138 0 129
1.10
*FX138 0 128
1.10
FORA%=1 TO LEN(STR$(ERL DIV10))
1.10
SYS 6,138,,ASC(MID$(STR$(ERL DIV10),A%,1))
1.10
NEXT:*FX138 0 13
1.10
END
1.10
Hidden software
1.10
(Ref. issue 9, page 4) Take a close look at the digitiser module!
1.10