Category : Files from Magazines
Archive   : CL-DEC88.ZIP
Filename : M-EXAMP.BAS

 
Output of file : M-EXAMP.BAS contained in archive : CL-DEC88.ZIP
0 ' Illustrates MOVE algorithm (lines 45000-45200)
10 DIM A$(12)
20 FOR J=1 TO 12:READ A$(J):NEXT
25 ' PUT A CLEAR SCREEN FUNCTION HERE (E.G. CLS IN IBM BASIC)
30 PRINT "This program takes the following list of strings (as the array A$() ) :":PRINT:GOSUB 1000:PRINT:PRINT " and moves array elements 7 to 12 to the position following element No. 1 (i.e. START=7, LENGTH=12-7+1=6, FINISH=1)"
40 PRINT:INPUT "Press RETURN to do this",X$:PRINT
50 START=7:LENGTH=6:FINISH=1:GOSUB 45000
55 IF TRUE=0 THEN PRINT "Error";:ELSE GOSUB 1000
200 END
998 '**************************************************************************
999 'Display strings
1000 PRINT "Array element No.";TAB(40);"String"
1005 PRINT STRING$(55,"-")
1010 FOR J=1 TO 12:PRINT J;TAB(40);A$(J):NEXT
1020 RETURN
1021 '*************************************************************************
1999 'Example data
2000 DATA "This","the","divide","and","swap","technique.","tests","the","MOVE","algorithm","which","uses"
2001 '*************************************************************************
44995 'MOVE procedure (pass START,LENGTH & FINISH to routine. Returns TRUE=0 if error))
44996 ' START is start position of 1st element of block
44997 ' LENGTH is the no. of array elements in the block
44998 ' The block is moved to the position following element No. FINISH
44999 '
45000 TRUE=1
45010 IF START>FINISH THEN X=START-FINISH-1:Y=START:START=FINISH+1:FINISH=Y+LENGTH-1:LENGTH=X
45020 IF (FINISH>START AND FINISH 45030 S=START
45040 WHILE LENGTH<>0:LPREV=LENGTH
45050 X=FINISH+1-(S+LENGTH):IF X=0 THEN GOTO 45100
45060 IF X=LENGTH THEN GOSUB 45200:GOTO 45100
45070 IF LENGTH 45080 IF LENGTH>X THEN L1=LENGTH-X:LENGTH=X:GOSUB 45200:S=S+LENGTH:LENGTH=L1
45090 WEND
45100 RETURN
45110 '........................................................................
45199 'Exchange LENGTH array elements starting at element S with block starting at element S+PREV
45200 FOR J=S TO S+LENGTH-1:SWAP A$(J),A$(J+LPREV):NEXT:RETURN


  3 Responses to “Category : Files from Magazines
Archive   : CL-DEC88.ZIP
Filename : M-EXAMP.BAS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/