'=========================================================================== ' Subject: COMMATOR Date: Unknown Date ' Author: Jesu's Lozano Code: QB, QBasic, PDS ' Origin: comp.lang.basic.misc Packet: TEXT.ABC '=========================================================================== ' This is a another util (like JOINT.BAS) to solve 'little 'problems' reading sequential ascii data coming from/to non PC 'machines or from spreadsheets. ' I.e. tipically a spreadsheet print ascii data in strange 'format, dificulting reading and proccesing. More than 255 chars 'per line were printed as ' 1111111111111111 ' 2222222222222222 ' 111 ' 222 ' When you want 11111111111111 ' 111 ' 22222222222222 ' 222 ' Well, just cut the full lines to many files, the rest to 'another and use the joint.bas code to concatenate by lines... ' BUT what about the space formats which difficults reading 'plain text data as we like? ' i.e. Gijon 5170968 Trabajo 5182188 (not correctly readed) ' vs. Gijon,5170968,Trabajo,5182188 (ok to read) ' Bla, bla... here is the PDS code :-) F1$ = ";": F2$ = "<": F3$ = "=": F4$ = ">": F5$ = "?" F6$ = "@": F7$ = "A": F8$ = "B": F9$ = "C": F10$ = "D" CR$ = CHR$(13): BS$ = CHR$(8): ESC$ = CHR$(27) aleft$ = "K": ARIGHT$ = "M": ADOWN$ = "P": AUP$ = "H" AHOME$ = "G": AEND$ = "O": PGUP$ = "I": PGDN$ = "Q" REM ---------------------------------------------------- PRINT "[ COMMATOR = Insert a lot of commas in your data files ,TA-CHAAN!,]" PRINT "Limited to 10,000 lines. Plea, support bad programmers: Report bugs" PRINT "Price: 0 Registration: OFF Bugs: ON Author: lozano@etsiig.uniovi.es" INPUT " My file is pathnamed as: ", infil$ INPUT " and want to store commated file in: ", oufil$ OPEN LTRIM$(RTRIM$(infil$)) FOR INPUT AS #1 PRINT PRINT "Well. Now we need to show a line to serve as pattern to put some commas." PRINT "Press arrow keys to view lines and RETURN to accept the best one. %-) " DIM jumpi(1 TO 10000) AS LONG inilin = CSRLIN: n = 1 DO IF EOF(1) THEN n = n - 1 SOUND 800, .2 SEEK #1, jumpi(n) END IF LINE INPUT #1, linea$ lenlinea = LEN(linea$) jumpi(n) = SEEK(1) - lenlinea - 2 LOCATE inilin, 1: COLOR 0, 7: PRINT LEFT$(linea$, 78); IF lenlinea < 78 THEN PRINT SPACE$(78 - lenlinea); GOSUB esperatecla IF (scant$ = PGUP$ OR scant$ = AHOME$ OR scant$ = AUP$ OR sacnt$ = aleft$) THEN IF n > 1 THEN n = n - 1 SEEK #1, jumpi(n) ELSE n = n + 1 END IF LOOP UNTIL tecla$ = CR$ COLOR 7, 0: PRINT : PRINT PRINT "Good. Now we have a petrified line. Let's overwrite over it some commas." PRINT "Arrows, charts... Press SPACE to blank or RETURN to accept make the file" inilin = CSRLIN: i = 1 DIM comma(lenlinea) AS INTEGER DO LOCATE inilin, 1: COLOR 7, 0: PRINT MID$(linea$, i, 79); IF lenlinea < 79 THEN PRINT SPACE$(79 - lenlinea); LOCATE inilin, 1: COLOR 0, 7: PRINT MID$(linea$, i, 1); GOSUB esperatecla SELECT CASE scant$ CASE AHOME$: i = 1 CASE aleft$: i = i - 1 CASE ARIGHT$: i = i + 1 CASE AEND$: i = lenlinea END SELECT IF i < 1 THEN i = 1 IF i > lenlinea THEN i = lenlinea IF tecla$ = CR$ THEN EXIT DO IF LEN(tecla$) < 2 THEN comma(i) = ASC(tecla$) LOCATE inilin, 1: COLOR 7 + 16, 0: PRINT tecla$; SLEEP 1 END IF IF tecla$ = " " THEN comma(i) = 0 LOOP SEEK #1, 1 OPEN LTRIM$(RTRIM$(oufil$)) FOR OUTPUT AS #2 PRINT "Working..."; DO LINE INPUT #1, linea$ lenlinea = LEN(linea$) lineaout$ = "" FOR i = 1 TO lenlinea IF i <= UBOUND(comma, 1) THEN IF comma(i) <> 0 THEN lineaout$ = lineaout$ + CHR$(comma(i)) END IF lineaout$ = lineaout$ + MID$(linea$, i, 1) NEXT i PRINT #2, lineaout$ LOOP UNTIL EOF(1) FOR i = -2 TO 5 SOUND 440 * (2 ^ (i - 10 / 12)), .6 NEXT i COLOR 7, 0: PRINT : PRINT "All done! Confused? Me too..." END esperatecla: tecla$ = "" WHILE tecla$ = "" tecla$ = UCASE$(INKEY$) scant$ = MID$(tecla$, 2, 1) WEND RETURN