Programming Tips, Part 3

See all articles from Sinc-Link v4 n2
Publication: Sinc-Link
Pub Details: Sinc-Link v4 n2 (Volume 4, Issue 2)
Date: March/April 1986
Pages: 14

Some beginning programmers tend to make an easy mistake with the TS1000: using SLOW when FAST is better. When is it better to use SLOW?

1. When moving graphics are used, especially with machine code.
2. For short interactive programs not necessarily using graphics.
3. When the screen blank-out and flickering of the FAST mode are undesirable.

When is FAST better?

1. When any major arithmetical computations are involved, particularly of the trigonometric, logarithmic, SQR, ABS, and other functions; anywhere that long equations are involved (which tends to exclude most games programs anyway!).
2. When editing – long programs in particular.
3. Most programs where appearance is unimportant: for example, most scientific and technical programs.

Let me give you some hard numbers.. Take this simple loop:

5 FOR F=1 TO 1000
10 NEXT F

In SLOW, execution time is 27.0 seconds. In FAST, it takes only 4.45 seconds. SLOW took over 6 times as long to do the same task. More timed examples are given in the September issue in “Programming Tips Part 1.”. One involving a trigonometric function given there took 39.5 seconds to finish in SLOW, but only 6 seconds in FAST. SLOW took, once again, over 6 times as long.

SLOW can cause frustrations when editing. When moving the line cursor down to a given line down to edit it, the listing is reprinted from the top of the screen each time. In FAST, you don’t have to watch it each time – and also while editing the line itself, since the line is reprinted on the bottom of the screen each time the K or L cursor is moved, there is a similar advantage to using FAST. So what if the screen flickers? Do your editting at home!

Something else that beginning programmers get confused about, is the use of PLOT coordinates vs PRINT coordinates.

PRINT AT 0,0;”X” will put the X in the upper left-hand corner of the screen. The PRINT positions are numbered from 0 to 23 down, and from 0 to 31 across. In a PRINT at A,B statement, A is the line number going down, and B is the print position going across.

PLOT 0,0 will blacken the pixel in the lower left-hand corner of the screen. The numbers here in PLOT and UNPLOT A,B run from 0 to 43 going up for A, and 0 to 63 going across for B. PLOT 43,63 will blacken the extreme upper right-hand pixel.

Ordinarily, you can’t print on lines 23 and 24, the bottom two lines. Within a program, however, you can, by using the line POKE 16418,0, one of the first programming tricks ever discovered for the TS1000. You must POKE 16418 back to 2, it’s original setting, before INPUTting anything, or the whole system will crash.

Taken from the Nov.1985 issue of the Hampton Roads T/S User Group newsletter.