Some GW-BASIC code for collating consecutive file data

Moderator: kcleung

Post Reply
Lyle Neff
active poster
Posts: 702
Joined: Wed Mar 14, 2007 3:21 pm
notabot: 42
notabot2: Human
Location: Delaware, USA
Contact:

Some GW-BASIC code for collating consecutive file data

Post 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.
Last edited by Lyle Neff on Thu Dec 18, 2008 9:10 pm, edited 3 times in total.
"A libretto, a libretto, my kingdom for a libretto!" -- Cesar Cui (letter to Stasov, Feb. 20, 1877)
pml
Copyright Reviewer
Posts: 1219
Joined: Fri Mar 16, 2007 3:42 am
notabot: 42
notabot2: Human
Location: Melbourne, Australia
Contact:

Post by pml »

Hi Lyle,

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

See? 8)

Regards, Philip
--
PML (talk)
Lyle Neff
active poster
Posts: 702
Joined: Wed Mar 14, 2007 3:21 pm
notabot: 42
notabot2: Human
Location: Delaware, USA
Contact:

Post 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.
"A libretto, a libretto, my kingdom for a libretto!" -- Cesar Cui (letter to Stasov, Feb. 20, 1877)
Post Reply