A Print Using Routine and Demonstration

Publication: Update Magazine
Pub Details: Update October 1987
Date: October 1987
Pages: 31

This interesting batch of string slicing and concantations does a nice job of aligning decimal places and simulating the print using functions. There are shorter ways of doing it but this one is included for a study of its tricks. TYPE RUN.

 10 CLS : DIM a$(10,10): FOR n=1 TO 10
30 LET a$(n)=STR$ (1000000*RND*RND*RND*RND): IF VAL a$(n)<.0000001 THEN GO TO 30
50 IF RND<.5 THEN LET a$(n)=a$(n, TO 5)+" "
60 IF a$(n,5)="." THEN LET a$(n,6)=STR$ (1+(9*INT RND))
70 PRINT n,a$(n): NEXT n: PRINT ,,"The numbers will now be placed in the first column and rounded to two decimal places. TOUCH ENTER"
100 INPUT x$: PRINT AT 0,0;"";: FOR n=1 TO 10: GO SUB 240: NEXT n: PRINT '"The numbers in left column will be placed in right column and trailing zeros and commas added.TOUCH ENTER": INPUT x$: PRINT AT 0,0;
180 FOR n=1 TO 10: GO SUB 290: NEXT n: PRINT AT 21,3;"Touch ENTER to REPEAT"
220 IF INKEY$="" THEN GO TO 220
230 RUN
240 LET a=VAL a$(n): LET a=INT (100*a+.05)/100: LET a$(n)=STR$ a: PRINT a$(n): RETURN
290 FOR i=10 TO 1 STEP -1: IF a$(n,i)<>" " THEN GO TO 320
310 NEXT i
320 LET c$=a$(n,1 TO i): IF c$(LEN c$-2)="." THEN GO TO 380
350 IF c$(LEN c$-1)="." THEN GO TO 370
360 LET c$=c$+".0"
370 LET c$=c$+"0"
380 LET a$(n)=" "
390 IF LEN c$>6 THEN LET c$=c$(1 TO LEN c$-6)+","+c$(LEN c$-5 TO )
400 LET a$(n,11-LEN c$ TO 10)=c$: PRINT AT n-1,16;a$(n)
420 RETURN

HELP!

Safe Disk Up-Date needs both Utilities, Programming Tips, and Major Software Programs. The material in this issue came from the Editor’s own treasure trove. The bottom of that basket will soon be uncovered. PLEASE HELP by sharing your useful programming. See the editorial about sharing the proceeds of “SDU ISSUE DISKETTE SALES”. We all need participation by all.

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