Page 1 of 1

Some GW-BASIC code for collating consecutive file data

Posted: Thu Dec 18, 2008 4:06 pm
by Lyle Neff
I'm sure the more computer-savvy among you have a better solution for this, but just in case this can help anyone, here it is.

After recoding a few work pages manually so as to collect separated single-file blocks into one multi-file block -- which involves moving fields and adding consecutive numbering -- I decided to try to automate part of the process. This is my code in GW-BASIC to do this (sorry, that's what I'm stuck with):

0REM IMSLPfil
10 DIM FI$(50),FD$(50),PC$(50)
90 OPEN"O",#2,"tempedt.txt:NAME OF NEW FILE CONTAINING STRIPPED AND RENUMBERED CODE
100 OPEN"I",#1,"temp.txt:NAME OF FILE CONTAINING OLD CODE
120 IF EOF(1) THEN GOTO 300
150 LINE INPUT #1,X$
200 IF LEFT$(X$,11)="|File Name " THEN CT=CT+1:CT$=MID$(STR$(CT),2):FI$(CT)=LEFT$(X$,11)+CT$+MID$(X$,13)
210 IF LEFT$(X$,18)="|File Description " THEN FD$(CT)=LEFT$(X$,18)+CT$+MID$(X$,20)
220 IF LEFT$(X$,12)="|Page Count " THEN PC$(CT)=LEFT$(X$,12)+CT$+MID$(X$,14)
290 GOTO 120
300 FOR Z=1 TO CT
310 PRINT #2, FI$(Z):NEXT
320 FOR Z=1 TO CT
330 PRINT #2, FD$(Z):NEXT
340 FOR Z=1 TO CT
350 PRINT #2, PC$(Z):NEXT
390 CLOSE:END

To make the "temp.txt" file, I cut and paste all of the code between the first "{{#fte:imslpfile" line and the last "}}" line.

Three things to remember:
  • 1. This should be used for data that apply to pieces/movements that belong ONLY to the SAME EDITION.

    2. This is meant only for the fields labeled "File Name," "File Description," and "Page Count," so you need to cut and paste carefully back into the work page data after processing, and collate any plate number information together.

    3. This renders Cyrillic, and presumably also other non-Latin, non-ASCII characters, as question marks.

Posted: Thu Dec 18, 2008 8:50 pm
by pml
Hi Lyle,

just re-edit your post and put a tick against "Disable Smilies in this post". :)

See? 8)

Regards, Philip

Posted: Thu Dec 18, 2008 9:12 pm
by Lyle Neff
Thanks, Philip!

Another caveat:
  • It seems that some of the code lines for "File Description" begin with two pipe characters (i.e., "|") rather than one, so adjust accordingly.