home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol052 / scatpad.bas < prev    next >
BASIC Source File  |  1984-04-29  |  2KB  |  48 lines

  1. 1000 '*****   Simple Utility Program   *****
  2. 1010 '    If your sort program only allows
  3.     records to be fixed length, then
  4.     this program can be used to pad
  5.     spaces to the end of each line.
  6. 1020 '    New addition - for those who must have
  7.     fixed length fields too.
  8. 1022 '    Beware - This program is like tomato juice,
  9.     i.e. possible insect fragments - it was put
  10.     together very quickly and has been tested
  11.     only minimally.
  12. 1030 '*****   Bill Norris, 12/13/81    *****
  13.  
  14. 1040 INPUT "Type complete INPUT filename : ",IFIL$
  15. 1050 INPUT "Type complete OUTPUT filename : ",OFIL$
  16. 1060 OPEN "I",#1,IFIL$ : OPEN "O",#2,OFIL$ : PRINT
  17. 1070 PRINT "Type '1' for fixed length records (last field padded)."
  18. 1080 PRINT "Type '2' for fixed length fields too (slower than #1)."
  19. 1090 INPUT "     Type '1' or '2' : ",X : PRINT
  20. 1100 IF X<>1 AND X<>2 THEN GOTO 1070
  21. 1110 IF X=2 THEN GOTO 1190
  22.  
  23.  
  24.  
  25. 1120 INPUT "What is the record length? ",RL
  26. 1130 PRINT "Only";RL-2;" bytes available for fields, as"
  27. 1140 INPUT "<cr/lf> occupies 2 bytes.  Retype ? ",X$
  28. 1150 IF ASC(X$)=89 OR ASC(X$)=121 THEN PRINT : GOTO 1120
  29.  
  30. 1160 LINE INPUT #1,A$:B$=A$+SPACE$(RL-LEN(A$)):
  31.      PRINT #2,B$:IF EOF(1) THEN GOTO 1170 ELSE GOTO 1160
  32. 1170 GOTO 9000
  33.  
  34. 1190 INPUT "How many fields per record? ",NUMF : WIDTH 78
  35. 1195 INPUT "Do you want commas inserted between fields? ",X$
  36. 1198 IF ASC(X$)=89 OR ASC(X$) THEN COM$=","
  37. 1200 FOR I=1 TO NUMF :
  38.     PRINT "How many bytes in field #";I; :
  39.     INPUT " ",FL(I) :
  40.      NEXT I
  41. 1210 Y$="":FOR I=1 TO NUMF-1:
  42.     INPUT #1,X$:Y$=Y$+X$+SPACE$(FL(I)-LEN(X$))+COM$:
  43.     NEXT I:INPUT #1,X$:Y$=Y$+X$+SPACE$(FL(NUMF)-LEN(X$)):
  44.     X$=Y$+CHR$(13)+CHR$(10):PRINT #2,X$;
  45. 1220 IF EOF(1) THEN GOTO 9000 ELSE PRINT "*"; : GOTO 1210
  46.  
  47. 9000 CLOSE : PRINT : PRINT "Fin" : END
  48.