' This Filter processes a database file from Microsoft Works(2.0) ' to one that is suitable to be imported to File Express ' In File Express choose SPECIAL MAIL MERGE and select ' a carriage Return as a delimiter instead of the default comma. ' Being a RAM-based program WORKS saves space by ending a record ' with a Carriage Return, so that if a record has ten fields ' but only uses 1,3,4,5, & 6 then tabs will separate the fields ' WITHIN the record but a Carriage Return(and Linefeed will be ' written after field 6 to skip to the next record, so this ' filter takes that into account by adding a blank (& CR) for ' each field. Each field takes up space in File Express ' assuming you want the same file structure. ' The works file is assumed to have been saved with TABS as ' separators, use works for this - ie load it in then SAVE AS ' File Express has the IMPORT process - choose SPECIAL ' MAIL MERGE with a Carriage Return as delimeter ' (c) Keith Farrell 1991 ' last update March 1991 DECLARE SUB Box () CONST Black = 0, Blue = 1, Green = 2, Cyan = 3, Red = 4, Magenta = 5 CONST Brown = 6, White = 7, Grey = 8, LBlue = 9, LGreen = 10, LCyan = 11 CONST Yellow = 14 CONST True = 1, False = 0 KEY OFF: COLOR Green, Brown: CLS ON KEY(2) GOSUB KeysInfo KEY(2) ON ON ERROR GOTO ErrorHandler DO UNTIL A$ = "C" COLOR Yellow, Brown CLS COLOR White PRINT , "MicroSoft WORKS to File Express IMPORT file" LOCATE 25, 50: PRINT "V 0.8 (c) Keith Farrell 1991"; LOCATE 4 COLOR Green PRINT "Note that the full name of the file is needed and the processed" PRINT "file is given the extension .FXP AND the file must have been" PRINT "saved by Microsoft Works (V 2.0) as `text & TAB separators'." COLOR Yellow LOCATE 20: PRINT "Press C to cont - F2 for Further Info" DO A$ = UCASE$(INKEY$) LOOP UNTIL A$ <> "" LOOP LOCATE 10: PRINT "Name of file to be processed : "; INPUT "", FullFileName$ DO Count = Count + 1 Temp$ = MID$(FullFileName$, Count, 1) IF Temp$ <> "." THEN FileName$ = FileName$ + Temp$ LOOP UNTIL Temp$ = "." FOR Ext = 1 TO 3 Count = Count + 1 Temp$ = MID$(FullFileName$, Count, 1) Extension$ = Extension$ + Temp$ NEXT Ext LOCATE 12: PRINT "Number of fields in the record : "; INPUT "", RecordLength OPEN FileName$ + "." + Extension$ FOR INPUT AS #1 OPEN FileName$ + "." + "FXP" FOR OUTPUT AS #2 FieldNo = 1 RecordNo = 1 COLOR LGreen LOCATE 13: PRINT STRING$(75, 219); COLOR Cyan LOCATE 15, 5: PRINT "Processing Field :"; FieldNo LOCATE 16, 5: PRINT "Record :"; RecordNo DO Temp$ = INPUT$(1, #1) IF Temp$ = CHR$(9) OR Temp$ = CHR$(13) THEN LOCATE 15, 5 PRINT "Processing Field :"; FieldNo PRINT #2, Second$ Second$ = "" FieldNo = FieldNo + 1 ' a complete field gets written to the file ' and one is added to the field count ' if the incoming character is a TAB, Carriage Return ELSE Second$ = Second$ + Temp$ END IF IF ASC(Temp$) = 13 THEN Temp$ = INPUT$(1, #1) ' never used as this is the linefeed Padding = RecordLength - FieldNo + 1 FOR Count = 1 TO Padding FieldNo = FieldNo + 1 LOCATE 15, 5 PRINT "Processing Field :"; FieldNo PRINT #2, "" NEXT Count LOCATE 16, 5 PRINT "Record :"; RecordNo RecordNo = RecordNo + 1 ' line feed signifies end of record and padding may be ' required - depending upon Works' storage ' and one is added to the record count FieldNo = 1 ' reset the field counter END IF LOOP WHILE NOT EOF(1) CLOSE #1 CLOSE #2 END ErrorHandler: PRINT "An error has occurred - "; ERR SELECT CASE ERR CASE IS = 53 PRINT "There is no file by that name on this disk" CASE IS = 58 PRINT "File already exists - reported when renaming as .BAK" PRINT "Do you wish to KILL it - and thus continue (Y/N)" Action$ = UCASE$(INPUT$(1)) IF Action$ = "Y" THEN KILL Source$ CASE ELSE PRINT "uh oh" END SELECT IF ERR = 53 OR (ERR = 58 AND Action$ = "N") THEN STOP PRINT PRINT , "tap a key to continue (unless the error was 'uh oh')" A$ = INPUT$(1) RESUME NEXT KeysInfo: CLS Box LOCATE 4, 7: PRINT "This Filter processes a database file from Microsoft Works(2.0)" LOCATE 5, 7: PRINT " to one that is suitable to be imported to File Express" LOCATE 6, 7: PRINT " In File Express choose SPECIAL MAIL MERGE and select" LOCATE 7, 7: PRINT " a carriage Return as a delimiter instead of the default comma." LOCATE 8, 7: PRINT " Being a RAM-based program WORKS saves space by ending a record" LOCATE 9, 7: PRINT "with a Carriage Return, so that if a record has ten fields" LOCATE 10, 7: PRINT " but only uses 1,3,4,5, & 6 then tabs will separate the fields" LOCATE 11, 7: PRINT " WITHIN the record but a Carriage Return(and Linefeed will be" LOCATE 12, 7: PRINT " written after field 6 to skip to the next record, so this" LOCATE 13, 7: PRINT " filter takes that into account by adding a blank (& CR) for" LOCATE 14, 7: PRINT " each field. Each field takes up space in File Express" LOCATE 15, 7: PRINT " assuming you want the same file structure." LOCATE 16, 7: PRINT " The works file is assumed to have been saved with TABS as" LOCATE 17, 7: PRINT "separators, use works for this - ie load it in then SAVE AS" LOCATE 18, 7: PRINT " File Express has the IMPORT process - choose SPECIAL" LOCATE 19, 7: PRINT " MAIL MERGE with a Carriage Return as delimeter" LOCATE 20, 20: PRINT "Press a key to return to menu" DO A$ = INKEY$ LOOP UNTIL A$ <> "" RETURN SUB Box LOCATE 2, 5: PRINT STRING$(65, 205) FOR Count = 3 TO 20 LOCATE Count, 5: PRINT CHR$(186) LOCATE Count, 70: PRINT CHR$(186) NEXT LOCATE 21, 5: PRINT STRING$(65, 205) LOCATE 2, 5: PRINT CHR$(201) LOCATE 21, 5: PRINT CHR$(200) LOCATE 2, 70: PRINT CHR$(187) LOCATE 21, 70: PRINT CHR$(188) END SUB