29.12.2012 Views

spectrum utility - OpenLibra

spectrum utility - OpenLibra

spectrum utility - OpenLibra

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Alphabetical order<br />

Dear David,<br />

I have programmed a list of articles<br />

in random order, and can<br />

interchange to get the lowest in<br />

alphabetical order to be first in<br />

the list. But I cannot work out<br />

how to get the whole list into<br />

alphabetical order. Please can<br />

you help.<br />

Mrs HG Blackwood,<br />

Fife, Scotland<br />

Dear Mrs Blackwood,<br />

The listing you send me requires<br />

little change to complete the<br />

sort; using your line numbers,<br />

variables and basic routine, here<br />

is the complete sort routine:<br />

190 FOR i = 2 TO n-1<br />

200 FOR k = iTO n<br />

210 IF n$(i-1 J n$|k) THEN<br />

GOTO 250<br />

220 LET t$ = n$(k)<br />

230 LET n$(k) = n$(i-1)<br />

240 LET n$(i-1) = t$<br />

250 NEXT k<br />

260 NEXT i<br />

CLEARing<br />

Dear David,<br />

Although I have a 48K Spectrum,<br />

I sometimes find that a<br />

long program will not load after<br />

NEWing a previous program.<br />

Pulling out the power lead and<br />

replacing it is the only way of<br />

resetting the machine that I'm<br />

aware of. ts there a simpler<br />

way?<br />

Ctive Williams,<br />

Staines<br />

Dear dive.<br />

You can reset the Spectrum by<br />

using the direct command:<br />

RANDOMISE USR 0; this effects<br />

the same ROM routine as<br />

used by the computer when it is<br />

first powered-up. The same<br />

(SINCLAIR SOLUTION!<br />

David Nowotnik answers your questions<br />

command (RAND USR 0) will<br />

also 'warm start' the ZX81.<br />

Decimal places<br />

Dear David,<br />

I have recently bought a 48K<br />

Spectrum, and wish to employ it<br />

to help me with my Open University<br />

Maths Foundation course.<br />

Can I make the Spectrum work<br />

to a fixed decimal place, and<br />

preferably a corrected decimal<br />

place?<br />

Barry Murfett,<br />

Hyde, Cheshire<br />

Dear Barry,<br />

The answer is 'yes', but it isn't<br />

that simple. The Spectrum<br />

doesn't have a print formatting<br />

command (PRINT USING/<br />

available on some other micros,<br />

so you have to write a short<br />

subroutine to do this. The listing<br />

is too long for the Problem Page,<br />

so /put it in the post to you. For<br />

other readers who want to solve<br />

this problem, the strategy for it<br />

is as follows:<br />

• Divide the number into its integer<br />

and fractional parts with<br />

the INT command,<br />

• Multiply the fractional part by<br />

10 to the power of n, where n is<br />

the number of decimal places,<br />

add. 5 (to round it), and take the<br />

integer.<br />

• Place both halves of the<br />

number into strings (S TR$), pad<br />

out with zeros, as necessary,<br />

then combine the two strings<br />

with a decimal point between<br />

them. Then print the string, or<br />

use VAL if you want to work on<br />

the number some more.<br />

Draughts<br />

Dear David,<br />

I am looking for a draughts program<br />

for my 48K Spectrum. I<br />

have looked through several<br />

magazines, but I cannot find any<br />

useful program. Do you know of<br />

a firm who has such a program?<br />

Fer Soorsma,<br />

Brunssum, Netherlands<br />

Dear Fer,<br />

Forgive the pun, but draughts<br />

seems to have been left out in<br />

the cold by comparison with<br />

that other board game, chess. /<br />

must admit, I'm not aware of<br />

any good draughts programs for<br />

the Spectrum, so, any producer<br />

reading this please let me<br />

know if you have a draughts program.<br />

You could try modifying<br />

the listing in 'Basic Computer<br />

Games' by David A hi for the<br />

Spectrum, but / doubt whether<br />

that will offer much of a<br />

Challenge for an experienced<br />

player.<br />

Crash!<br />

Dear David,<br />

I'm trying to write a simple<br />

machine code routine on the<br />

2X81 which involves places<br />

characters on the screen. The<br />

program starts to work, but then<br />

crashes; what could I be doing<br />

wrong?<br />

Simon Harrison,<br />

Manchester<br />

Dear Simon,<br />

There are lots of things that<br />

could go wrong with your<br />

machine code routine, and my<br />

machine code series may help.<br />

But as your routine actually does<br />

something before crashing, then<br />

/ suspect that you are inadvertently<br />

changing the value<br />

of the NEWLINE character<br />

which exists at the end of each<br />

row on the screen — that's<br />

always good for a crashI<br />

In the fully expanded display<br />

file (with less than 3.5K of RAM<br />

the ZX81 contracts the display<br />

file to save space), there are 33<br />

characters per row; you've probably<br />

overlooked that extra<br />

NEWLINE character.<br />

ZX COMPUTING APRIL/MAY 1 98 5 111

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!