/* * Concordance Programming Language * Export Transcripts to LiveNote .PTF files. * * This program exports the current transcript to a LiveNote .ptf file. * It only exports one transcript or deposition at a time. The database must * be a V7 or later transcript formattted database. Exported transcripts * can be imported into LiveNote or Concordance with all annotations and * issue coding in place. * * Dataflight Software, Inc. * 2337 Roscomare Road, Suite 11 * Los Angeles, CA 90077 * * (C) Copyright Dataflight Software, Inc. 2001. All Rights Reserved. * * Unauthorized distribution, adaptation or use may be * subject to civil and criminal penalties. * * You may incorporate this program into your own programs * ONLY if you incorporate the following copyright notice: * * Copyright (c) CURRENT-YEAR. YOUR NAME. ALL RIGHTS RESERVED. * Portions copyright (c) 2001 Dataflight Software, Inc. */ text szIssues[300]; int Issues; main() { int db, rc, i, fh, edited; text szText, szMail; char string[256]; /* Make sure we have the database fields we require. */ if ((isfield(db, "NAME") == FALSE) or (isfield(db,"TEXT") == FALSE) or (isfield(db,"STARTPAGE") == FALSE)) return(messageBox("This program exports transcripts to LiveNote format." + newline() + "This isn't a transcript database though.", program(), MB_ICONEXCLAMATION | MB_OK)); string = trim(db->NAME)+".ptf"; if (getfile("Export PTF File", "*.ptf", string) == CR) { if ((fh = open(string, "w+")) == EOF) messageBox("Couldn't create "+string, program(), MB_OK); else { Message("Working...", FALSE); WriteHeader(fh, db); WriteActiveIssues(fh,db); WriteAnnotations(fh, db); WriteTranscript(fh, db); close(fh); } } return; } /* main() */ /***************************************************************** * Name: WriteAnnotations * * Synopsis: Exports the text of the transcript in PTF format.* *****************************************************************/ WriteAnnotations(int fh, db) { text szText, szNote; char szTime[80]; int i, j, n, x, y, offset, length, counter; /* The begin= and end= sections are required even if */ /* if there are no annotations in the transcript! */ writeln(fh, szText = "begin=Annotations", len(szText)); if (j = annotationCount(db)) { counter = 1; for(annotationGoto(db, counter); counter <= j; annotationGoto(db, counter = counter + 1)) { /* pos= */ szNote = annotationRetrieve(db, "LINKOFFSET"); offset = num(szNote); szNote = annotationRetrieve(db, "LINKLENGTH"); length = num(szNote); i = 0; x = findline(db->TEXT, 1, y); while((offset > x + y) and (x > 0)) { x = findnline(db->TEXT, x, y); i = i + 1; } /* Is this a quick mark? */ if (length == 0) writeln(fh, szText = "quick="+str(i), len(szText)); else { writeln(fh, szText = "begin=anno", len(szText)); /* This note is in line i, zero-based. */ write(fh, szText = "pos="+str(i) + " " + str(offset - x), len(szText)); /* Now calculate the ending line and offset. */ i = 0; offset = offset + length; x = findline(db->TEXT, 1, y); while((offset > x + y) and (x > 0)) { x = findnline(db->TEXT, x, y); i = i + 1; } writeln(fh, szText = " " + str(i) + " " +str(offset - x), len(szText)); /* Now determine the issue numbers and write them to file. */ szNote = ""; for(i = 1; i <= Issues; i = i + 1) { if (annotationIsTagged(db, szIssues[i])) szNote = szNote + str(i) + " "; } if (len(szNote)) writeln(fh, szText = "issues="+szNote, len(szText)); /* Retrieve the note and write it to file. */ szNote= annotationRetrieve(db, "NOTETEXT"); if (len(szNote)) { writeln(fh, szText = "begin=note", len(szText)); n = 0; for(x = findline(szNote, 1, y); x <> 0; x = findnline(szNote, x, y)) { writeln(fh, szText = str(n)+"="+substr(szNote, x, y), len(szText)); n = n + 1; } writeln(fh, szText = "end=note", len(szText)); } /* Write the attachment to file, if there is an attachment. */ szNote= annotationRetrieve(db, "NOTEATTACHED"); if (len(szNote)) writeln(fh, szText = "attach="+szNote, len(szText)); /* End this annotation. */ writeln(fh, szText = "end=anno", len(szText)); } } } /* End the annotation section. */ writeln(fh, szText = "end=Annotations", len(szText)); /* quick=1 begin=anno pos=0 4 0 7 issues=2 3 5 1 begin=note 0=This annotation highlights the word "How" on 1=the first line. end=note end=anno */ } /* WriteAnnotations() */ /***************************************************************** * Name: WriteHeader * * Synopsis: Exports the text of the transcript in PTF format.* *****************************************************************/ WriteHeader(int fh, db) { text szText; char szTime[80]; int i, x, y; writeln(fh, szText = "begin=Head", len(szText)); writeln(fh, szText = "type=ptf", len(szText)); writeln(fh, szText = "version=1.3", len(szText)); writeln(fh, szText = "end=Head", len(szText)); writeln(fh, szText = "begin=CaseInfo", len(szText)); /* writeln(fh, szText = "path=d:\ftdemo\cases\_demo_.lnt", len(szText)); */ writeln(fh, szText = "name="+capitalize(FileName(db.database)), len(szText)); writeln(fh, szText = "end=CaseInfo", len(szText)); writeln(fh, szText = "begin=TranscriptInfo", len(szText)); szTime = " "+trim(db->TIME); for(i = 0; szTime[i]; i = i + 1) if (szTime[i] == ':') szTime[i] = ' '; writeln(fh, szText = "datetime="+str(year(db->DATE))+" "+str(month(db->DATE))+" "+str(day(db->DATE))+szTime, len(szText)); writeln(fh, szText = "name="+trim(db->NAME), len(szText)); writeln(fh, szText = "firstpage="+str(db->STARTPAGE), len(szText)); writeln(fh, szText = "pagelen="+str(db->LPP), len(szText)); /* Export comments if there are any. */ i = x = y = 0; if (len(db->COMMENTS)) { writeln(fh, szText = "begin=comments", len(szText)); for(x = findline(db->COMMENTS, 1, y); x <> 0; x = findnline(db->COMMENTS, x, y)) { writeln(fh, szText = str(i)+"="+substr(db->COMMENTS, x, y), len(szText)); i = i + 1; } writeln(fh, szText = "end=comments", len(szText)); } writeln(fh, szText = "end=TranscriptInfo", len(szText)); } /* WriteHeader() */ /***************************************************************** * Name: WriteActiveIssues * * Synopsis: Exports the text of the transcript in PTF format.* *****************************************************************/ WriteActiveIssues(int fh, db) { text szText; int i, j, bt, rc; char string[256]; /* This section is required even if there are no issues. */ /* This is not documented in the LiveNote documentation. */ writeln(fh, szText = "begin=ActiveIssues", len(szText)); bt = btopen(db.database+"-notes.tag"); if (bt <> EOF) { i = 0; for(rc = btfirst(bt, string, j); rc == 0; rc = btgt(bt, string, string, j)) { writeln(fh, szText = str(i = i + 1)+"="+string, len(szText)); /* Save the issue in the global array. */ szIssues[Issues = i] = string; } btclose(bt); } writeln(fh, szText = "end=ActiveIssues", len(szText)); /* This next section is required, but it is not documented that it is required. */ writeln(fh, szText = "begin=DeletedIssues", len(szText)); writeln(fh, szText = "end=DeletedIssues", len(szText)); } /* WriteActiveIssues() */ /***************************************************************** * Name: WriteTranscript * * Synopsis: Exports the text of the transcript in PTF format.* *****************************************************************/ WriteTranscript(int fh, db) { int i, x, y; text szText; writeln(fh, szText = "begin=Text", len(szText)); for(x = findline(db->TEXT, 1, y); x <> 0; x = findnline(db->TEXT, x, y)) { writeln(fh, szText = str(i)+"="+substr(db->TEXT, x, y), len(szText)); i = i + 1; /* Write the page break. */ if ((i mod db->LPP) == 0) writeln(fh, szText = "fmt=pb", len(szText)); Message("Exporting line "+str(i), FALSE); } writeln(fh, szText = "end=Text", len(szText)); } /**************************************************************** * Name: Message * * Synopsis: Displays error message and waits for key. * ****************************************************************/ Message(text message; int wait) { text screen; int key; cursoroff(); if (wait) screen = save(5,13,8,69); box(5,13,8,69, "3D", MenuColor_); puts(6,14,pad(message,'C',53),MenuColor_); if (wait) { key = getkey(); restore(5,13,screen); } return(asc(upper(chr(key)))); } /* Message() */ /**************************************************************** * Name: FileName * * Synopsis: Trims the path from the file name. * ****************************************************************/ FileName(text name) { int i; if (i = match(name,":",1)) name = substr(name,i+1); while(i = match(name,"\",1)) name = substr(name,i+1); return(name); } /* FileName() */ /**************************************************************** * Name: Path * * Synopsis: Trims the file name from the path. * ****************************************************************/ Path(text name) { int i, j; char string[257]; string = name; if (i = match(name,":",1)) j = i; else i = j = 1; while(j = match(name,"\", i)) i = j + 1; string[i - 1] = 0; return(string); } /* Path() */ RGB(char red, grn, blu) { return(((blu & 255) * 65536) | ((grn & 255) * 256) | (red & 255)); }