Print Using

Authors

Publication

Pub Details

Date

Pages

BASIC Terms

See all articles from The Plotter v5 n8

The TS 1000, 1500, and 2068 computers do not support this function but many forms of BASIC do. I have had no experience with this function but have noticed its use in some programs so decided it warranted investigating.

There appears to be more than one form of PRINT USING. The simplest establishes the form for printing numbers, right justified. The program contains a line such as 10 A$='#####' where PRINT USING is invoked with a line like 100 LPRINT PRINT USING A$, T. This will print the number assigned to T. If T is 3 digits long then 2 spaces are printed in front of the 3 digits. A number larger than that assigned to A$ will not be controlled.

Some forms of PRINT USING will properly place a decimal point as defined by A$, or add a $ sign in front of all numbers as 10 A$=581.7 and 100 LPRINT PRINT USING $####.##. This will display $581.70.

Using Sinclair methods we can develop a subroutine that will simulate some of these forms of PRINT USING. For the simplest use to right justify a series of numbers we can set it up this way:

Listing 1

  10 LET PRINTUSING=2200
100 READ A
120 PRINT A
130 IF A<>999 THEN GO TO 100
140 PRINT : RESTORE
150 READ A
160 LET I$="####"
170 LET XI=A
180 GO SUB PRINTUSING
190 PRINT X$
200 LPRINT X$
215 IF A<>999 THEN GO TO 150
220 DATA 1,50,100.1,1000,12.346,1023.99,1.1,.0345,999
2200 LET IL=LEN I$
2220 LET ID=0
2290 LET X$=STR$ INT XI
2430 FOR J=1 TO IL-LEN X$
2440 LET X$=CHR$ 32+X$
2450 NEXT J
2490 RETURN

This prints DATA, dropping all digits right of the decimal point, and right justifies. To print the numbers in DATA to two decimal places, change lines 130 and 2290 and add lines 2230, 2240, 2270, 2280, 2390.

Listing 2

  10 LET PRINTUSING=2200
100 READ A
120 PRINT A
130 IF a<>999 THEN GO TO 100
140 PRINT : RESTORE
150 READ A
160 LET I$="####.##"
170 LET XI=A
180 GO SUB PRINTUSING
200 LPRINT X$
210 IF A<>999 THEN GO TO 150
2200 LET IL=LEN I$
2220 LET ID=0
2230 FOR J=1 TO IL
2240 LET J$=I$(J)
2270 IF J$=CHR$ 46 THEN LET ID=LEN I$-J
2280 NEXT J
2290 LET x$=STR$ INT (ABS XI*10↑ID)
2300 LET XD=LEN X$-ID
2310 FOR J=0 TO -XD
2320 LET X$="0"+X$
2330 NEXT J
2380 LET XD=LEN X$-ID
2390 IF ID>0 THEN LET X$=X$( TO XD)+"."+X$(XD+1 TO )
2430 FOR J=1 TO IL-LEN X$
2440 LET X$=CHR$ 32+X$
2450 NEXT J
2490 RETURN

For the TS 1000 & 1500 computers use the following program to allow inputting numbers such as are used in the DATA statement. Lines 2200-2490 are the same except for 2440 where 32 (space) is changed to 26, 2270 where CHR$ 46 (.) is changed to ‘.’, and 2290 which is to be changed as:

2290 LET X$=STR$ INT(ABS XI*10**ID)

To duplicate the first program just change line 170 so I$=’????’.

Listing 3 — TS 1000 / TS 1500

  10 LET PRINTUSING=2200
100 INPUT A
120 PRINT A
130 IF a<>999 THEN GO TO 100
160 LET I$="????.??"
170 LET XI=A
180 GO SUB PRINTUSING
200 LPRINT X$
2200 LET IL=LEN I$
2220 LET ID=0
2230 FOR J=1 TO IL
2240 LET J$=I$(J)
2270 IF J$="." THEN LET ID=LEN I$-J
2280 NEXT J
2290 LET x$=STR$ INT (ABS XI*10↑ID)
2300 LET XD=LEN X$-ID
2310 FOR J=0 TO -XD
2320 LET X$="0"+X$
2330 NEXT J
2380 LET XD=LEN X$-ID
2390 IF ID>0 THEN LET X$=X$( TO XD)+"."+X$(XD+1 TO )
2430 FOR J=1 TO IL-LEN X$
2440 LET X$=CHR$ 26+X$
2450 NEXT J
2490 RETURN

For readers wishing to investigate more PRINT USING forms plus many other conversions To Sinclair Basic I suggest obtaining the book, CONVERTING TO TIMEX SINCLAIR BASIC by Stuart L. Bird, published by Wayne Green Publications.

Products

 

Media

 

Image Gallery

Source Code

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

Scroll to Top