filePro Notes Routine "fPNotes" By: Howard Wolowitz Date: 3/15/99 Version: 01.00.00 (UNIX/MSDOS) INTRODUCTION fPNotes is an application extension that allows any filePro programmer to easily add free-form text to any filePro application. It is written totally in filePro's processing language and comes preset to allow up to 100 lines of 65 characters of text per entry to be associated with each record on a user defined "Master" files. There is no limit as to the number of 100-Line X 66-Char entries that can be created for each master record. There is no limit on the number of "Master" files that can use the fPNotes facility. fPNotes supports Insert Mode, Delete Character, Insert/Delete Line and Block Marking with Copy, Move and Paste operations. It maintains 10 Undo Buffers in a circular arrangement. It supports standard filePro keys such as F7 for end-of-data on a line, Tab, Left-Tab, Up, Down, Left, Right, Home Ctrl-End, Backspace, Break and ESC keys. It also supports the Browsing of all of the notes for a particular Master record, Searching by Keyword(s) across notes or within a single note. It can also Search and Replace text and Print the Note records. Each note is associated with a particular Master Record and a date or text and can be reviewed, edited and printed on-line at any time. In addition to normal text entry and word-wrapping, fPNotes can: - Supply "Boilerplate" paragraphs. - Merge data from the Master record into the Note. - Ask questions and allow free-form answers that are merged with the text. - Ask the user to pick an answer from a popup list of valid choices. - Supply specific paragraphs based on answers chosen. - Branch to additional "Canned Text" based on answers chosen. - Print Notes in normal or bold face on a line by line basis. Using these features, you can define "Pre-Canned" text so that a complex document can be generated by simply picking choices from popup "pick-list"s and answering simple questions. REQUIREMENTS The demo version of fPNotes requires the filePro 16 Plus Quickstart runtime. The full version of fPNotes requires either filePro 16 Plus Regular or Quickstart runtime. DEMO VERSION LIMITATIONS The demo version does not include the processing tables, only the token tables. The demo version will not add more than xxx records to the notes file. fPNotes CONTENTS Files The supplied fPNote system consists of five filePro files: A set of Header and Line Data files for the notes (NOTEHED and NOTELNS). Another set for the Pre-Canned text (TEXTHED and TEXTLNS). A demonstration "Master File" called NOTEDEMO. HOW TO INSTALL AND IMPLEMENT fPNotes 1-To unzip the files from the FPNOTES.ZIP file into the \filepro \fp and \fp\menus directories: From the root prompt on the drive where filePro is installed type: pkunzip -d a:\fpnotes.zip 1A- Try out fPNotes by typing: p demo. Take choice 1, choose record 1 and press N. Specify a date or, for today's date enter a Slash (/). Type in your free-form text and press ESC to record it. 1B- Try the Merge Text option by pressing a Back Slash (\) while updating or adding text. 2- Add the following code to your "Master"'s input processing table. BE SURE TO CHANGE ALL REFERENCES FROM notedemo TO THE NAME OF YOUR MASTER FILE @entsel If @cd="" Then end If Then show "\r N \r-Note Records" If Then end ... @keyN If @cd="" Then end If * Then system "\fp\rclerk notehed -sNTS -r \"notedemo|" { @rn { "\"" If Then end ... @keyD If * Then ky=@rn & "notedemo " If Then ms="OK To Delete This Record? \r Y \r or \r N \r >" If Then lookup notes = notehed k=KY i=a -nx If notes Then ms="WARNING...Record Contains Notes\n" & ms If Then input popup yn(1,yesno) ms: If yn ne "y" Then end If Then lookup lns = notelns k=KY i=a -bx dlns If lns(1) & lns(2) = ky Then delete lns; getnext lns; goto dlns notelp If not notes Then delete; end If notes(1) & notes(2) ne ky Then delete; end If Then delete notes; getnext notes; goto notelp * = lines that need to be changes for each master file. You can copy the above routines from the above listing. Remember: BE SURE TO CHANGE ALL REFERENCES FROM notedemo TO THE NAME OF YOUR MASTER FILE The way fpNotes is implemented (using a system call) insures that there are no changes required to your existing application data or structure. USING fPNotes Almost all of the keys used in editing are displayed at the bottom of the screen so little or no end-user documentation is required. Hidden is the ability to delete the Notes for a particular Day for a particular Master record. To do this, first highlight the entry in the Browse Window that appears when notes exist for a Master record, then press the Exclamation Point (!). When the system asks if it is OK to delete this entry, reply with another Exclamation Point (!) NOT A "Y". TO USE THE PRE-CANNED TEXT FEATURE: Press the Back Slash (\) key during text entry and at the point you want to merge in the precanned text. SYNTAX FOR PRE-CANNED TEXT The "Pre-canned" text is contained in the files TEXTHED and TEXTLNS. Each logical entry contains a name and a free-form block of merge text. If the name starts with a plus sign (+) the text block is only available to be called by other text blocks and is not displayed to the user when merge text is requested during Note entry. The body of the merge text can be entered or edited after you press ESC to record the text Name. Pre-Canned text can be used simply to supply common paragraphs for merging into your Note records. In addition, Pre-Canned text can interact directly with the end user. It can: ASKING QUESTIONS You can place questions to be asked of the user anywhere in the body of the pre-canned text by using the following syntax: Place "pipe" symbols (|) around the question's text. i.e.: |question text|. "question text" is what the user will be asked. The user's answer will be inserted at the point in the text at which the question is asked. SOUND A BEEP AT THE TIME A QUESTION IS ASKED If the "question text" starts with the plus sign character "+" then a beep will sound as the question is being asked. I.E. |+Please enter your name| REQUEST FREE-FORM ANSWERS If the above syntax |question text| is used then no pick-list is generated and the user can specify a free-form answer of any length. The answers are entered as a series of single 70 character lines until the user enters a blank line. SHOW A PICK-LIST OF VALID ANSWERS The syntax |question text *ans1*ans2*...*| is used to generate a pick list of allowed choices. The user will be required to choose one of the entries within the pick-list. Each choice MUST be preceded and MUST be followed by an *. The answer chosen will normally be placed at the current point in the text. NOT SHOW THE PICK-LIST CHOICE IN THE BODY OF THE NOTE By default, when the user chooses an entry from a pick-list, the word or phrase chosen is inserted at the point the pick-list was found. Sometimes it is not desirable to show one or more of the choices taken from a pick-list in the body of the resulting note. To prevent the choice from showing use a minus sign (-) in front of one or more of the allowed answers. I.E.: |question *ans1*-ans2*| Each answer that starts with a minus sign will be shown in the pick-list but will NOT be shown in the resulting body of the note if it is chosen. I.E.: There were |MASSES FOUND *-yes*no| masses found. If the user chooses "-yes" then the text will read: There were masses found. If the user chooses "no" then the text will read: There were no masses found. SUBSTITUTE TEXT AS A RESULT OF A PARTICULAR ANSWER After a question is asked fPNotes will remember the user's answer until the next question is asked. You can use this to substitute a string of text based on a particular answer. Use the syntax: |question *-ans1*-ans2*ans3*ans4*| [-ans1 text1] [-ans2 text2] [ans4 text4] This will substitute: "text1" if -ans1 is chosen, "text2" if -ans2 is chosen, "ans3" if ans3 is chosen and "ans4 text4" if ans4 is chosen. The string of text substituted can consist anything from a single word to multiple paragraphs. CONDITIONALLY BRANCH TO OTHER CANNED TEXT ENTRIES To branch to another Canned Text entry a plus sign (+) is added before the substituted text. The syntax is as follows: |question *-ans1*ans2*| [-ans1 +name1] [-ans2 +name2] If -ans1 is chosen then the text named "+name1" is loaded at this point in the resulting note. If -ans2 is chosen then "+name2" is loaded. You can specify the name of any existing text entry...even the one you are currently working on, as long as its name starts with a +. I.E.: within the Canned Text record called "+STUFF" the question: |MORE STUFF *-yes*-no*| [-yes +stuff] [-no +ending] will cause "+STUFF" to be reloaded If -yes is chosen and "+ENDING" to be loaded if -no is chosen. Note: to test for a NOT ANSWER condition add a Slash (\) in front of the answer being tested. I.E. The statement [/-ans is interperted to mean "IF -ANS WAS NOT CHOSEN". TAKE UNCONDITIONAL BRANCHES To cause the system to load a new body of text without first asking a question, make a pick-list with only one answer. Use the syntax: |question *-ans*| [-ans +name] Since there is only one answer in the pick list the, fPNotes will NOT ask the question and WILL set the answer to -ans. The [-ans +name] part tells fPNotes that if the answer was "-ans" then load the text named "+name". ASK ADDITIONAL QUESTIONS BASED ON ANSWERS TO PREVIOUS QUESTIONS The nesting of questions within conditional text is supported. This allows for a set of further questions to be asked based on a previous answer. I.E.: |WAS THE PROSTATE PALPATED *-yes*-no*| [-yes The prostate was palpated. It was found to be |HARDNESS OF PROSTATE *soft*firm*hard*|. It was |PROSTATE *normal*abnormal*|. [abnormal +abnormal-prostate] In the above example picking the "-no" answer to the WAS THE PROSTATE PALPATED? question will not generate any text. A "-yes" answer will generate some text and then ask two additional questions (hardness and normal/abnormal) about the prostate. Finally, if the normal/abnormal question was answered "abnormal", the text +abnormal-prostate will be loaded. NOTICE THAT THE TWO OPENING [s ARE UNBALANCED. THEY ARE BOTH TERMINATED BY THE SINGLE ]. PRINT LINES IN BOLD Any line that begins with the a backwards apostrophe character (`) will be printed in bold letters. The ` must be the first character on the line after any text has been merged. This means it always follows a line that ends with a paragraph mark. SPACES fPNotes DOES NOT ALLOW MORE THAN 1 SPACE IN A ROW. When notes are printed, fPNotes will insert a double space between sentences. After the merging of Pre-Canned text is complete, control is returned to the user and the resultant text can be reviewed, added to, modified, printed, saved or canceled. MERGE FIELD DATA FROM YOUR MASTER RECORD To merge field data from your Master record, place an asterisk (*) followed by the field number you want. This can appear anywhere in the Note or Pre-Canned text. Be careful not to specify a field number larger than the number of fields defined on your Master file. PRINT/PAGE CONTROL COMMANDS Print/Page Control Commands must be the first characters of a text line. They are always enclosed in { } {c} {cent} {center} -Centers all following lines {lft} {left} -Left Justifies all following lines {off} -Turns printing OFF for following lines {on} -Turn printing back ON for following lines {rem} {com} -Makes remander of current line non printing (comments) {sheet} -Sheet feed. Causes a pause before each page is printed {t} {top} {tof} {page} -Skips to top of form (see {len} for setting page length) {len}nn -Sets Page Length to nn {prt}nn -Set Print Lines per Page to nn {i}nn {in}nn {indent}nn -Causes all following lines to be indented nn characters {s}nn {skip}nn -Skips nn lines during printing KEYS TO BE AVOIDED Do not use the following keys in your Notes or Pre-Canned text: ^ @ ~ The ^ key is used for debugging. The ~ key is used internally to represent a back slash (\). The @ key will cause filePro to display the "Press Any Key To Continue" message at the bottom of the screen whenever the cursor passes over the @ character. fPNotes will run on all the flavors of NIX that filePro can run on. Comments, questions, new-feature-requests, clever-additions-you have-made, war-stories and bug-reports should be e-mailed to: howiewz@ix.netcom.com A NOTE FROM THE PROGRAMMER fPNotes is written in the best tradition of really bad spaghetti code. Any attempt at modifying it will certainly result in severe headaches, blurry vision, sleepless nights and probably won't work anyway. But, what the hell, give it a try. DISCLAIMER These routines have been in use since 1991 and have never screwed up any of my or my clients' data but, as usual, use of fPNotes is totally at your own risk! Neither I nor any company I am associated with assume any liability. I may even have introduced bugs when I attempted to clean up the code (ha!) so that it could be used by other filePro programmers. Good Luck Howie howiewz@ix.netcom.com