/* * Concordance Programming Language STAIRS Output Program * * Copyright (c) 1990, 1991 Dataflight Software. * All Rights Reserved. * 3200 Airport Avenue, Suite 19 * Santa Monica, CA 90230 * * ALL RIGHTS RESERVED. * * Unauthorized distribution, adaptation or use may be * subject to civil and criminal penalties. * */ /**************************************************************** * Name: stairs * * Synopsis: Produces STAIRS Editable Condensed Text output. * * Document header information is taken from the * * system number fixed field. * * Description Each entry in the Editable Condensed Text file * * must be preceded by a control command. The * * format of the control command is: * * .SO command-code parameter * * Any line that does not begin with a control * * command is a line of data. Valid commands are: * * DOC This command indicates the start of a * * new document. The document name, the * * STAIRS system number, is specified as * * the command parameter. * * PID The paragraph ID command is followed by * * the three character paragraph code. * * RPW This command sets the privacy level of * * the following documents. The parameter * * can be any number in the range 0 - 255. * * LEN This command sets the line length of * * the following paragraphs. The line * * length parameter should be in the range * * 1 - 79. 80 is a also valid, however * * STAIRS will not properly highlight * * paragraphs with this line length. * * OPT This command sets two options for the * * creation of the data base. STAIRS will * * remove blank lines from the input text * * file by default. Use: * * .SO OPT NOD * * to keep blank lines. Use: * * .SO OPT DEL * * to continue removal of blank lines. * ****************************************************************/ main() { int db; char string[80]; initialize(); if (db.documents < 0) if (getfile("Concordance Database","*.DCB",string) == CR) db = opendb(string); if (db.documents >= 0) stairs(db); } /* main() */ /**************************************************************** * Name: stairs * * Synopsis: Produces STAIRS Editable Condensed Text output. * ****************************************************************/ stairs(int db) { int i, j, handle, offset, length, field, key; text line, screen; char string[80]; if (getfile("STAIRS Editable Condensed Text","*.TXT",string) == CR) { if ((handle = open(string,"w+")) <> EOF) { /* Start with query zero, to print the entire file. */ query(db,0); /* Here would be the place to sort the data base if that was desired. */ /* sort(db,"db->fld[0]"); */ /* Cycle through each document in the data base. */ key = 0; screen = save(15,57,19,79); box(15,57,19,79,'sd',MenuColor_); puts(15,58,"STAIRS Text",MenuColor_); puts(MaxRow_,0,pad("Press [Esc] to cancel...",'C',80),MenuColor_); cycle(db) { puts(16,58,"Document "+str(docno(db),10,0,','),MenuColor_); /* Special case for first field. Output a DOC command with */ /* field contents to indicate the start of a new document. */ line = ".SO DOC " + str(db->1); writeln(handle,line,len(line)); /* Cycle through each field in the document. */ for(field = 1; (field <= db.fields) and (key <> ESC); field = field + 1) { puts(17,58,"Field "+str(field,10,0,','),MenuColor_); /* Check for an ESC key. */ while(keypress()) key = getkey(); /* Print the field information to file. */ switch(db.type[field]) { case 'N': /* Convert the number to a string and print it to file. */ WritePID(handle,field); string = str(db->field,db.length[field],db.places[field]); writeln(handle,string,len(string)); break; case 'T': /* Don't bother printing empty text fields. */ if (len(trim(db->field))) { /* Print the field code and data to file. */ WritePID(handle,field); string = trim(db->field); writeln(handle,string,len(string)); } break; case 'P': /* Don't bother printing empty paragraph fields. */ if (len(trim(db->field))) { /* Write the text field to file. Wordwrap it in */ /* a column of 53 characters width. */ WritePID(handle,field); wrap(db->field,53); offset = findline(db->field,1,length); write(handle, " ",16); while(offset) { writeln(handle,addr(db->field,offset),length); offset = findnline(db->field,offset,length); if(offset) write(handle, " ", 10); } } break; case 'D': /* Convert date to YYYYMMDD string. */ WritePID(handle,field); string = str(year(db->field),4,0,'Z') + str(month(db->field),2,0,'Z') + str(day(db->field),2,0,'Z'); writeln(handle,string,len(string)); break; } } /* Check for a user requested exit. */ if (key == ESC) { if (Message("Cancel STAIRS output? Y/N") == 'Y') break; else key = 0; } } /* All done with the output loop, close the file and return. */ restore(15,57,screen); close(handle); } } } /* stairs() */ /**************************************************************** * Name: WritePID * * Synopsis: Writes paragraph ID code to file. WritePID() is * * a helper function for the stairs() routine. * ****************************************************************/ WritePID(int handle, name) { text fldnum; fldnum = ".SO PID " + StairsField[name]; writeln(handle,fldnum,len(fldnum)); } /**************************************************************** * Name: Message * * Synopsis: Displays error message and waits for key. * ****************************************************************/ Message(text message) { text screen; int key; cursoroff(); screen = save(5,13,8,69); box(5,13,8,69,"DS", MenuColor_); puts(6,14,pad(message,'C',53),MenuColor_); key = getkey(); restore(5,13,screen); return(asc(upper(chr(key)))); } /* Message() */ /**************************************************************** * Name: initialize * * Synopsis: Set global variables to initial values * * Action: Global variables are set for system calls * ****************************************************************/ int TRUE = 1; int FALSE = 0; int ESC = 27; int CR = 13; int EOF = -1; text StairsField[51]; initialize() { cls(); cursor(0,0); StairsField[01] = "0AA"; StairsField[02] = "005"; StairsField[03] = "010"; StairsField[04] = "015"; StairsField[05] = "020"; StairsField[06] = "025"; StairsField[07] = "030"; StairsField[08] = "035"; StairsField[09] = "040"; StairsField[10] = "045"; StairsField[11] = "050"; StairsField[12] = "055"; StairsField[13] = "060"; StairsField[14] = "065"; StairsField[15] = "070"; StairsField[16] = "075"; StairsField[17] = "080"; StairsField[18] = "085"; StairsField[19] = "090"; StairsField[20] = "095"; StairsField[21] = "100"; StairsField[22] = "105"; StairsField[23] = "110"; StairsField[24] = "115"; StairsField[25] = "120"; StairsField[26] = "125"; StairsField[27] = "130"; StairsField[28] = "135"; StairsField[29] = "140"; StairsField[30] = "145"; StairsField[31] = "150"; StairsField[32] = "155"; StairsField[33] = "160"; StairsField[34] = "165"; StairsField[35] = "170"; StairsField[36] = "175"; StairsField[37] = "180"; StairsField[38] = "185"; StairsField[39] = "190"; StairsField[40] = "195"; StairsField[41] = "200"; StairsField[42] = "205"; StairsField[43] = "210"; StairsField[44] = "215"; StairsField[45] = "220"; StairsField[46] = "225"; StairsField[47] = "230"; StairsField[48] = "235"; StairsField[49] = "240"; StairsField[50] = "245"; } /* initialize() */