home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Archive Magazine 1997
/
ARCHIVE_97.iso
/
text
/
hints
/
vol_10
/
issue_09
< prev
next >
Wrap
Text File
|
1997-08-11
|
10KB
|
237 lines
Hints and Tips
10.9
Address list editing Ö I love playing with text, trying to manipulate
it using a combination of packages Ö usually Edit, StrongED and
PipeDream Ö to achieve certain ends. If I had time, Iæd write an
article about it, but as an illustration of the sort of thing I mean,
hereæs an example of what can be achieved.
10.9
The problem: I had 8,000 addresses of various lengths Ö up to nine or
ten lines which had to be printed onto continuous label stationery, i.
e. with each label starting at exactly nine-line intervals, so no
label had to be longer than eight lines of text.
10.9
The solution: This consisted of a number of separate tasks:
10.9
1) make each address a single line of text
10.9
2) sort out the over-long addresses and shorten them
10.9
3) make every address exactly eight lines
10.9
4) put each address back into multiple lines of text
10.9
1, 2 and 4 are easy enough, but I first thought that the only way to
cope with different lengths of label was to write a Basic program,
but then I suddenly realised how to do it. Anyway, hereæs the full
recipe:
10.9
1) In Edit (because I find StrongED a little slow when doing S&R on
very large files Ö sorry Guttorm!), S&R all double returns (\n\n)
into xzxz, change all returns into tabs (\x09), and change all xzxz
into single returns.
10.9
2) Drop the resulting file into PipeDream. The number of columns is
then the number of lines of the longest address. So if the last
column is j, sort the whole text on column j, with a secondary sort
on column i. This will bring all the too-long lines to the top of the
file. Now drop the file back out into Edit or StrongED and
concatenate (good word, that!) parts of the over-long addresses so
that they each only have eight lines max.
10.9
3) Drag the file back now into PipeDream and check that no lines
spill over into column i. Check also that the addresses that fit all
eight columns are at the top of the file. Go to the first address
that does not extend into column h and enter öxzxzò into the box in
column h. Copy this box down to the end of the file. Drop it back
into Edit and use S&R to remove all occurrences of xzxz, and all
addresses now have exactly eight lines!
10.9
4) Continuing in Edit, use S&R to change all returns (\n) into xzxz,
then all tabs (\x09) into returns (\n) and finally all xzxz into
double returns (\n\n).
10.9
If you want to do a final check to see that all the addresses start
at exactly 9-line intervals, drop the text into StrongED (youæll see
why in a minute!) and open up the height of the window to exactly a
whole number multiple of nine lines of text. A few clicks inside the
scroll bar, to move down a screen at a time, will show if it is
creeping up or creeping down each click. If it is exactly right (and
this is easier to achieve in a lower resolution screen mode), you can
click and hold inside the scroll bar and it will auto-repeat a
screenful at a time, right to the end of the file. (Edit doesnæt auto-
repeat mouse clicks, so 8,000 addresses at eight addresses per click
= 1,000 clicks = RSI in my mouse-finger!)
10.9
(Oh, Iæve just thought Ö you could use Edit because the <page-down>
key has the same effect, and that does auto-repeat!)
10.9
The challenge: If you have a text editing job to do and would like me
to have a go at it, do get in touch. (a) I enjoy this kind of
challenge and (b) the solution, like the one above, might help others
in doing their text-editing jobs.
10.9
(If you want more help on this sort of thing, Jim Notttingham did an
excellent series on text editing in issues 8.3p63, 8.4p43, 8.5p15, 8.
8p64 and 9.1p57. Gosh, was it that long ago?!)
10.9
Ed. <paul.NCS@paston.co.uk>
10.9
Background printing Ö I have had, for some time, two Printer icons on
the iconbar. One is set up to print to a file Ö the one that is
always selected Ö and the other is set up to print to the printer.
10.9
I used to print to a file by default, but then I had to look around
for the printfile, to drag it to the other printer icon, in order to
print in the background.
10.9
Now I have the printfile stuck to the backdrop near the Éprint to
printeræ icon, so dragging the printfile to the printer icon is now
the work of a moment! Obvious really Ö but only if the idea happens
to occur to you. (Or if you read it in Archive! Thanks for that,
Barry Ö so come on, folk, send in the Éobviousæ tricks that save you
time. Ed.)
10.9
Barry Allen <barrya@dean.nwnet.co.uk>
10.9
Exiting from CASE...ENDCASE Ö The CASE...OF..WHEN..OTHERWISE...
ENDCASE construct, introduced in version 1.04 of Basic, provides a
very powerful means of writing structured programs. The CASE
construct consists of a number of WHEN statements followed by one or
more values or expressions to be matched. Whenever the result of the
CASE expression matches one of the values listed after the WHEN, all
statements following this WHEN are executed, down to the next WHEN,
OTHERWISE or ENDCASE. The Basic interpreter then skips to the
statement following the ENDCASE, and continues with the rest of the
program. For this reason, the WHEN, OTHERWISE and ENDCASE keywords
must each start at the beginning of a line.
10.9
So far, I have described the normal use of the CASE...ENDCASE
construct. However, there are situations where the WHEN part consists
of many statements, mostly occupying separate lines. In such cases,
it is possible that other constructs such as IF...ENDIF or REPEAT...
UNTIL are used inside a WHEN part, and a means to exit from the WHEN
construct is required, so that the program continues after the
ENDCASE statement.
10.9
Basic provides a means to exit from a CASE...ENDCASE construct using
the keyword WHEN.
10.9
Here is an example:
10.9
10 check%=7
10.9
20 test% =0
10.9
30
10.9
40 CASE test% OF
10.9
50 WHEN 0:
10.9
60 IF check%=7 THEN PRINT ö1st checkò
10.9
70 IF check%=7 THEN PRINT ö2nd checkò
10.9
80 IF check%=7 THEN PRINT ö3rd checkò
10.9
90 ENDCASE
10.9
Running the above program will produce the following on the screen:
10.9
1st check
10.9
2nd check
10.9
3rd check
10.9
All three lines are, of course, printed. If you want to terminate the
WHEN part after the first check (at line 60) and skip lines 70 and
80, then you replace line 60 with the following:
10.9
60 IF check%=7 THEN PRINT ö1st checkò:WHEN
10.9
70 IF check%=7 THEN PRINT ö2nd checkò
10.9
80 IF check%=7 THEN PRINT ö3rd checkò
10.9
90 ENDCASE
10.9
By adding a WHEN keyword, the Basic interpreter will terminate the
WHEN part and close the ENDCASE construct after line 60 (i.e. the IF
matching part). So, running the program with line 60 changed will
produce the following result:
10.9
1st check
10.9
Lines 70 and 80 will be skipped.
10.9
The above use of WHEN to close an ENDCASE construct is, to my
knowledge, undocumented although the Basic Reference Manual does
describe or hint at its use. Using the keyword OTHERWISE in place of
WHEN for early exits also seems to give the same results!
10.9
Mohsen Alshayef <mohsen@qatar.net.qa>
10.9
Magazine storage Ö I see that Archive storage is still a topic of
concern (10.8 p27). How about cutting down A4 racks? The magazines
fit long-side in (because A5 = half-A4), but you can put them on the
shelf either way. This is particularly useful for wire-bound manuals
that just will not fit a normal A5 box, and a suitable cut provides a
housing for Acorn manuals that otherwise fit too tightly in the
supplied box. You may think cutting down is wasteful, so buy the
cheapest, which I believe are IKEAæs PENG at ú3 for eight. These are
the plainest brown card with no printing, and can also make useful
trays for other odds and ends.
10.9
Steve Drain <steve.d@virgin.net>
10.9
Neat screenshots (again) Ö Hereæs another offering spurred by the
comment in Archive 10.7 p20. It is !GrabMenu by Cy Booker and it
allows you to grab menus that are transient. Hereæs an example of
what it can do.
10.9
Itæs worth reading the !Help file that comes with it as itæs a bit
quirky and not all that intuitive to use.
10.9
Jim Nottingham <email via NCS>
10.9
StrongARM speed-up Ö I was particularly interested in the StrongARM
upclocking article (10.8 p19) as I tried this out some months ago and
Iæve sent Paul the various programs, tests and charts that Iæve
compiled which may be of interest to readers. (On the monthly program
disc.) This is also available from the Acorn Cybervillage FTP site
at:
10.9
ftp://ftp.cybervillage.co.uk/pub/acorn/info/
10.9
My StrongARM also runs cool at 287MHz, but it was very slightly flaky
at this speed. However, I think it is more to do with the PC card and
StrongARM not wanting to work together at that speed. (I wasnæt
actually running the PC card, you understand, but it does continue to
operate in an idle mode even when not being used.)
10.9
Iæd also recommend that people with a PC card and a upclocked
StrongARM use the PCsleep application as this powers down the PC card
and thus reduces the internal temperature of the RiscPC.
10.9
Stuart Halliday <stuart@quantumsoft.co.uk>
10.9
On the program disc, Iæve put Stuartæs tests for speed and memory
integrity, plus some things sent in by Tony Hopstaken, who was the
person quoted last month at the end of Robertæs article. Ed.
10.9
StrongARM speed-up (2) Ö Various people have mentioned the fact that
Robert suggests using a piece of anti-static bag as an insulator, but
the idea of these bags is that the inside surface is slightly
conductive. It would be much better to use simple dry cardboard.
10.9
A number of other people, like Tony and Stuart, are running
StrongARMs at higher speeds without any extra cooling at all and
donæt seem to be having any problems. However, we cannot, by
definition, know what the long-term effect is, i.e. whether the life
of the chip will be reduced. Still, as Tony says, öAs long as it
lasts until my RiscPC II arrives, I donæt mind!ò
10.9
Ed. <paul.NCS@paston.co.uk>