08-10-2006, 02:21 AM
this program, written by my predecessor, converts a library catalog in one format into another format, which is then uploaded to the internet. It has been working until now. It ends with the "out of string space" error code 14, after processing 22,000 plus records. I will post it below, along with a portion of the 26 MB file that it tries to convert. Any suggestions would be appreciated. I have tried running it on a Windows 2000 pc, and on 2 different XP pro computers, with the same result.
***************************************************
'Program to massage communications-format MARC records
' for publishing on the Internet.
'This originated from "gen2.bas, written around May '98.
'History: Ver 2.5; fixes design flaw: didn't know we would get records up to
' 13K! Actually this is a workaround rather than a fix: we
' simply eliminate the records which are too long to fit in this program.
'23 Jan 2003
'Ver 2.6 Adds note that bar code shown when there's a long-record reject
' is the barcode of the previous record. Also attempts to add output of
' a counter to cover case of records w/ no barcode causing a log message.
'11 Feb 2004
'
' Initializations
'
DECLARE FUNCTION FindSubFld% (Ftag%, Sf$)
DECLARE FUNCTION FindFld% (tag$)
DECLARE FUNCTION InsertFld% (NewTag$)
DECLARE FUNCTION Zerostr$ (value%, zstringlen%)
DECLARE FUNCTION GetId$ (Fptr%, count%)
DECLARE FUNCTION CountSubs% (FldPtr%)
DECLARE SUB WriteRecord ()
DECLARE SUB MassageRecord ()
DECLARE SUB GetRecord ()
DECLARE SUB OpenFiles ()
DECLARE SUB WriteLog ()
DECLARE SUB SetMsg (i%)
DECLARE SUB AddSubfield (TagIn$, AfterField$, FieldLabel$, FieldText$)
DECLARE SUB DelSubfield (tag$, label$)
DECLARE SUB DelField (tag$)
DECLARE SUB DelChar (Cs$, deldex%)
DECLARE SUB FixUperChars (FldPtr%)
DECLARE SUB BadUper (Cs$, index%)
DECLARE SUB FixBase (Cs$, index%)
DECLARE SUB SpclCrit (Cs$, index%)
CONST TRUE = -1
CONST FALSE = 0
CONST DL = "" 'delimiter
CONST FT = "" 'field terminator
CONST RT = "" 'record terminator
TYPE fldstruc
tag AS STRING * 3
fldlen AS INTEGER 'These include the FT
fstart AS INTEGER 'Adjstd for index starting at 1 insted 0
indics AS STRING * 2
subscount AS INTEGER
END TYPE
REDIM SHARED fld(1) AS fldstruc 'Holds field-wide info on one field
REDIM SHARED dataId(1, 1) AS STRING * 1 '1st:field; 2ndubfield; holds subfld ID char
' (the char after the DL [delimiter])
REDIM SHARED MARCptr(1, 1) AS LONG 'holds ptrs to subfield txt in MARCdata
' (these point to first data char, just aftr ID char
REDIM SHARED MARClengs(1, 1) AS INTEGER 'holds subfields' txt lengths
' (these dont incl DL or ID lengths)
DIM SHARED DoMsgs%(1 TO 10) 'Flags for log messages (reset each record)
DIM SHARED Msgs$(1 TO 10) 'Place to put message constants
DIM SHARED AnselBasesConv$ 'Table for base chars conversion
DIM SHARED CombinCrit$ 'Find which alowd-base table to use
DIM SHARED CombinBase$(1 TO 8) 'Which bases are allowed for each 'crit
DIM SHARED CombinChar$(1 TO 8) 'ANSI subst's for base+diacritic units
DIM SHARED Chop245$ 'what's not allowed frm end of 245
DIM SHARED DirecLen% 'Directory length (stored in leader)
DIM SHARED DataLen& 'Length of all after directory
DIM SHARED InRecLen& 'Length of current inpt MARC rec.
DIM SHARED InFlds% 'Gets no. of fields in INPUT MARC rec.
REM DIM SHARED OutFlds% 'now unused: no. of fields in OUTPUT
DIM SHARED MaxSubs% 'Max subs in any field of curr rec
DIM SHARED holdptr% 'temp for xtra fcn return val
DIM SHARED holdleng% 'temp for xtra fcn return val
DIM SHARED stringchanged% 'flag to signal FixUperChars
DIM SHARED skipflag% 'flag to signal skip this in output
DIM SHARED CurentBar$ 'barcode if found in 852 field
DIM SHARED Leader AS STRING * 24 'Front of MARC record, fixed length
DIM SHARED Directory AS STRING 'Direc for this one record
DIM SHARED MARCdata AS STRING 'all the stuff after directory
DIM SHARED OutMARCdata AS STRING 'construct output counterpart here
DIM SHARED passctr% 'Main prog loop passes (input recs)
DIM SHARED outcount% 'Records written to output file
'Module level code starts here
CLS
OpenFiles ' Open in, out, log files.
Msgs$(1) = "no 001 field"
Msgs$(2) = "no 852"
Msgs$(3) = "no 245"
Msgs$(4) = ""
Msgs$(5) = "undefined upper-ASCII (ANSEL) character(s)"
Msgs$(6) = "diacritic has no following base character"
Msgs$(7) = ""
Msgs$(8) = ""
Msgs$(9) = ""
Msgs$(10) = "" 'Wonder if there's a better way..
AnselBasesConv$ = "LÃÃÃÃÅ'·b®±OUâ?âlødþæÅ" + CHR$(34) + "i£ð?ou??°lp©#¿¡"
'above is ANSEL to ANSI ("ISO") conversn table (base characters, &HA1-C6)
'In above, the '?'s are "future" and so might have to be changed.
'Also see note in FixUperChars
CombinCrit$ = "áâãäèéêð" 'grave,acute,circum,tilde,diere,hacec,angstr,cedil
'programmer CAUTION! The characters in CombinCrit$ must also be duplicated
' in a CASE stmt's expression that calls SpclCrit! (There they're in hex)
CombinBase$(1) = "AEIOUaeiou" 'these are indexed by CombinCrit$
CombinBase$(2) = "AEIOUYaeiouy"
CombinBase$(3) = "AEIOUaeiou"
CombinBase$(4) = "ANOano"
CombinBase$(5) = "AEIOUYaeiouy"
CombinBase$(6) = "Ss"
CombinBase$(7) = "Aa"
CombinBase$(8) = "Cc"
CombinChar$(1) = "ÃÃÃÃÃà èìòù" 'these must be sync'd w/ CombinBase
CombinChar$(2) = "ÃÃÃÃÃÃáéÃóúý"
CombinChar$(3) = "ÃÃÃÃÃâêîôû"
CombinChar$(4) = "ÃÃÃãñõ"
CombinChar$(5) = "ÃÃÃÃßäëïöüÿ" 'that last one is &HFF (l.c. y-dieresis)
CombinChar$(6) = "Å Å¡"
CombinChar$(7) = "à å"
CombinChar$(8) = "Ãç"
Chop245$ = "#$%&(*+,-./:;<=>?@" 'Punct not allowed in 091 at end of what"
' comes from 245a
passctr% = 0
outcount% = 0
PRINT #3, "Beginning at time: "; TIME$
PRINT "Inetmarc: converts MARC records for Internet use. Ver. 2.6 Feb 2004"
DO ' MAIN LOOP
GetRecord ' Read a record and parse it.
IF EOF(1) THEN EXIT DO
MassageRecord ' Process it; make notes as needed in log file.
WriteRecord ' Write out the processed record
WriteLog ' Write out any accumulated messages
passctr% = passctr% + 1
IF (passctr% AND 127) = 0 THEN PRINT "Completed"; passctr%; " records"
MARCdata = "" 'CLEAR MARCdata
OutMARCdata = "" 'CLEAR OutMARCdata
LOOP
PRINT #3, "Ending at time: "; TIME$
PRINT "Total records input: "; passctr%
CLOSE 1, 2, 3 'Close files [END would do this].
SYSTEM
END
**************************************************
here is a portion of the file it uses for the conversion "INRECS"
**************************************************
00753nam 2200217 a 4500001001500000003000900015005001700024008004100041040002300082082001200105110004200117245012200159260005000281300002900331504002900360650002900389700002000418700002100438700002400459852005200483 37741100019197 TxDaGIAL 20050502123337.7 970723s1983 ilua 000 0 eng d ¬aTxDaGIAL¬cTxDaGIAL 04¬a404¬221 2 ¬aChicago Linguistic Society.¬bMeeting. 10¬aCLS 19 :¬bpapers from the nineteenth regional meeting /¬cedited by Amy Chukerman, Mitchell Marks, John F. Richardson. ¬aChicago :¬bChicago Linguistic Society,¬c1983. ¬a407 p. :¬bill. ;¬c23 cm. ¬aIncludes bibliographies. 0¬aLinguistics¬vCongresses. 10¬aChukerman, Amy. 10¬aMarks, Mitchell. 10¬aRichardson, John F. ¬aTxDaGIAL¬h410.5¬iC532¬m19 1983¬820050502¬kJOURN 00762nam 2200229 a 4500001001500000003000900015005001700024008004100041020001500082040002300097082001200120110004200132245011200174260005000286300002900336504002900365650002900394700001900423700001900442700001900461852005200480 37741100019198 TxDaGIAL 20050502123411.1 970723s1984 ilua 000 0 eng d ¬a0914203215 ¬aTxDaGIAL¬cTxDaGIAL 04¬a404¬221 2 ¬aChicago Linguistic Society.¬bMeeting. 10¬aCLS 20 :¬bpapers from the twentieth regional meeting /¬cedited by Joseph Drogo, Veena Mishra, David Testen. ¬aChicago :¬bChicago Linguistic Society,¬c1984. ¬a402 p. :¬bill. ;¬c23 cm. ¬aIncludes bibliographies. 0¬aLinguistics¬vCongresses. 10¬aDrogo, Joseph. 10¬aMishra, Veena. 10¬aTesten, David. ¬aTxDaGIAL¬h410.5¬iC532¬m20 1984¬820050502¬kJOURN 01160nam 2200241 a 4500001001500000003000900015005001700024008004100041020001500082040002300097082001200120110004200132245015900174260005000333300002900383504002900412505032800441650002900769700002400798700002100822700002300843852005200866 37741100019199 TxDaGIAL 20050502123438.4 970723s1985 ilua 000 0 eng d ¬a0914203231 ¬aTxDaGIAL¬cTxDaGIAL 04¬a404¬221 2 ¬aChicago Linguistic Society.¬bMeeting. 10¬aCLS 21 part 1 :¬bpapers from the general session at the twenty-first regional meeting /¬cedited by William H. Eilfort, Paul D. Kroeber, Karen L. Peterson. ¬aChicago :¬bChicago Linguistic Society,¬c1985. ¬a438 p. :¬bill. ;¬c23 cm. ¬aIncludes bibliographies. 2 ¬aSyllables and tones in Middle Korean / Eung-Jin Baek -- Morphology in Relational Grammar / Donald G. Frantz -- Lexical operations and unbounded dependencies / Jeffrey Goldberg -- Language-external evidence for clitics as words; Lappish particle clitics / Joel A. Nevis -- Copular constructions in Hebrew / Tova R. Rapoport. 0¬aLinguistics¬vCongresses. 10¬aEilfort, William H. 10¬aKroeber, Paul D. 10¬aPeterson, Karen L. ¬aTxDaGIAL¬h410.5¬iC532¬m21 1985¬820050502¬kJOURN 01112nam 2200229 a 4500001001500000003000900015005001700024008004100041040002300082082001200105110004200117245015900159260005000318300002900368505030700397504002900704650002900733700002000762700002100782700002700803852005200830 37741100019200 TxDaGIAL 20050502123509.9 970723s1986 ilua 000 0 eng d ¬aTxDaGIAL¬cTxDaGIAL 04¬a404¬221 2 ¬aChicago Linguistic Society.¬bMeeting. 10¬aCLS 22 part 1 :¬bpapers from the general session at the twenty-second regional meeting /¬cedited by Anne M. Farley, Peter T. Farley, Karl-Erik McCullough. ¬aChicago :¬bChicago Linguistic Society,¬c1986. ¬a360 p. :¬bill. ;¬c23 cm. 2 ¬aMorphological conditioning of epenthetic vowels in Hungarian / George Fowler -- Concatenation and liberation / Arnold M. Zwicky -- Possessor Ascension in Kinyarwanda / J. Albert Bickford -- Null valents in the expression of impersonal action in Kashmiri and Russian -- On weather verbs / Nicolas Ruwet. ¬aIncludes bibliographies. 0¬aLinguistics¬vCongresses. 10¬aFarley, Anne M. 10¬aFarley, Peter T. 10¬aMcCullough, Karl-Erik.
***************************************************
'Program to massage communications-format MARC records
' for publishing on the Internet.
'This originated from "gen2.bas, written around May '98.
'History: Ver 2.5; fixes design flaw: didn't know we would get records up to
' 13K! Actually this is a workaround rather than a fix: we
' simply eliminate the records which are too long to fit in this program.
'23 Jan 2003
'Ver 2.6 Adds note that bar code shown when there's a long-record reject
' is the barcode of the previous record. Also attempts to add output of
' a counter to cover case of records w/ no barcode causing a log message.
'11 Feb 2004
'
' Initializations
'
DECLARE FUNCTION FindSubFld% (Ftag%, Sf$)
DECLARE FUNCTION FindFld% (tag$)
DECLARE FUNCTION InsertFld% (NewTag$)
DECLARE FUNCTION Zerostr$ (value%, zstringlen%)
DECLARE FUNCTION GetId$ (Fptr%, count%)
DECLARE FUNCTION CountSubs% (FldPtr%)
DECLARE SUB WriteRecord ()
DECLARE SUB MassageRecord ()
DECLARE SUB GetRecord ()
DECLARE SUB OpenFiles ()
DECLARE SUB WriteLog ()
DECLARE SUB SetMsg (i%)
DECLARE SUB AddSubfield (TagIn$, AfterField$, FieldLabel$, FieldText$)
DECLARE SUB DelSubfield (tag$, label$)
DECLARE SUB DelField (tag$)
DECLARE SUB DelChar (Cs$, deldex%)
DECLARE SUB FixUperChars (FldPtr%)
DECLARE SUB BadUper (Cs$, index%)
DECLARE SUB FixBase (Cs$, index%)
DECLARE SUB SpclCrit (Cs$, index%)
CONST TRUE = -1
CONST FALSE = 0
CONST DL = "" 'delimiter
CONST FT = "" 'field terminator
CONST RT = "" 'record terminator
TYPE fldstruc
tag AS STRING * 3
fldlen AS INTEGER 'These include the FT
fstart AS INTEGER 'Adjstd for index starting at 1 insted 0
indics AS STRING * 2
subscount AS INTEGER
END TYPE
REDIM SHARED fld(1) AS fldstruc 'Holds field-wide info on one field
REDIM SHARED dataId(1, 1) AS STRING * 1 '1st:field; 2ndubfield; holds subfld ID char
' (the char after the DL [delimiter])
REDIM SHARED MARCptr(1, 1) AS LONG 'holds ptrs to subfield txt in MARCdata
' (these point to first data char, just aftr ID char
REDIM SHARED MARClengs(1, 1) AS INTEGER 'holds subfields' txt lengths
' (these dont incl DL or ID lengths)
DIM SHARED DoMsgs%(1 TO 10) 'Flags for log messages (reset each record)
DIM SHARED Msgs$(1 TO 10) 'Place to put message constants
DIM SHARED AnselBasesConv$ 'Table for base chars conversion
DIM SHARED CombinCrit$ 'Find which alowd-base table to use
DIM SHARED CombinBase$(1 TO 8) 'Which bases are allowed for each 'crit
DIM SHARED CombinChar$(1 TO 8) 'ANSI subst's for base+diacritic units
DIM SHARED Chop245$ 'what's not allowed frm end of 245
DIM SHARED DirecLen% 'Directory length (stored in leader)
DIM SHARED DataLen& 'Length of all after directory
DIM SHARED InRecLen& 'Length of current inpt MARC rec.
DIM SHARED InFlds% 'Gets no. of fields in INPUT MARC rec.
REM DIM SHARED OutFlds% 'now unused: no. of fields in OUTPUT
DIM SHARED MaxSubs% 'Max subs in any field of curr rec
DIM SHARED holdptr% 'temp for xtra fcn return val
DIM SHARED holdleng% 'temp for xtra fcn return val
DIM SHARED stringchanged% 'flag to signal FixUperChars
DIM SHARED skipflag% 'flag to signal skip this in output
DIM SHARED CurentBar$ 'barcode if found in 852 field
DIM SHARED Leader AS STRING * 24 'Front of MARC record, fixed length
DIM SHARED Directory AS STRING 'Direc for this one record
DIM SHARED MARCdata AS STRING 'all the stuff after directory
DIM SHARED OutMARCdata AS STRING 'construct output counterpart here
DIM SHARED passctr% 'Main prog loop passes (input recs)
DIM SHARED outcount% 'Records written to output file
'Module level code starts here
CLS
OpenFiles ' Open in, out, log files.
Msgs$(1) = "no 001 field"
Msgs$(2) = "no 852"
Msgs$(3) = "no 245"
Msgs$(4) = ""
Msgs$(5) = "undefined upper-ASCII (ANSEL) character(s)"
Msgs$(6) = "diacritic has no following base character"
Msgs$(7) = ""
Msgs$(8) = ""
Msgs$(9) = ""
Msgs$(10) = "" 'Wonder if there's a better way..
AnselBasesConv$ = "LÃÃÃÃÅ'·b®±OUâ?âlødþæÅ" + CHR$(34) + "i£ð?ou??°lp©#¿¡"
'above is ANSEL to ANSI ("ISO") conversn table (base characters, &HA1-C6)
'In above, the '?'s are "future" and so might have to be changed.
'Also see note in FixUperChars
CombinCrit$ = "áâãäèéêð" 'grave,acute,circum,tilde,diere,hacec,angstr,cedil
'programmer CAUTION! The characters in CombinCrit$ must also be duplicated
' in a CASE stmt's expression that calls SpclCrit! (There they're in hex)
CombinBase$(1) = "AEIOUaeiou" 'these are indexed by CombinCrit$
CombinBase$(2) = "AEIOUYaeiouy"
CombinBase$(3) = "AEIOUaeiou"
CombinBase$(4) = "ANOano"
CombinBase$(5) = "AEIOUYaeiouy"
CombinBase$(6) = "Ss"
CombinBase$(7) = "Aa"
CombinBase$(8) = "Cc"
CombinChar$(1) = "ÃÃÃÃÃà èìòù" 'these must be sync'd w/ CombinBase
CombinChar$(2) = "ÃÃÃÃÃÃáéÃóúý"
CombinChar$(3) = "ÃÃÃÃÃâêîôû"
CombinChar$(4) = "ÃÃÃãñõ"
CombinChar$(5) = "ÃÃÃÃßäëïöüÿ" 'that last one is &HFF (l.c. y-dieresis)
CombinChar$(6) = "Å Å¡"
CombinChar$(7) = "à å"
CombinChar$(8) = "Ãç"
Chop245$ = "#$%&(*+,-./:;<=>?@" 'Punct not allowed in 091 at end of what"
' comes from 245a
passctr% = 0
outcount% = 0
PRINT #3, "Beginning at time: "; TIME$
PRINT "Inetmarc: converts MARC records for Internet use. Ver. 2.6 Feb 2004"
DO ' MAIN LOOP
GetRecord ' Read a record and parse it.
IF EOF(1) THEN EXIT DO
MassageRecord ' Process it; make notes as needed in log file.
WriteRecord ' Write out the processed record
WriteLog ' Write out any accumulated messages
passctr% = passctr% + 1
IF (passctr% AND 127) = 0 THEN PRINT "Completed"; passctr%; " records"
MARCdata = "" 'CLEAR MARCdata
OutMARCdata = "" 'CLEAR OutMARCdata
LOOP
PRINT #3, "Ending at time: "; TIME$
PRINT "Total records input: "; passctr%
CLOSE 1, 2, 3 'Close files [END would do this].
SYSTEM
END
**************************************************
here is a portion of the file it uses for the conversion "INRECS"
**************************************************
00753nam 2200217 a 4500001001500000003000900015005001700024008004100041040002300082082001200105110004200117245012200159260005000281300002900331504002900360650002900389700002000418700002100438700002400459852005200483 37741100019197 TxDaGIAL 20050502123337.7 970723s1983 ilua 000 0 eng d ¬aTxDaGIAL¬cTxDaGIAL 04¬a404¬221 2 ¬aChicago Linguistic Society.¬bMeeting. 10¬aCLS 19 :¬bpapers from the nineteenth regional meeting /¬cedited by Amy Chukerman, Mitchell Marks, John F. Richardson. ¬aChicago :¬bChicago Linguistic Society,¬c1983. ¬a407 p. :¬bill. ;¬c23 cm. ¬aIncludes bibliographies. 0¬aLinguistics¬vCongresses. 10¬aChukerman, Amy. 10¬aMarks, Mitchell. 10¬aRichardson, John F. ¬aTxDaGIAL¬h410.5¬iC532¬m19 1983¬820050502¬kJOURN 00762nam 2200229 a 4500001001500000003000900015005001700024008004100041020001500082040002300097082001200120110004200132245011200174260005000286300002900336504002900365650002900394700001900423700001900442700001900461852005200480 37741100019198 TxDaGIAL 20050502123411.1 970723s1984 ilua 000 0 eng d ¬a0914203215 ¬aTxDaGIAL¬cTxDaGIAL 04¬a404¬221 2 ¬aChicago Linguistic Society.¬bMeeting. 10¬aCLS 20 :¬bpapers from the twentieth regional meeting /¬cedited by Joseph Drogo, Veena Mishra, David Testen. ¬aChicago :¬bChicago Linguistic Society,¬c1984. ¬a402 p. :¬bill. ;¬c23 cm. ¬aIncludes bibliographies. 0¬aLinguistics¬vCongresses. 10¬aDrogo, Joseph. 10¬aMishra, Veena. 10¬aTesten, David. ¬aTxDaGIAL¬h410.5¬iC532¬m20 1984¬820050502¬kJOURN 01160nam 2200241 a 4500001001500000003000900015005001700024008004100041020001500082040002300097082001200120110004200132245015900174260005000333300002900383504002900412505032800441650002900769700002400798700002100822700002300843852005200866 37741100019199 TxDaGIAL 20050502123438.4 970723s1985 ilua 000 0 eng d ¬a0914203231 ¬aTxDaGIAL¬cTxDaGIAL 04¬a404¬221 2 ¬aChicago Linguistic Society.¬bMeeting. 10¬aCLS 21 part 1 :¬bpapers from the general session at the twenty-first regional meeting /¬cedited by William H. Eilfort, Paul D. Kroeber, Karen L. Peterson. ¬aChicago :¬bChicago Linguistic Society,¬c1985. ¬a438 p. :¬bill. ;¬c23 cm. ¬aIncludes bibliographies. 2 ¬aSyllables and tones in Middle Korean / Eung-Jin Baek -- Morphology in Relational Grammar / Donald G. Frantz -- Lexical operations and unbounded dependencies / Jeffrey Goldberg -- Language-external evidence for clitics as words; Lappish particle clitics / Joel A. Nevis -- Copular constructions in Hebrew / Tova R. Rapoport. 0¬aLinguistics¬vCongresses. 10¬aEilfort, William H. 10¬aKroeber, Paul D. 10¬aPeterson, Karen L. ¬aTxDaGIAL¬h410.5¬iC532¬m21 1985¬820050502¬kJOURN 01112nam 2200229 a 4500001001500000003000900015005001700024008004100041040002300082082001200105110004200117245015900159260005000318300002900368505030700397504002900704650002900733700002000762700002100782700002700803852005200830 37741100019200 TxDaGIAL 20050502123509.9 970723s1986 ilua 000 0 eng d ¬aTxDaGIAL¬cTxDaGIAL 04¬a404¬221 2 ¬aChicago Linguistic Society.¬bMeeting. 10¬aCLS 22 part 1 :¬bpapers from the general session at the twenty-second regional meeting /¬cedited by Anne M. Farley, Peter T. Farley, Karl-Erik McCullough. ¬aChicago :¬bChicago Linguistic Society,¬c1986. ¬a360 p. :¬bill. ;¬c23 cm. 2 ¬aMorphological conditioning of epenthetic vowels in Hungarian / George Fowler -- Concatenation and liberation / Arnold M. Zwicky -- Possessor Ascension in Kinyarwanda / J. Albert Bickford -- Null valents in the expression of impersonal action in Kashmiri and Russian -- On weather verbs / Nicolas Ruwet. ¬aIncludes bibliographies. 0¬aLinguistics¬vCongresses. 10¬aFarley, Anne M. 10¬aFarley, Peter T. 10¬aMcCullough, Karl-Erik.