-
Notifications
You must be signed in to change notification settings - Fork 0
/
WriteFile.c
executable file
·184 lines (151 loc) · 4.94 KB
/
WriteFile.c
1
#include <string.h>#include "Misc.h"typedef char string[31];typedef string line[50];extern int keys[3][2], numberOfKey, saveRefNum, lineCounter;extern string keyStrings1[3], keyStrings2[3], variables[3];extern Boolean countFlag; void WriteMatch(line line1, line line2, int lineLength1, int lineLength2);void WriteOne(line theLine, int lineLength1, int lineLength2);void WriteTwo(line theLine, int lineLength1, int lineLength2);void WriteLabel(line line1, line line2, int lineLength1, int lineLength2);void WriteMatch(line line1, line line2, int lineLength1, int lineLength2){ OSErr theErr; int i; long Count, CharCount = 1; char ReturnChar = '\r', TabChar = '\t'; string tempString; if (countFlag) { itoa(lineCounter,tempString); Count = strlen(tempString); theErr = FSWrite(saveRefNum,&Count,tempString); theErr = FSWrite(saveRefNum,&CharCount,&TabChar); } for (i=0; i<numberOfKey-1; i++) { Count = strlen(keyStrings1[i]); theErr = FSWrite(saveRefNum,&Count,keyStrings1[i]); theErr = FSWrite(saveRefNum,&CharCount,&TabChar); } Count = strlen(keyStrings1[numberOfKey-1]); theErr = FSWrite(saveRefNum,&Count,keyStrings1[numberOfKey-1]); for (i=1; i<=lineLength1; i++) if ((i != keys[0][0]) && (i != keys[1][0]) && (i != keys[2][0])) { theErr = FSWrite(saveRefNum,&CharCount,&TabChar); Count = strlen(line1[i-1]); theErr = FSWrite(saveRefNum,&Count,line1[i-1]); } for (i=1; i<=lineLength2; i++) if ((i != keys[0][1]) && (i != keys[1][1]) && (i != keys[2][1])) { theErr = FSWrite(saveRefNum,&CharCount,&TabChar); Count = strlen(line2[i-1]); theErr = FSWrite(saveRefNum,&Count,line2[i-1]); } theErr = FSWrite(saveRefNum,&CharCount,&ReturnChar); }void WriteOne(line theLine, int lineLength1, int lineLength2){ OSErr theErr; int i; long Count, CharCount = 1; char ReturnChar = '\r', TabChar = '\t'; string tempString; if (countFlag) { itoa(lineCounter,tempString); Count = strlen(tempString); theErr = FSWrite(saveRefNum,&Count,tempString); theErr = FSWrite(saveRefNum,&CharCount,&TabChar); } for (i=0; i<numberOfKey-1; i++) { Count = strlen(keyStrings1[i]); theErr = FSWrite(saveRefNum,&Count,keyStrings1[i]); theErr = FSWrite(saveRefNum,&CharCount,&TabChar); } Count = strlen(keyStrings1[numberOfKey-1]); theErr = FSWrite(saveRefNum,&Count,keyStrings1[numberOfKey-1]); for (i=1; i<=lineLength1; i++) if ((i != keys[0][0]) && (i != keys[1][0]) && (i != keys[2][0])) { theErr = FSWrite(saveRefNum,&CharCount,&TabChar); Count = strlen(theLine[i-1]); theErr = FSWrite(saveRefNum,&Count,theLine[i-1]); } for (i=1; i<=lineLength2-numberOfKey; i++) theErr = FSWrite(saveRefNum,&CharCount,&TabChar); theErr = FSWrite(saveRefNum,&CharCount,&ReturnChar);}void WriteTwo(line theLine, int lineLength1, int lineLength2){ OSErr theErr; int i; long Count, CharCount = 1; char ReturnChar = '\r', TabChar = '\t'; string tempString; if (countFlag) { itoa(lineCounter,tempString); Count = strlen(tempString); theErr = FSWrite(saveRefNum,&Count,tempString); theErr = FSWrite(saveRefNum,&CharCount,&TabChar); } for (i=0; i<numberOfKey-1; i++) { Count = strlen(keyStrings2[i]); theErr = FSWrite(saveRefNum,&Count,keyStrings2[i]); theErr = FSWrite(saveRefNum,&CharCount,&TabChar); } Count = strlen(keyStrings2[numberOfKey-1]); theErr = FSWrite(saveRefNum,&Count,keyStrings2[numberOfKey-1]); for (i=1; i<=lineLength1-numberOfKey; i++) theErr = FSWrite(saveRefNum,&CharCount,&TabChar); for (i=1; i<=lineLength2; i++) if ((i != keys[0][1]) && (i != keys[1][1]) && (i != keys[2][1])) { theErr = FSWrite(saveRefNum,&CharCount,&TabChar); Count = strlen(theLine[i-1]); theErr = FSWrite(saveRefNum,&Count,theLine[i-1]); } theErr = FSWrite(saveRefNum,&CharCount,&ReturnChar);}void WriteLabel(line line1, line line2, int lineLength1, int lineLength2){ OSErr theErr; int i; long Count, CharCount = 1; char ReturnChar = '\r', TabChar = '\t'; string tempString; if (countFlag) { strcpy(tempString,"Case #\t"); Count = 7; theErr = FSWrite(saveRefNum,&Count,tempString); } for (i=0; i<numberOfKey-1; i++) { Count = strlen(variables[i]); theErr = FSWrite(saveRefNum,&Count,variables[i]); theErr = FSWrite(saveRefNum,&CharCount,&TabChar); } Count = strlen(variables[numberOfKey-1]); theErr = FSWrite(saveRefNum,&Count,variables[numberOfKey-1]); for (i=1; i<=lineLength1; i++) if ((i != keys[0][0]) && (i != keys[1][0]) && (i != keys[2][0])) { theErr = FSWrite(saveRefNum,&CharCount,&TabChar); Count = strlen(line1[i-1]); theErr = FSWrite(saveRefNum,&Count,line1[i-1]); } for (i=1; i<=lineLength2; i++) if ((i != keys[0][1]) && (i != keys[1][1]) && (i != keys[2][1])) { theErr = FSWrite(saveRefNum,&CharCount,&TabChar); Count = strlen(line2[i-1]); theErr = FSWrite(saveRefNum,&Count,line2[i-1]); } theErr = FSWrite(saveRefNum,&CharCount,&ReturnChar); }