One-Liners

Author(s): Jack Hodgson
Pub Details: Sinclair Timex User Group Newsletter v3 n4 (Volume 3, Issue 4)
Date: April 1984
Pages: 1, 7

A common recreation among programmers has been the one-liner; a short program structures so as to be complete with only one line number. Indeed, the number is only necessary to allow LISTing. Since Sinclair BASIC allows lines of any length up to the limits of memory, the challenge is not as great as when characters per line are limited to 88, as in PET BASIC, for example. However, one must still structure each one liner to make maximum use of IF/THEN and FOR/NEXT plus other BASIC routines while avoiding GOTO and GOSUB.

This one line program produces a surprising variety of displays and also illustrates the animation possibilities of the OVER command on the T/S 2068. Let’s have some more of these!

  10 INPUT "type a #, 0 to 50 :";x: INPUT "How many repeats ? ";y: FOR n=1 TO y: PLOT 65,27: DRAW OVER 1;120,120,(x*10+9)*3*PI: NEXT n
Screen display, Input #5
Screen display, Input #5
  10 CLS : INPUT "Choose a #, 1-255   ";x: OVER 1: FOR n=0 TO 1: PLOT 65,27: DRAW 110,100,PI*x: BEEP .5,1: NEXT n: PRINT AT 3,7;"Any key to again": PAUSE 0: GO TO 10
Screen display of the "Choose a #" one-liner
Screen display of the "Choose a #" one-liner
  10 CLS : INPUT "Choose a #, 1-255   ";x: OVER 1: FOR n=0 TO 1: PLOT 65,27: DRAW 110,100,PI*x: BEEP .5,1: NEXT n: PRINT AT 3,7;"Any key to again": PAUSE 0: GO TO 10
Screen display, #=255
Screen display, #=255
  10 FOR x=0 TO 65 STEP .1: PLOT 2*x*SIN x+125,x*COS x+88: NEXT x
Spiral screen display
Spiral screen display
  10 FOR x=0 TO 254: PLOT x,40*SIN (x/10)+88: DRAW 10,10: DRAW -10,5: NEXT x
Sine wave screen display
Sine wave screen display

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.