manual exsys

674
EXSYS Professional for Windowed Environments MANUAL ® © Copyright EXSYS Inc. 1983-1996 All rights reserved. All product names are trademarks of their respective manufacturers. Expert System Development Software

Upload: fernandoosor45

Post on 28-Nov-2014

490 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Manual Exsys

EXSYSProfessional forWindowedEnvironments

MANUAL

®

© Copyright EXSYS Inc. 1983-1996 All rights reserved.

All product names are trademarks of theirrespective manufacturers.

Expert SystemDevelopment Software

Page 2: Manual Exsys

Table of ContentsA Introduction

A1: System Requirements 5A2: Runtime License 6A3: Installing EXSYS Professional 7A4: Technical Support 9A5: Compatibility Between GUI EXSYS and Non-GUI EXSYS 10A6: Working in Multi-user Environments 11A7: Features in EXSYS Professional 13A8: EXSYS Professional Files 15

B Developing Expert System Knowledge BasesB1: What Can an Expert System Do? 1B2: How to Select an Appropriate Problem 2B3: Building an Expert System 5B4: Backward Chaining 14B5: Using Confidence Modes 19B6: Using the Command Language 22B7: Using the Report Generator 23B8: Creating Your First Expert System 24

C EXSYS Rule EditorC1: Starting the Rule Editor 2C2: Opening an Existing Knowledge Base 3C3: Starting a New Knowledge Base 4

Subject 4Author 4Confidence Mode 5Calculation Mode 9Threshold Level For Display of Results 10Derivation Mode 11Rule Display Mode 13Starting Text 14Ending Text 14Starting External Program 15Initial Choice Value 15Finished Setting Parameters 16Entering Choices 16

Table of Contents

Page 3: Manual Exsys

C4: Main System Title Screen 17C5: Saving the Changes to a Knowledge Base 18C6: Exiting the Editor 20C7: System Help 21C8: Copying Text from Other Applications 24C9: Adding a New Rule to the Knowledge Base 25C10: Editing a Rule in the Knowledge Base 26C11: Building a Rule 28

Positioning of New Conditions 28Adding a Qualifier Condition 29Adding / Editing a Qualifier 31Editing an Existing Qualifier Value 32Deleting an Existing Qualifier Value 33Options for Each Qualifier 33Qualifier Name 33Display of Qualifier Values with Results 34Maximum Number of Values 34Default Value 34Automatic Data Acquisition 36Custom Formula Systems 36Finished Setting Qualifier Parameters and Values 36

C12: Selecting Qualifier Values to Build a Condition 37Adding a New Value 39Correcting Typographical Errors 39Qualifier Conditions Combined with OR 39

C13: To Change the AND / OR Blocks 42C14: Using Qualifiers 43C15: Mathematical Expressions and Variables 45

Variables 45Math Expressions in the IF Part 45Math Expressions in the THEN/ELSE Part 46Building Math Conditions in a Rule 46THEN / ELSE Part 47Variable Parameters 48Entering the Expression to Assign 53Expressions 54Arithmetic Operators 54Boolean Operators 54ANSI Standard Order of Priority 56Conditional Tests 57

Table of Contents

Page 4: Manual Exsys

Approximately Equal Operator 57Syntax Checking 57Conditional Operator 58Functions 59Special Functions 61AGE Function 64

C16: Adding a Choice Condition 65Choices in the THEN/ELSE Part 65Choices in the IF Part 66Adding a New Choice 67Deleting a Choice 68Editing a Choice 68

C17: Adding a Command Condition 69C18: To Copy or Move a Condition 70C19: To Delete a Condition 72C20: To Change a Condition 72C21: To Scroll to the Previous or Next Rule 72C22: To Add / Edit the Note, Reference and Name 72

Note 72Reference 73Name 73

C23: To Repeat a Condition from the Previous Rule 75C24: Consistency Checking of New Rules 76C25: Deleting a Rule 79C26: Moving a Block of Rules 80C27: Printing a Knowledge Base 82C28: Displaying the Qualifiers, Variables or Choices 84C29: Running the Rules 85C30: Canceling a Run 86C31: Changing the Knowledge Base Parameters 87C32: Automatic Validation / Tree Diagrams 88

Introduction 88Running in Validation Mode 90Setting the Test Parameters 91Validation Results 95Custom Reports 97Validation Testing to Compare Versions of aKnowledge Base 98External Program Problems 99

C33: Examining Existing Tree Diagram Files 100

Table of Contents

Page 5: Manual Exsys

C34: Notebook 101C35: Asking for Help 102C36: Editing the Knowledge Base Text Files 103C37: The Questions Menu 104C38: Trace the History of the Run 105C39: Hypertext 107C40: Custom Formula Confidence 108

Using Custom Formulas Confidence System 108Confidence Variables 109Assigning a Confidence Formula 111User-Supplied Confidence Ratings 112

C41: Custom Help Screens 114C42: Loop Error Messages 115

D EXSYS Runtime

D1: Starting the RUNTIME 1D2: Opening an Existing Knowledge Base 2D3: System Help 3D4: Notebook 6D5: Display of Rules During Runtime 7D6: Title Screen 8D7: Starting Text 9D8: User Interaction 10

Asking for a Qualifier Value 10Asking for a Variable Value 12

D9: External Program Input 13D10: Custom Screens 13D11: Asking Why a Question is Being Asked 14D12: Asking for More Information on a Question 16D13: UNDO a Previous Answer 17D14: Save Input 18D15: Recover Input 19D16: Displaying the Known Data 20D17: Displaying the Status of the Choices 21D18: Displaying a Rule 23D19: Ending Text 26D20: Displaying Results 27

Confidence Modes 27D21: Change and Rerun 30

Table of Contents

Page 6: Manual Exsys

D22: Custom Results Screens 31D23: Existing the Runtime 32

E Configure OptionsE1: Editor/Runtime Configure Files 1E2: Knowledge Base Configure Files 2E3: Creating Configure Files 3

Change Connector Words 4Asks for Specified Data at the Start of a Run 5Calling an External Program After Change andRerun Commands 6Change the Name of the Configure File Used 7Allow Data from External Programs to be Modified During Change and Rerun 8Change the Name of the Command File Executed 9Control of Runtime Menu Options 10Automatically Reads a Series of Records of Data and Executes the Rules 11Change the Standard Ending Message if No Choicesare Set 13External Program Flag File Control 14Add Extra Space When Printing Rules 14Stops Execution When Any Choice Has a Final Value Set Greater Than 0 15Forward Chaining Options 16Sets an Alternate Knowledge Base Help File 22Limits Options Available to User of Runtime 23Turns Off Loop Error Checking 24Displays Choices Without Sorting by Value 24Switch Off Color Display 25Prevents Deletion of RETURN.DAT AfterReading 25Prevents Display of Results at Any Time 26Disables Option to Use Passwords 26Eliminates Starting Questions 27Do Not Display Title and Author 27Prevents Display of Values Assigned to Choices 28Prevents Backward Chaining on Simple Expressions 29Allows Choices with No Value Set to Test False 30Changes the Name of the File Used to Pass Data to External Programs 31

Table of Contents

Page 7: Manual Exsys

Load Password from Command Lineor .CFG File 32Reads Custom Help File When Rules are Read 33Recovers Data Saved Previously with QUIT 34Turns Off DISPLAY Command During"Change and Rerun" 35Releases Memory Used for String Variables 36Changes the Name of the Report Specification

To Be Used 37Turns Off Report Generator During"Change and Rerun" 38Changes the Default to Rerun Rules at End 39Changes the Name of File Used to Return Data from External Programs 40Changes How Rounding is Handled in Calculations 41Writes a File of Information on Rule Execution,Data and Other Functions 42Sets the Number of Times UNDO Can be Called 43Sets WORKING Screen Color 44Sets Printer Width 45

F Report GeneratorF1: Commands 1

Make a Beep Noise 2Print Data on Choices 3

Examples 5Close a File for Display 7Display a File in a Window 8Exit to the Operating System 10Select the Output File 11Print Text Only for First Set of Datain DATALIST 13Unconditional and Conditional Branches 14Print the Data Input by the User 16Print the Notes and References 17Data on Qualifiers 18

Examples 21Restart the System 22Call an External Program 23Save the Input Data for a RECOVER 24Print Text String 25

Table of Contents

Page 8: Manual Exsys

Print Data on Variables 26Options 28Examples 30

G Internal Commands and Data Acquisition

G1: Internal Commands in a Rule 1G2: Commands Used for Data Acquisition 2G3: Internal Command Window 4

Direct Command Input 4Blackboard Interface 5dBase III Interface 6Clear Out Known Data or Rules 13Read a File of Data 17Display a File in a Window 19Frame Interface 23LINDO Linear Programming Interface 23Lotus 123 Interface Commands 24Run a Report Specification File 29Run an External Program 31Stop Program Execution 32Table Interface 33

H External Program CallsH1: Syntax 2H2: RUN Command Window 7H3: Microsoft Windows Program Calls 8H4: Macintosh Program Calls 10H5: UNIX and VMS Program Calls 11H6: Returning Data to EXSYS 11

RAM Disks 14Erasing RETURN.DAT 14Passing Back a Command from anExternal Program 15Returning Hypertext Words fromExternal Programs 15

H7: Calling Programs from THEN/ELSE 16H8: Calling Programs from the Report Generator, Command File or Custom Screen File 18H9: Calling an External Program at the Start of a Run 19H10: Calling External Programs from Variables 20H11: Calling External Programs from Qualifiers 22

Table of Contents

Page 9: Manual Exsys

H12: Problems Calling External Programs 24H13: Calling External Programs - Summary 26H14: DATALIST: Analyzing a Multiple Record

Data Report 28H15: DATAREAD: Reading a File of Data 30

I Customizing the User Interface

I1: GUI Custom Screen Definition Language 2I2: Screen Files 3I3: Screen File Structure 4

Indicating the Qualifier or Variable 4Hypertext Keywords 5Custom Screens for Confidence Variables 5

I4: Returned Data 5Returning Commands 6Passing Back a Hypertext Call 7

I5: Syntax for a RCT 7I6: Setting the Window Size 8I7: Embedded Variables 8I8: GUI Custom Screen Commands 9I9: Custom Screen Examples 24I10: EXSYS_CS Custom Screen Preview 35I11: Custom Screens to Ask Questions 36I12: Context Sensitive Help Files 38I13: Hypertext 39

Defining Screens 40Flagging Keywords 40Using Keywords 41The .HYT File 41Example: 42

I14: Inserting Value Text in the Middle of Qualifiers 43I15: ASCII Codes 44I16: Embedding Data in Text 45

Variables 45Formulas 46Qualifiers 46Embedding Qualifier Values 47Embedding Expressions 48Recursive Brackets 48[[ ]] Replacement in the ReportGenerator and Command File 49

Table of Contents

Page 10: Manual Exsys

J Command LanguageJ1: Changing the Name of the Command File 2J2: Expressions and Variables 2

Request User Input for a Specific Item 3Make a Beep Noise to Alert User 4Branch Point Label 5Cause a "Change and Rerun" Option 6Allow Command Files to be Commented 7Erase Data or Reset Rules to Unused 8Call Another Command File 10Cause the Next Record of Data to be Read from a DATALIST File 11dBase III Interface Commands 12Display the Contents of a File 15Exit a Command File Called by AnotherCommand File 17Exit to the Operating System 18Unconditional Branch 19Allow Conditional Execution of Blocks of Rules 22Pause Until a Key is Pressed 24Recover Data saved with a QUIT or SAVEDATA Command 25Run a Report Generator Specification 26Display the Results of the Run 27Run the Rules or a Subset of the Rules 28Run an External Program 31Save the Current System Data 32Assign a Value to a Variable, Qualifier orChoice 33Execute a Block of rules While a Conditionis True 35

K Rule CompilerK1: Getting Started 2K2: Starting the Rule Compiler 4K3: Editing the Text Files 5K4: Producing Files That Can Be Compiled 5K5: Commands 7

Allow Comments to be Added to a File 9Define the Subject of the Expert System 10Define the Author of the Expert System 11

Table of Contents

Page 11: Manual Exsys

Define the Starting Text of the System 12Define the Ending Text of the System 13Define an External Program to Call at the Startof a Run 14Set the Threshold for Choice Display 15Define the Confidence System to be Used 16Set the Initial Choice Confidence Value 18Set Option to Display Rules as a System Runs 19Set Option for How Many Rules to Use inDeriving Information 20Define List of Qualifiers and Parameters 21New Qualifiers or Values Found in the Rules 26Define List of Variables and Parameters 27Text Only Variables Found in the Rules 31Define List of Choices 32Use Only Defined Qualifiers, Variables andChoices 33Define a Rule 34Qualifier Conditions in Rules 36Choice Conditions in Rules 38Formula Conditions in Rules 40Text Conditions in Rules 42NOTE and REFERENCE Text 44Special Cases 45Set Space Allocated for Compile 47

K6: Error Messages 48

L Frame and Table Interface

L1: TABLE and NTABLE 1Data Table Syntax 1

L2: Frame 3What is a Frame 3Specifying a Slot 4Specifying the Frame Row 6How to Create a Frame 7Inheritance 8

L3: Reading from a Frame 11L4: Writing to a Frame 12L5: Examples 13L6: Including FRAME and TABLE in Your Expert System 14

Table of Contents

Page 12: Manual Exsys

M Blackboard ManagerM1: Introduction 1

Recommended Uses for EXSYSBB 1EXSYSBB Blackboards 1Communication Between EXSYSBB and YourApplications 2

M2: Calling EXSYSBB 2

M3: Including EXSYSBB in Your Expert System 3Associated with a Qualifier or Variable 3Run as the Result of a Rule Firing 4From the Command Language 4From the Report Generator 4From the Screen Definition Language 4Called from the Operating System 4Called from Other Programs 4

M4: Blackboard Command Window 5M5: Reading From a Blackboard 6M6: Writing to a Blackboard 7M7: Deleting Data From a Blackboard 8M8: Attributes and Values 9M9: Parameters 11M10: External Call Values (demons): 17M11: Operating Modes 18M12: Error Messages 19M13: Common Errors 20

N LINDO Interface

N1: Introduction 1N2: Calling the LINDO Specification File 2

LINDO Specification File 3N3: Model Commands 5N4: ~IF test expression, ~ELSE, ~ENDIF 6N5: ~Results 7N6: Return Data Commands 7

LINDO Data ID 7N7: Sample EXSYS / LINDO Interface 12

Table of Contents

Page 13: Manual Exsys

O Utility ProgramsO1: Compressing Edited Files 1O2: Rule Organizer 2O3: Moving Files Between Operating Systems 3O4: Pager 4O5: EX_TIME 7O6: Repeat 10O7: EXSQ - Report File Squeezer 11

P SQL CommandsIntroduction 1P1: Installation 1

DLL Notes 2INTERSOLV 2SQL Interface Technical Support 3Backward Compatibility 3

P2: SQL Commands 4Reading a Single Item of Data into a SingleEXSYS Variable 4SQL Commands that Return Multiple Items of Data 5

P3: Connecting to the Database 6Connection Strings 7

P4: Executing an SQL Command 8Selecting the Next Record of Returned Data 8Selecting the Previous Record of Returned Data 9Selecting a Random Record of Returned Data 10Finding the Number of Records of Returned Data 10Creating Random Access Buffers for Returned Data 11Releasing the Data Returned from an SQLCommand 11Disconnecting from a Database 12Reading a Specific Field of Returned Data 12Reading the Name of a Column of Returned Data 13Reading the Number of Columns ofReturned Data 13

P5: Transactions 14Beginning a Transaction 14Committing a Transaction 14Canceling a Transaction 15

P6: Using SQL Commands 15Some Basic SQL Commands 16

Table of Contents

Page 14: Manual Exsys

Q ExDesign Custom Screen Design Program

Q1: Introduction 1Q2: Master System Help 1Q3: File Menu 1

New 2Open 3Save 4SaveAs 5Print 5Exit 5About 5Adding a New Screen 5

Q4: Object Menu 6Return Strings 7Rectangles 9Push Button 9Radio Button 11Check Box 12Slide Bar 13Edit Box 15Line 18Arrow 19Oval 20Rectangle 20Rounded Rectangle 21Text 21Mouse Box 22PCX 24Meters 25List Boxes, Buttons and Edits 27

Q5: Aligning Objects 31Q6: Selecting Multiple Objects 32

R Fuzzy Logic

R1: Introduction 1How Fuzzy Logic Is Implemented in EXSYS Professional 3Defuzzification 6Advantage of Fuzzy Sets 7IF / THEN Only 8

Table of Contents

Page 15: Manual Exsys

R2: Building Fuzzy Systems - The Mechanics 8Starting a System 8Fuzzifying a Qualifier 9Choices in a Fuzzy System 15

R3: Defuzzifying a Variable 18Validation and Defuzzified Variables 20

R4: Building Fuzzy Systems - Techniques and Demos 21When 21How 22Demos 25

R5: Graphing Validation Data 26Setting Constraints 27Display Variables 29Examining Values on the Graph 29Constraints on the Validation Graph 30

R6: Combination of Confidence 30IF PART 30Qualifier Conditions 31Variable Conditions 33Choice Conditions 34Overall IF Confidence 34If Conditions Summary 36Rule Confidence Threshold 36THEN PART 37Choices (THEN Part) 37Qualifiers (THEN Part) 39Variables (THEN Part) 39Changing the Way Confidence is Combined 40

S Screen Templates

Introduction 1S1: Using Templates 2S2: To Add Templates to Your System 2S3: Previewing Your Screens 3S4: Template Designs 3

Template Styles: 4 - 14S5: Modifying / Creating Your Own Templates 15S6: Editing an Existing Template 19S7: Handling Individual Screens 19

Table of Contents

Page 16: Manual Exsys

Chapter A

Introduction

At EXSYS Inc., we believe that expert systems will be widelyimplemented only if the systems are easy to build. Having the expertsbuild the systems themselves can produce large numbers of systemsrapidly. The widespread use of smaller expert systems is often farmore effective than one large expert system. This approach requiresthat the tools to build the system be easy to use. It is not reasonableto ask experts to spend 6 months learning how to use an expertsystem tool, but it is reasonable to ask them to spend a few days. Tobe implemented effectively, an expert system shell must not besignificantly more difficult to use than a word processor. It isreasonable to ask experts to build their own expert systems, only ifthe shell is easy to use. We believe that this is the future of expertsystems. The goal at EXSYS is to provide easy-to-use tools so thatpeople can build their own expert systems.

Both developers and users of expert systems have become moresophisticated. End users now request more from an expert systemthan a few years ago. A few years ago, simple systems wereconsidered major accomplishments. Now users expect more powerand flexibility in an expert system and developers of such systemsrequire the tools to build them. In order to meet this goal, EXSYSProfessional was created.

EXSYS Professional offers a new level of sophistication toknowledge engineers developing expert systems, while retaining theeasy-to-use EXSYS interface that has proven so successful. EXSYSProfessional provides many commands to modify the defaultoperation of the shell. If these new capabilities are not used, EXSYSProfessional automatically uses safe defaults.

EXSYS Professional is a generalized expert system developmentpackage. An Expert system is a type of artificial intelligence programthat emulates the interaction a user might have with a human expertto solve a problem. The user answers by selecting one or moreanswers from a list or by entering data. The computer will continueto ask questions until it has reached a conclusion. The conclusion maybe the selection of a single solution or a list of possible solutionsarranged in order of likelihood. The computer can explain, in English,how it arrived at its conclusion and why.

A - INTRODUCTION 1

Page 17: Manual Exsys

Expert systems can be developed with EXSYS for any problem thatinvolves a selection from among a definable group of choices wherethe decision is based on logical rules. The rules can involve relativeprobabilities of a choice being correct. Any area where a person orgroup has special expertise needed by others is a possible area forEXSYS. Expert systems can help automate anything fromautomating complex regulations to aiding customers in selecting fromamong a group of products, from automated user assistance toidentification of diseases or problems with a piece of equipment ispossible.

Expert systems deal with knowledge rather than data and the filesthey use are often referred to as knowledge bases. The rules that theprogram uses are IF-THEN-ELSE type rules. A rule is made up of alist of IF conditions (normal English sentences or algebraicexpressions) and lists of THEN and ELSE conditions (moresentences) or statements about the probability of a particular choicebeing the appropriate solution to the problem. If the computerdetermines that all IF conditions in a rule are true it adds the rule'sTHEN conditions to what it knows to be true. If any of the IFconditions are false, the ELSE conditions are added to what isknown. The computer determines what additional information itneeds and how best to get the information. If possible, the programwill derive information from other rules rather than asking the user.This ability to derive information allows the program to combinemany small pieces of knowledge to arrive at logical conclusions aboutcomplex problems. The rule editor allows the rules to be easilymodified, added or deleted.

The final goal of an expert system is to select the most appropriatesolution to a problem based on the data input by the user. If morethan one solution is possible the program will provide a list of thepossible solutions arranged in order of probability.

Essentially all of the instruction necessary to run an expert systemknowledge base is provided by the program and all output is inEnglish. Little or no training is required to run an already developedknowledge base.

The principal development tool in EXSYS Professional is the EXSYSProfessional Rule Editor. It enables you to rapidly generate your ownexpert system knowledge bases. All options available to you aredisplayed on the screen. The "Learning to Use EXSYS Professional"videotape takes you step-by-step through a series of lessons on thegeneration of your own expert system knowledge bases. Whenrunning the rule editor, help screens are available for more detailedinformation on command options. All input is in the form of normalEnglish text or algebraic expression. Since most of the input to theprogram comes from items selected from a list, virtually all of thetypo problems that can confuse some expert system developmentprograms are effectively eliminated. New rules entered are checked

A - INTRODUCTION 2

Page 18: Manual Exsys

against the existing rules for consistency. The final decision onwhether or not a rule should be included is left up to you. You havevarious options for assigning and combining probability values.

EXSYS Professional also includes a rule compiler that allows you tocreate or edit rules with a word processor and then compile the rulesfor use with the EXSYS Professional Runtime or Editor. In general,we believe that it is better to use the EXSYS Professional RuleEditor, rather than a text editor, to create and edit rules. The RuleEditor is faster, easier and provides error checking. However, thereare times when having the ability to edit the rules directly can bevery powerful. Also, the rule compiler allows other programs togenerate EXSYS rules which can be compiled into the EXSYSProfessional form. It is even possible to have expert systems thatcreate their own new rules which can be added to make the systemsmore capable.

We feel that EXSYS Professional offers the correct balance of powerwith ease-of-use. Very complex expert system problems can behandled in EXSYS Professional, but a new user will still be able tolearn to create systems in a few days. Also, EXSYS Professional willcontinue to grow. As users continue to suggest new features, theywill be added to the program to make it even more capable.

EXSYS Professional is easy to use, no special languages are neededand all input is in the form of either English text, algebraicexpression or menu selection. The developer of an expert systemworks within the EXSYS Professional Rule Editor, which providesmenus, prompts and help. It is not necessary to memorize complexrule syntax. EXSYS Professional also includes a rule compiler thatallows development or editing of knowledge bases with a wordprocessor.

For more complex applications and increased control, there is acommand language that can be used to control the execution of theexpert system. The command language gives the developer greatercontrol and flexibility in developing rule based systems. Rule sub-sets, looping and conditional tests are part of the command language.

EXSYS Professional expert systems can be run by an end user withessentially no training. The end user of the expert system can askHOW conclusions were reached or WHY information is needed. Theprogram will respond with a full explanation of the logic used toarrive at the conclusion, including backward chaining and externalprogram calls for data. The developer can customize screens anddecide what options are available to the end user. For particularlylarge or complex problems, blackboarding can be utilized to divide aproblem into smaller expert systems that communicate through acommon data file (a "blackboard").

A - INTRODUCTION 3

Page 19: Manual Exsys

The EXSYS editor, runtime and utility programs are written in C forhigh speed and efficient utilization of memory.

Expert systems developed with EXSYS Professional function thesame way on Microsoft Windows, VAX/VMS Motif, Macintosh SunOpen Look and OS/2 Presentation Manager computers. TheEXSYS application need only be moved to the new environment andrun with the appropriate runtime program. EXSYS versions are alsoavailable in Japanese (with kanji support for Kanji MS-DOS andKanji Unix computers) and Spanish.

A - INTRODUCTION 4

Page 20: Manual Exsys

A1: System Requirements

IBM PC or compatible

2 Meg RAMHard diskVGA MonitorMicrosoft Windows

MacintoshAll Macintosh computers are supported exceptthe Classic. EXSYS will run on the Classic, butsome buttons will be off the screen.4 Meg RAMHard diskSystem 6 or System 7

DEC VAX/VMS

EXSYS runs on all DEC VAX computers running VMS Motif. EXSYS is a small programfor the VAX and runs in all configurations.

UNIXEXSYS runs on many UNIX computers. EXSYS is a small program for all but the smallestUNIX computers and should run in all configurations.

A - INTRODUCTION 5

Page 21: Manual Exsys

A2: Runtime License

The EXSYS software is not "copy protected." Copy protectionmakes a program more difficult to use and adds to the cost of thesoftware. The intention throughout the development of EXSYSProfessional has been to make it easy and user friendly and to bringyou a quality, supported software package. We feel that copyprotection runs contrary to these goals. The Runtime programsupplied in with the development environment is for developmentonly. It will display a message at the start of each session remindingyou of this. A copy of the runtime that does not display this messageis provided when you purchase a Runtime License.

A Runtime license is required to distribute copies of the EXSYSProfessional Runtime program. There are two separate licensecategories: commercial and non-commercial. The non-commercialRuntime license entitles the developer to distribute applications to anunlimited number of users on a non-commercial basis--that is, aslong as the application is not sold by itself or as part of a package thatis sold. The applications can be given away, distributed to co-workers, or in other ways distributed in a non-profit manner.

The commercial license is intended for those individuals planningto market their applications. We believe that if an application ismarketed, part of its capability and sales value comes from theEXSYS software and that EXSYS should receive a small paymentper copy of the program marketed. Consequently we have institutedthe Commercial Runtime License. Contact EXSYS Inc. forinformation on Commercial Runtime Licenses

Note: Please remember, even if you havea Runtime license, the license agreementprohibits sub-licensing. That is, you cannot give a copy of the Runtime to someoneelse and have them distribute it to others.All distribution must be from a licenseholder. If person A has a runtime licenseand creates an application which he or shegives to person B, person B cannot makeadditional copies, unless they obtain theirown Runtime license.

Runtime licenses are also available for versions of EXSYSProfessional running on other operating systems.

A - INTRODUCTION 6

Page 22: Manual Exsys

A3: Installing EXSYS Professional

MS WindowsOS/2 (Presentation Manager)

Exit Windows (or Presentation Manager) and return to theDOS level.

Select the drive to install to by entering the drive letter, forexample:

C:

Create a new directory called EXSYSP on your hard disk withthe DOS command

MD \EXSYSP

Make this new directory the default directory by entering

CD \EXSYSP

Copy the contents of all of the disks to the new directory byputting the distribution floppy disk in drive A and entering

COPY A:*.* C:\EXSYSP /V

Once EXSYS Professional is installed on the hard disk, storethe distribution disk in a safe place.

Macintosh

Create a new folder called EXSYS on your hard disk byselecting New Folder.

Insert the distribution disks and copy all files and programs inthe disk into the EXSYS folder.

Once EXSYS Professional is installed on the hard disk, storethe distribution disk in a safe place.

A - INTRODUCTION 7

Page 23: Manual Exsys

DEC VAX/VMS Computers

The program is supplied on one TK-50 tape. Create adirectory named [EXSYS]. Copy the contents of the tape into[EXSYS]. The tape is a save_set labeled EXSYS. Allparameters such as block size, etc. are default VMS settings.

When a new program is added to VAX/VMS, you must install thenew command or use the RUN command.

The RUN command is used by entering:

RUN EXSYSP

If RUN is used, you cannot pass argument vectors to the program.

To install a new command, you must enter the following at the VMS$ prompt.

EXSYSP := $[directory]EXSYSP.EXEEDITXSP := $[directory]EDITXSP.EXE

This will allow you to call EXSYSP or EDITXSP without using RUNand will allow you to pass in a knowledge base name or usecommand line options. For example, you can enter EXSYSPPCDEMO.

UNIXComputers

The UNIX version of EXSYS Professional is distributed on a"tar" tape for the specific target computer. The instructions onthe device driver to use are provided with the tape.

A - INTRODUCTION 8

Page 24: Manual Exsys

A4: Technical Support

If you encounter problems using EXSYS

1. Run the expert system TECHHELP to see if it can solve yourproblem. To run this system, enter click on the EXSYSP icon tostart the runtime program. Select Open from the main menu andselect TECHELP.RUL in the EXSYSP directory.

2. Re-read the manual section related to the problem.

3. If you are still having problems, give us a call at (505) 256-8356from 9:00-5:00 PM Mountain time Monday to Friday or Email:tnexsys@pop,nm.org. After hours you can leave a message on ananswering machine and we'll call you back. If you are calling fortechnical support, please have your registration number and versionnumber handy.

Please have a detailed description of the problem, what the programdid or did not do, what other operations were being done, etc. Thereis an enormous number of command combinations possible inEXSYS Professional. If you are having a problem, it may be due toa combination of commands. In some cases it will not be possible forus to fully understand what the problem is or be able to correct itwithout seeing the actual rules being run. If we can not reproducethe problem, we may ask that you send us a copy of your rules or asample system that shows the problem.

A - INTRODUCTION 9

Page 25: Manual Exsys

A5: Compatibility Between GUI EXSYS and Non-GUI EXSYS

The GUI versions (MS Windows, Macintosh, VMS Motif, Sun OpenLook and Presentation Manager) of EXSYS Professional can readfiles created with the non-GUI versions of EXSYS withoutmodification.

All files will be identical, except:

1. The GUI custom screen language is different from theNon-GUI custom screen language.

2. The command language commands for positioning thecursor and writing to the screen are not supported.

3. Certain configuration options which have no meaning in aGUI environment are not supported.

With the exception of three items above, an expert system developedwith the Non-GUI version of EXSYS should run in the GUI versionswithout modification.

A - INTRODUCTION 10

Page 26: Manual Exsys

A6: Working in Multi-user Environments

When EXSYS Professional is used in a multi-user environment, somespecial precautions have to be taken to prevent inadvertent clashesbetween users. For example, if two users are accessing the sameexpert system which calls an external program, their RETURN.DATfiles could overwrite each other. Likewise, reports and other outputcould be confused.

To avoid this, EXSYS Professional checks the environment variableEXSYS to see if it exists and has a path associated with it. If theenvironment variable EXSYS has a path associated with it, all userspecific files will be written to or read from files preceded by thatpath. This is similar to using the HOME path in UNIX. It is possibleto override the addition of the path when necessary. If thespecification for a read or write in the rules starts with

\ in DOS or OS/2/ in UNIX[ in VMS

the path from the EXSYS environment variable will NOT be used.

The path associated with the environment variable must end in away that a file name can be appended to it to make a legal path.

For example, suppose in UNIX the environment variable EXSYS is\RULES\MY_DATA\

The report command: FILE ABCDwould actually open a file: \RULES\MY_DATA\ABCD

However, the command FILE \OTHER\ABCDwould not have the path added and would open\OTHER\ABCD

Likewise, a run command would look for the RETURN.DATfile in \RULES\MY_DATA\RETURN.DAT

The addition of the path applies to all files created or read that areunique to a particular user: DATALIST, RETURN.DAT,PASS.DAT, and report output files. The path is not applied to filesused by the system: .RUL, .TXT, .OUT, .CMD, .HLP, .SCR, .CFGfiles or external program calls.

A - INTRODUCTION 11

Page 27: Manual Exsys

The use of the environment variable EXSYS makes the path dataavailable to called external programs. If this approach is being used,make sure the called external program also reads the environmentvariable and writes the RETURN.DAT file to the correct location.

Note: See your operating system manual forinformation on setting environment variables.Environment variables are not supported onthe Macintosh.

You should also store the EXSYS Professional .HLP files in a singledirectory accessible by all users. Normally the .HLP files are lookedfor in the current directory. Adding the command line or .CFGoption

EXSYS_HELP=<path>

causes EXSYS Professional to look on this path for the help filesneeded. This command would normally be put in the filesEXSYSP.CFG and EDITXSP.CFG configure file.

A - INTRODUCTION 12

Page 28: Manual Exsys

A7: Features in EXSYS Professional

Inference Engine:IF/THEN/ELSE Production RulesAND / OR ConditionsUp to 128 Conditions in IF/THEN/ELSEUp to 64 OR Groups in a RuleMinimum Questions to UserBackward/Forward Chaining (w. Subsets)Procedural Command LanguageRule Sub-setsRule NamesAutomatic Chaining on VariablesSub-goal ConfidenceFive Confidence SystemsBlackboardingDynamic Agenda ManagerBatch Mode ProcessingChange and RerunClear (Forget) DataUNDO Previous Input (10 levels)Complex Boolean ExpressionsAdvanced Math FunctionsArray FunctionsTable Look-upFrame Data with Inheritance

Developer Environment:Rule Editor with Context KnowledgeRule Compiler (Text Editor Files)Procedural Command LanguageIncremental CompileRun or Edit with Single KeystrokeAutomatic Consistency CheckingAutomatic Global ChangeRule NamesReference by NameColor CodingMenu DrivenRepeat ConditionsWhereTitle/Author OptionStart/End Text OptionConfigure File OptionsUser Menu ControlReport Generator Language

A - INTRODUCTION 13

Page 29: Manual Exsys

Custom Screen LanguageCustom Hypertext FilesInterface Command GeneratorOR Block Validity CheckingCross Reference ListingsRule Compiler Format OutputC Code Output Format

External Interface:Linear Programming (LINDO)External Program calls: Front End Data Dependent Rule Dependent Command Language Report DependentDirect Lotus 123 InterfaceDirect dBase III InterfaceGraphics InterfaceMenu Driven Command Definition

End User Interface:Default Question FormatCustom Screen DefinitionWHY and HOWDisplay Known DataRule NotesUser Help: Hypertext System Help Custom Help Screens Help with Custom Hypertext Help with External ProgramsRule Reference DataVariable Data Embedded in Help Messages or HypertextEasily Readable RulesOption ControlsInput Verification with Custom MessagesColor Coding of Conditions

A - INTRODUCTION 14

Page 30: Manual Exsys

A8: EXSYS Professional Files

EXSYS Professional uses a number of files to store, configure, runand communicate between expert systems. The files below aremarked as EXECUTABLE (the name entered to call the programfrom the operating system, or there is an executable icon to click on),REQUIRED (needed to run a knowledge base) or OPTIONAL (notrequired except to perform a special function). Files marked with an* are created by the user and are not on the distribution disks. <ESname> is the name of the expert system file created by a user.

EDITXSP.CFGThe configure file for all knowledge bases runwith EDITXSP.EXE. This file isautomatically read whenever EDITXSP.EXEis used and the configure commandsimplemented (This is an ASCII file createdand edited with a text editor). OPTIONAL

EDITXSP(.EXE)The EXSYS Professional editor program forcreating and editing knowledge bases. This isthe program used to modify EXSYSProfessional rules, qualifiers, formulas, etc.EDITXSP has the ability to run knowledgebases during development. EXECUTABLE

EXSYSP.CFGThe configure file for all knowledge bases runwith EXSYSP.EXE. This file is automaticallyread whenever EXSYSP.EXE is used and theconfigure commands implemented. (This isan ASCII file created and edited with a texteditor.) OPTIONAL

EDITXSP.HLP The EXSYS Professional Editor help file.This file contains the help informationdisplayed from EDITXSP. (This file shouldnot be modified.) REQUIRED

A - INTRODUCTION 15

Page 31: Manual Exsys

EXSYSP(.EXE) The EXSYS Professional Runtime program.This is the program for running existing, fullydeveloped knowledge bases. EXECUTABLE

EXSYSP.HLP The EXSYS Professional help file. This filecontains the help information displayed fromEXSYSP. (This file should not be modified.)REQUIRED

EXSYSRC(.EXE)The EXSYS Professional Rule Compiler.Used for compiling knowledge basesdeveloped or edited in a word processor. Thisprogram produces files that can be used withEXSYSP or EDITXSP. EXECUTABLE

EXSYSRC.HLP The EXSYS Professional Rule Compiler helpfile. This file contains the help informationdisplayed from EXSYSRC. (This file shouldnot be modified.) REQUIRED

EXSYS-CS(.EXE)The EXSYS Professional Screen DisplayUtility. Used for displaying custom screens.EXECUTABLE

EXSYS_CS.HLP The EXSYS Professional Screen Display helpfile. This file contains the help informationdisplayed from EXSYS_CS. (This file shouldnot be modified.) REQUIRED

PASS.DAT* The default file to pass data from EXSYSProfessional to external programs. The nameof this file can be changed as a command lineoption or in the .CFG file with PASS= (This isan ASCII file created by EXSYS).OPTIONAL

RETURN.DAT* The default file to return data to EXSYSProfessional from external program calls orDATALIST commands. The name of this filecan be changed as a command line option orin the .CFG file with RETURN= (This is anASCII file created by the external programcalled). OPTIONAL

A - INTRODUCTION 16

Page 32: Manual Exsys

<ES name>.CFG*The configure file associated with the specifiedknowledge base. This file is automaticallyread whenever the specified knowledge baseis used and the configure commandsimplemented (This is an ASCII file createdand edited with a text editor). OPTIONAL

<ES name>.CMD*The command file associated with thespecified knowledge base. This file wouldcontain commands controlling order of ruleexecution, looping, etc. It would override thenormal EXSYS Professional backward orforward chaining modes. OPTIONAL

<ES name>.HLP*The custom help file data. This file containsthe custom help information for qualifiers andvariables to be used with the specifiedknowledge base (This is an ASCII file createdand edited with a text editor) OPTIONAL

<ES name>.HYT*A file created by EXSYS Professional ofoffset information for the .SCR file. This fileshould never be modified by theuser.GENERATED BY EXSYS

<ES name>.OUT*The report generator specification file for thespecified knowledge base. This file containsthe report generator commands to be usedwhen the knowledge base has completed itsrun (This is an ASCII file created and editedwith a text editor). OPTIONAL

<ES name>.RUL*The rule file associated with the specifiedknowledge base. This file contains the textindependent numeric representation of theknowledge base rules. The contents of the fileare read when EXSYS or EDITXS reads therules (This file is modified by the editorEDITXS.EXE and should not be changed byany other program). REQUIRED

A - INTRODUCTION 17

Page 33: Manual Exsys

<ES name>.SCR*The screen definition file associated with thespecified knowledge base. This file containsdefinitions for some or all of the qualifiers andvariables in EXSYS Professional. This screenwould be used to ask the end user for data.OPTIONAL

<ES name>.TXT*The text file associated with the specifiedknowledge base. This file contains the textportion of the EXSYS rules. The contents ofthe file is accessed when text must displayedto the user (This file is modified by the editorEDITXS.EXE and should not be changed byany other program). REQUIRED

TECHHELP.*A technical support expert system. If youhave problems running EXSYS Professional,this should be able to answer many of yourquestions.

A - INTRODUCTION 18

Page 34: Manual Exsys

Chapter B

Developing Expert SystemKnowledge Bases

B1: What Can an Expert System Do?

The first question in considering the development of an expert systemis "Why build an expert system?" Expert systems cannot solve allproblems. Understanding why an expert system is desired,understanding what type of system it must be and how it must workare primary questions.

The usual reasons for building an expert system are to

Disseminate problem-solving knowledge, not just facts,with minimal training of end users.

Standardize the conclusions for a given set of data.

Interface with other programs and provide analyticalcapability.

Free a human expert from repetitive, routine jobs inorder to do activities an expert system cannot do.

Codify a problem-solving technique for future users.

Provide a safe and effective training tool.

Allow the problem-solving skills of several people to becombined.

The goal of a particular expert-system project may be a combinationof several of the above. Before developing an expert system, firstdecide on the goals. A system designed to automatically analyze aspreadsheet may be very different from one designed to provide aproblem-solving capability or training of users.

B - DEVELOPING EXPERT SYSTEMS 1

Page 35: Manual Exsys

B2: How to Select An Appropriate Problem

An unlimited number of problems can be solved by an expertsystem. In theory, any decision-making process can be converted toan expert system; however, in practice, many problems cannot beeffectively converted. For example, a problem may be incompletelyunderstood or be just too large or complex for conversion to anexpert system. The most important first step in developing an expertsystem is to define an appropriate problem.

Often, even if a large problem cannot be solved, part of the problemcan be. Factors that should be considered in defining a problem forthe expert system include:

1. Does a human know how to solve the problem?If no human expert can solve the problem, it is not possible todevelop rules describing the solution. The techniques of solving theproblem must be known and defined in order to create an expertsystem.

2. Does the problem have a definable solution?EXSYS Professional and most other expert system shells aredesigned to select one or more possible solutions from a group. If allof the possible solutions cannot be specified, writing rules to solve theproblem is difficult. Some problems can be handled that have a verylarge number of solutions, configuration problems are a goodexample, but a definable set of possible solutions is known.

B - DEVELOPING EXPERT SYSTEMS 2

Page 36: Manual Exsys

3. Is the level of understanding and scope appropriate?A graph can best illustrate the question. The level of understanding ison the horizontal axis ranging from limited understanding (a simple,well defined solution) to deep understanding (a solution requiringinsight and innovation). The other axis is the scope of the problem,ranging from very specific to very wide problems.

Scope

Wide

Specific

Limited DeepLevel of Understanding

Problems

ExpertSystems

Defining the problem to fall within the shaded area of the graph isvery important. A problem that has too wide a scope or thatrequires too deep a level of understanding is not appropriate for anexpert-system solution. Expert systems cannot emulate deepunderstanding with insightful solutions to new problems. As thescope of the problem gets larger and larger, the number of rulesnecessary to express the problem becomes very large. To solveproblems with a wide scope, first narrow the scope and solve a smallpart of the problem. Once that part works, do another part of theproblem. Eventually the collection of expert systems can solve awide range of problems.

Keeping realistic goals is very important. An human expert cannotbe captured in a computer; only a small part of the problem-solvingskill can be expressed in an expert system. A human expert cansolve new problems based on experience and intelligence; a computercannot. However, the expert system can solve the specific problemsit has been designed for and will do so for many non-expert users, 24hours a day. Moreover, the expert system gives consistent answersand usually faster than the human expert can.

B - DEVELOPING EXPERT SYSTEMS 3

Page 37: Manual Exsys

4. Has the technique for solving the problem beendocumented?A vast number of problems meet the requirements for successful,worthwhile, and effective expert-system development. Remember,an expert system does not have to solve a major problem to beworthwhile. Any area where one person possesses a problem-solvingskill that is needed by others is often well documented and has goodpotential for an expert system. The areas may seem very mundaneor uninteresting, but these are often the best for expert systemdevelopment because they are well understood and well documented.

The solution may be a decision tree, manual procedure, regulations,or specific, written instructions. Such well-defined problems can beeasily converted to expert systems and the solution is made moreaccessible to end users through an expert system. Solving a problemwith an expert system is much easier than looking up procedures in amanual and less prone to error.

B - DEVELOPING EXPERT SYSTEMS 4

Page 38: Manual Exsys

B3: Building an Expert System

Once a suitable problem has been defined, the problem-solvingtechniques must be converted to expert system rules. A particularproblem may be solved in a variety of ways. Different expert systemdevelopers have different approaches and techniques of preference.Some developers write backward-chaining systems while othersprefer forward chaining. Some use modular systems withblackboards; others prefer large, single systems. Some embed theexpert system and others embed the external programs. As long asthe system gives the correct results, no one way is more correct thananother. More difficult problems sometimes require cleverapproaches. As you gain experience in converting human knowledgeto rule form, you will be able to better determine what approach isgoing to be best for you in developing a particular system.

Tree-Structured ApproachTo get started, choose a simple problem that has a well-defined set ofsolutions and few alternatives. Even then, the system can be writtenin a variety of ways. For example, suppose we want to write asystem to identify the items on a desk. The desk has a telephone, acomputer, a pencil, paper, and floppy disks. One way to write asystem is to first create a decision-tree diagram. If the decision tree iscomplete, the systems developed from it will be complete.

First we will make a simple decision tree for the problem ofidentifying the items on the desk:

Makesnoise?

YES

NO

Color?Black

White

Color?Black

White

ShapeFlat

Cylindrical

TELEPHONE

COMPUTER

FLOPPY DISK

PAPER

PENCIL

B - DEVELOPING EXPERT SYSTEMS 5

Page 39: Manual Exsys

This very shallow tree can be converted directly to rules by justtracing each branch of the tree. Tracing each branch always allows atree to be converted to rules, but if the tree has many branchingpoints, this approach may result in more rules than are needed. Forthis example, at the same time we identify the items, we can indicatethe level of confidence in the answer. We are using the 0-10Confidence Mode. Beginning with the top branch,

Makesnoise?

YES

NO

Color?Black

White

Color?Black

White

ShapeFlat

Cylindrical

TELEPHONE

COMPUTER

FLOPPY DISK

PAPER

PENCIL

the rule would be:

Rule 1IF

The item makes noiseand The color is blackTHEN

Telephone - Confidence=10/10

The rules for the other branches would be:

Rule 2IF

The item makes noiseand The color is whiteTHEN

Computer - Confidence=10/10

Rule 3IF

The item does not make noiseand The color is blackTHEN

Floppy Disk - Confidence=10/10

B - DEVELOPING EXPERT SYSTEMS 6

Page 40: Manual Exsys

Rule 4IF

The item does not make noiseand The color is whiteand The shape is flatTHEN

Paper - Confidence=10/10

Rule 5IF

The item does not make noiseand The color is whiteand The shape is cylindricalTHEN

Pencil - Confidence=10/10

Use of Sub-sets of Rules for Sub-goalsAny decision-tree diagram can be converted to rules, but if largedecision trees need to be translated, identifying sub-goals may makethe system easier to manage. Using sub-goals may increase the totalnumber of rules, but ease of use and maintenance are increased. If ablack pen is added to the desk, the form would be:

Makesnoise?

YES

NO

Color?Black

White

Color?

Black

White

ShapeFlat

Cylindrical

TELEPHONE

COMPUTER

PAPER

PENCIL

ShapeFlat

Cylindrical

FLOPPY DISK

PEN

B - DEVELOPING EXPERT SYSTEMS 7

Page 41: Manual Exsys

We could convert this option to rules as before, by adding a "shape"condition to Rule 3 and adding a new rule for "PEN." However,since the "Shape?" test is repeated, we can restructure the diagram.

Makesnoise?

YES

NO

Color?Black

White

Color?Black

White

Shape

Flat

Cylindrical

TELEPHONE

COMPUTER

PAPER

PENCIL

FLOPPY DISK

PEN

Color?Black

White

We can now create sub-goals. This example will require more rulesto specify the sub-goal, but the rules will be less complex. In a largesystem, sub-goals provide a very convenient way to specify a branchpoint in one condition rather than many. Sub-goals are simply a wayof specifying part of the decision process. In this example, if the itemdoes not make noise, we can divide the possible solutions into twocategories - writing tools and information storage media (quite aeuphemism for paper). Rules 1 and 2 would be the same as above,but now we will add new rules 3 and 4:

Rule 3IF

The item does not make noiseand The shape is cylindricalTHEN

The item is a writing tool

Rule 4IF

The item does not make noiseand The shape is flatTHEN

The item is information storage media

B - DEVELOPING EXPERT SYSTEMS 8

Page 42: Manual Exsys

The conditions in the THEN part of rules 3 and 4 are simply builtfrom qualifiers. They are not choices. These qualifiers will beautomatically invoked through backward chaining if the informationis needed.

We can now add two more rules to complete the sub-set:

Rule 5IF

The item is a writing tooland The color is blackTHEN

Pen - Confidence 10/10

Rule 6IF

The item is a writing tooland The color is whiteTHEN

Pencil - Confidence 10/10

Rule 7IF

The item is information storage media

and The color is blackTHEN

Floppy Disk - Confidence 10/10

Rule 8IF

The item is information storage media

and The color is whiteTHEN

Paper - Confidence 10/10

The system now has 8 rules to express what could have beenexpressed in 5, but the problem is broken into smaller parts. Thenew Rule 6 is easier to understand than the old Rule 5. The systemhas fewer but more explanatory conditions. If we ask the program*HOW it knows the item is a writing tool, Rule 3 is automaticallydisplayed since the information was obtained through backwardchaining.

B - DEVELOPING EXPERT SYSTEMS 9

Page 43: Manual Exsys

When we run the rules, however, if we input that the item does notmake noise, the program asks if:

The item is1 a writing tool2 information storage media

We have only told the program how to determine if the item is awriting tool or media only for cases that do not make noise. Oncewe say it makes noise, rules 3 and 4 are false and the program cannotgain any information from them. Consequently, the program will askus as end users the question about the "item." Suppose, though,that we do not wan the user asked this question. Severalmodifications to the system are available.

First, another value can be added to the sub-goal qualifier:

The item is1 a writing tool2 information storage media3 machine

Now we have three options:

1. Add a rule:

Rule 9IF

The item makes noiseTHEN

The item is a machine

This rule will provide the information, because now theprogram can determine data on the sub-goal even if the itemmakes noise.

or

2. Add the THEN condition of Rule 9 to rules 1 and 2.Again, the program is able to get information on the sub-goaleven if the item makes noise.

or

3. Make value 3, machine, the default value for thequalifier. In this alternative, if the program cannot derive avalue from the rules, the default value applies and the end useris not asked the question.

Any one of the above solutions complete the rule sub-set.

B - DEVELOPING EXPERT SYSTEMS 10

Page 44: Manual Exsys

Adding a sub-goal increased the number of rules from 6 to 9. In ourexample, the sub-goal was unnecessary, but if the sub-goal had 7decision levels below it, specifying the decision tree only from thatpoint would be useful. Sub-goals should always be used if thedecision tree is very deep.

Working back from ConclusionsMany problems can be diagrammed as decision trees, but not all.

Some systems that have confidence values associated with theirsolutions are difficult to diagram in a tree structure. In such asituation, an alternative is to work on only a small part of theproblem at a time. If the problem is small, all aspects are more easilyhandled. To use this approach, start with the goals of the wholesystem and express them in the most general terms when thatsolution is appropriate.

We will use the example of the items on the desk, but this time wewill approach the problem without a tree diagram and start with thegoals. First we will consider the PEN and PENCIL. We candistinguish them by color, so we will say:

Rule 1IF

The item is a writing tooland The color is blackTHEN

PEN - Confidence 10/10

Rule 2IF

The item is a writing tooland The color is whiteTHEN

PENCIL - Confidence 10/10

We will then make the same type of rules for the FLOPPY DISK andPAPER.

Rule 3IF

The item is information storage media

and The color is blackTHEN

FLOPPY DISK - Confidence 10/10

B - DEVELOPING EXPERT SYSTEMS 11

Page 45: Manual Exsys

Rule 4IF

The item is information storage media

and The color is whiteTHEN

PAPER - Confidence 10/10

These rules are valid, but when we now run the rules, the programasks

The item is1 a writing tool2 information storage media

For our intended end users, this question is inappropriate. We wantthe system to provide this information, not the user. When using thetechnique of starting with the choices, this is expected. The goal is towork out the logic at the highest levels. Creating complete andlogical descriptions of the decision is much more important than thequestions asked of the user. Sets of rules can be written to handlethe user interface after the logic is correct.

Once we have the logic correct at the highest level, we will startworking down to eliminate the inappropriate questions.

To eliminate the question on writing tool versus media, we add theserules:

Rule 5IF

The item does not make noiseand The shape is cylindricalTHEN

The item is a writing tool

Rule 6IF

The item does not make noiseand The shape is flatTHEN

The item is information storage media

B - DEVELOPING EXPERT SYSTEMS 12

Page 46: Manual Exsys

and another rule to allow the qualifier to get an answer even if theitem makes noise:

Rule 7IF

The item makes noiseTHEN

The item is a machine

Since we were this time only writing rules to derive a value for thespecific qualifier, it was easier to see that a third rule would beneeded, rather than in the tree approach above with sub-goals. Theadvantage of working back from the choices is that a small part ofthe problem can be in focus, while still maintaining a complete andlogical set of rules.

We now need to consider the rules for the TELPEHONE andCOMPUTER choices. These rules are simple:

Rule 8IF

The item makes noiseand The color is blackTHEN

TELEPHONE - Confidence=10/10

Rule 9IF

The item makes noiseand The color is whiteTHEN

COMPUTER - Confidence=10/10

We end up with the same set of rules as above but in a differentorder. Since this system is backward chaining, the order of the rulesdoes not matter. We produced the same results by very differentlogical approaches.

For many problems, the approach used is purely a matter of personaltaste. Both methods can produce equally good systems. However, ifconfidence factors are used extensively, the method of workingbackward from the choices seems easier to use. Professional displaysthe tree diagram of the rules we have input, allowing us to check forincomplete branches or other errors.

B - DEVELOPING EXPERT SYSTEMS 13

Page 47: Manual Exsys

B4: Backward ChainingMost expert-system problems should be divided into several sub-problems which can often be divided yet again. Writing these smallsets of rules to solve the smaller problems or define sub-goals is mucheasier. Then writing more general rules using the solutions to thesmaller problems to solve the large problem can be written. EXSYSProfessional tries to solve the larger problems by using the solutionsto the smaller problems to derive the information it needs.Professional's ability to automatically invoke the rules needed toderive information is called "backward chaining."

Backward chaining is one of the most powerful aspects of an expertsystem. Regardless of how the problem is approached, backwardchaining will likely be used to obtain information from other rules. Ifprogramming languages are familiar, the implementation of backwardchaining may seem strange because the program does so much of thework. The expert system does not have to be instructed that rulesare available that allow the information to be derived or to tell theprogram which rules to use. If such rules exist, the program will findthem and use them. Their order does not matter. If a new rulerelevant to part of the decision process is needed, it can be addedanywhere in the rule set.

As described above, one approach to finding smaller problems is toask how, in the broadest terms, does one solve the problem. Theanswer will probably be "If --- and --- then ----." Consider if the IFconditions could be made into questions to ask a user and reliably geta meaningful answer. If the IF condition is too complex to ask simply,consider how it could be broken down into questions that theintended user would understand and which could be used to derivethe IF condition. The process may have to be repeated if thesequestions are still impractical to ask a user. Continue this process untilthe questions are ones the intended user can answer. The rules aresimply the statements that express how the information is derived.

The following example shows how a problem can be broken downinto smaller parts.

B - DEVELOPING EXPERT SYSTEMS 14

Page 48: Manual Exsys

Suppose we are developing an expert system to supply medicaladvice over the telephone when the doctor is out. Assume calls areanswered by non-medical personnel who run the expert system andtalk with the caller. Naturally, such an expert system would need toknow that if someone is sick and calls after hours, he should take anaspirin and call back in the morning. This can be expressed in ruleform as:

Rule 1:IF The caller is sick

and The hour is late

THEN Aspirin - Probability= 10/10

and Call again in morningConfidence= 10/10

This rule will select the aspirin and call again choices. Theproblem has now been reduced to two smaller problems: determiningif the caller is sick and determining if the hour is late. The programcould ask the user for this information but the answers on "sick" or"late" would be subjective. If the program derives the informationfrom other rules and asks the user precise questions, the results willbe objective.

When the program tests Rule 1, it checks the first condition, Thecaller is sick. The qualifier for this condition is Thecaller is. Before it asks the user, the program searches all itsother rules to see if any can derive the value for the same qualifier intheir THEN or ELSE parts. In this case, assume we have put in threerules to help the program determine if the caller is sick. All threerules have the qualifier The caller is in their THEN part.

Rule 2:IF

The voice sounds hoarse

THEN The caller is sick

Rule 3:IF

The temperature is over 100 degrees

THENThe caller is sick

B - DEVELOPING EXPERT SYSTEMS 15

Page 49: Manual Exsys

Rule 4:IF

The voice is not hoarseand The temperature is less than 100

degrees

THENThe caller is well

In this example, the program first tries to derive information aboutThe caller is from Rule 2. Since no rules have The voiceis in their THEN parts, the program asks the user about the voice. Ifthe user selects "hoarse," then the IF condition in Rule 2 is trueand the program knows The caller is sick.

The developer has the option of directing the program to stopderivations after the first successful rule fires or to apply allappropriate rules (see Section C3.6 for more information.) If only thefirst successful rule in derivations was selected, the program wouldreturn to work on Rule 1 with the new piece of information that Thecaller is sick. If all applicable rules in derivations was selected,the program also tries to apply Rule 3. (In this example, the additionalquestion would be unnecessary and using the first successful rule forderivations would be adequate.)

If the caller answered that the voice was not hoarse, the programwould reject Rule 2 as invalid and try Rule 3, since it is the next rulewith the same qualifier, The caller is, in its THEN part. Theprogram next asks about the caller's temperature. If the callerresponded that the temperature was over 100 degrees, Rule 3 woulddetermine the caller was sick; if the caller said the temperature wasless than 100 degrees, Rule 4 would determine the caller was not sick.

By using rules 2, 3, and 4, the program can derive whether the calleris sick or well, without directly asking about "sick" or "well."

Had we not included Rule 4 and had the caller answered that thevoice was not hoarse and the temperature was less than 100 degrees,the program would not have had any valid rules with The calleris in their THEN part. The program could not derive anyinformation on The caller is and would have asked directly ifthe caller was sick or well. This is what we were trying to avoid, soRule 4 was added. (Other ways to do this with default values aredescribed in Section C3.6.) Any combination of answers to thequestions about voice and temperature will result in at least one ofthe rules being found true.

The program now knows the state of the caller's health. If the calleris well, Rule 1 is rejected. If the caller is sick, the first condition ofRule 1 is true and the program tests the second condition, Thehour is late. Since "late" is subjective, we want rules toderive the information.

B - DEVELOPING EXPERT SYSTEMS 16

Page 50: Manual Exsys

Rule 5:IF

The day is Mon or Tues or Wed or Thursand The time is between 4:00PM and 9:00AM

THENThe hour is late

Rule 6:IF

The day is Friand The time is between 2:00PM and 4:00PM

or between 4:00PM and 9:00AM

THENThe hour is late

NOTE: The Doctor plays golf on Friday

Rule 7:IF

The day is Sat or Sun

THENThe hour is late

Rule 8:IF

The day is not Sat or Sunand The time is between 9:00AM and 2:00PM

THENThe hour is early

Rule 9:IF

The day is Mon or Tues or Wed or Thursand The time is between 2:00PM and 4:00PM

THENThe hour is early

The program now only needs to ask easily answered questions aboutthe day of the week and the time segment (9:00AM-2:00PM,2:00PM-4:00PM, 4:00PM-9:00AM) to know if the hour is late.(The first condition in Rule 8 could have been written THE DAY ISMON or TUES or WED or THURS or FRI and producedexactly the same results. The form used is shorter and simpler.)

B - DEVELOPING EXPERT SYSTEMS 17

Page 51: Manual Exsys

To summarize, we broke the problem into three parts: a general rule(Rule 1) based on two smaller problems (sickness and lateness) andtwo sets of rules to solve the smaller problems.

Since in normal backward chaining, Professional will not fire rulesunless it needs some piece of information in the THEN or ELSEpart, the only time it should have rules do not that contain choices intheir THEN/ELSE parts is if they are being used to deriveinformation for other rules.

Derivations can continue down many layers in complex expertsystems; EXSYS can backward chain well over 100 layers ofqualifiers.

Other rules can be written using the qualifiers The caller is orThe hour is and rules 2-9 are invoked to derive the neededinformation. Should we later decide that another way to determine ifthe caller is sick is required, we can simply add a single rule such as:

Rule 10:IF

The patient is sneezing

THENThe caller is sick

The new Rule 10 is automatically invoked by any rule that uses Thecaller is in its IF part. (In practice, we would need to modifyRule 4 so we do not have a patient that is both well and sick).

Note: Once rules to solve the small parts of a problemare written, the more general rules are often easier towrite.

Remember that if the rules are created to derive information, theymust be a complete set that accounts for all possible combination ofinput. If not, the program may ask the complex or ambiguousquestion that was being avoided. This is where ELSE conditions canbe very useful.

Rules can call each other to derive information recursively. Forexample, Rule 1 could use Rule 2 to derive information and Rule 2could use Rule 1 to derive information causing Rule 1 to again callRule 2, etc. The program recognizes the loop and breaks out tocontinue the problem. This type of error in logic will produce anerror message. A rule can also have the same qualifier in both its IFand THEN parts. This is useful if, based on other input, a suspicionexists that the user may not have fully considered all of the values forthe qualifier or if a value for the qualifier is forced regardless of theuser input.

B - DEVELOPING EXPERT SYSTEMS 18

Page 52: Manual Exsys

B5: Using Confidence Modes

One of the most powerful parts of an expert system is being able tocreate rules which state that an answer is probably, but not definitely,true. Definite yes/no answers are nice, but in practice the real worldis rarely so cooperative. In most cases certain facts may imply oneanswer but are not definitive. Because of this EXSYS Professionalhas five confidence systems.

Selecting the appropriate confidence mode for an expert system isvery important. Changing to a different system later is difficult.(Changing can be done only through the Rule Compiler. The rulesare printed, confidence values are changed to a new system with atext editor, and then they are recompiled.) The main rule of thumbto use when selecting a confidence mode for a system is - Use thesimplest one that will do the job.

If all data in a system is definite, use the "0 or 1" system. This isequivalent to YES/NO. This is good for selecting among groups ofitems that can be definitely identified. It is also appropriate forconverting decision trees that do not involve probability.

The 0-10 system is one of the best for most problems. It isrecommended for all beginning systems. It allows values to belocked at YES or NO with a 0 or 10, but still provides a way ofhandling the confidence of intermediate answers. Many rule-basedproblems can be handled with this system and it should be used,unless some aspect of the problem requires the special capabilities ofone of the other systems.

The -100 to 100 system is similar to the 0-10 but offers moreprecision in the confidence values. In practice this precision may notbe valid unless there is statistical data available. Few human expertscan put a value to their intuitive knowledge that is precise to 2 digits.

The increment/decrement system is another easy-to-use system. Itallows intuitive knowledge about the chance of a solution beingappropriate to be easily expressed in rules. This system has themajor benefit that the answers are not bounded to a small range. Thefinal confidence can be 10,000. This allows differentiating betweensolutions that might have the same value in other systems.

The custom formula system is by far the most complicated and themost powerful. We do not recommend it for new developers or ifone of the other techniques is adequate. This system allows assigningconfidence values for qualifiers and variables in addition to choices.Usually this is not necessary, but in some cases it can be desirable.(See Section C3.3 for more detail on confidence modes and SectionC40 for more information specifically on custom formula systems.)

B - DEVELOPING EXPERT SYSTEMS 19

Page 53: Manual Exsys

Giving specific directions for which confidence system to use isdifficult because the selection depends on the purpose of the expertsystem. Consider what the system will do and how confidence willbe used in the rules. The following questions may help with makinga selection.

How precise is the data?If the data is from a human expert, accuracy is usually expressed withone digit. If the confidence data is statistical, two or more digits ofaccuracy may be possible.

Do solutions with a few rules assigning different valuesneed to be differentiated from solutions with many rulesassigning the same value?If differentiation is needed, none of the systems which use averagingare appropriate. Instead "increment/decrement" or "-100 to 100" inthe dependent or independent mode is good.

Do the users need to provide confidence values for their data?Most systems do not need the user to input confidence values withhis response. But if user confidence is necessary, the custom formulasystem is the best choice.

For example, the program might ask the user

The age of the antique chair is1 less than 50 years2 50 years or more

In the custom formula mode, the program could then ask how definiteis the answer. The user-supplied confidence for the qualifier wouldhave to be in the range specified by the developer. The usual ones are0-10, 0-100 or -1 to 1. This user-supplied confidence value for thequalifier could then be combined with the qualifier's value to determinethe confidence for the choices. For example, the developer mightdecide to ignore the users' opinion of the age if their confidence is lessthan 5/10. Also, the user-supplied confidence values could helpdetermine a final confidence value for a choice - lower user confidencein answers would lead to lower overall confidence in the choices.

Clearly, asking the users to supply confidence values for theirinformation assumes a higher level of end-user expertise than simplyasking unambiguous multiple choice questions. Asking users tosupply confidence values may be counterproductive to the expert-system goal that provides problem-solving techniques to non-expertswho may be unsure of their answers. Users' confidence in theiranswers may vary greatly between different users and even varysignificantly with the same user answering at different times. Becauseof these variations, heavy reliance on the user-supplied confidencevalues is discouraged. Users' values can best be used to determine ifdata should be disregarded or to determine the level of the end-users'knowledge.

B - DEVELOPING EXPERT SYSTEMS 20

Page 54: Manual Exsys

The confidence values for a qualifier or variable can also be derivedfrom other rules. This approach is often better than asking the userfor a numeric value. For example, the program could ask thequestion about the antique chair, and then ask

Your opinion of the age of the chair is1 definite2 very probably correct3 probably correct4 somewhat uncertain

Although the number of options for the user has been reduced, theanswers still provide the data needed by the program. This methodof questioning can be employed with all of the five confidence modes.The qualifier values about the degree of certainty can be used as theystand or can be converted to numeric values. This method produceshighly consistent answers among a group of users.

Does the problem require a complex system for combiningconfidence factors?The initial four systems in Professional have intentionally been kepteasy to use. They are designed for the rapid construction of expertsystems by people with domain expertise but not necessarily ArtificialIntelligence training. Many very complex systems can be developedfor combining confidence factors. These can be implemented byapplying the custom formula system when required.

B - DEVELOPING EXPERT SYSTEMS 21

Page 55: Manual Exsys

B6: Using the Command Language

The Command Language is the most complex part of building anexpert system. EXSYS Professional defaults to a backward-chainingsystem. This is very easy to use and is adequate for most problems.Rule order or placement is not important; rules will be found andused if needed. However, if the developer wants the program to dosomething other than backward chaining, he can use the CommandLanguage.

The Command Language provides complete control, not only overthe order of rule execution, but also chaining, setting of data, andlooping. It is very powerful, but it requires more work by thedeveloper. The Command Language is a programming language forprocedural operations which, combined with the rules for logiccontrol, allows more complex problems to be handled than withsimple backward chaining.

To experiment with the Command Language, first create a simplebackward-chaining system. (Using one you create is better than usingone of the demo systems because you will understand the systemmuch better.) Add a .CMD file. Start with the following commands:

:LOOPRULES ALLRESULTS /C:LOOP

These directions are the same as backward chaining. Try changingthe RULES command or adding some SET commands. Experimentand see how the commands effect the run of the rules. (See ChapterJ for more information.)

B - DEVELOPING EXPERT SYSTEMS 22

Page 56: Manual Exsys

B7: Using the Report Generator

The EXSYS Professional Report Generator can print reports, passdata to other programs, and format the conclusions of the run. Thecommands used in the Report Generator have default options of onlyone character, but these can have added options to produce morespecific results. For example, the command C prints all choices, butthe command C>6 prints only those choices which received a finalscore greater than 6, and the command C>6 /T prints only the text(no value) of those with a score greater than 6, and so forth.

The report generator command language is easy to use, but it canproduce very complex reports. Once a system is developed, one canexperiment with the commands.

A particularly easy form for testing the Command Language is to

FILE XXX.commands.

CLOSEDISPLAY XXX

These commands create a report and then display it on the screen.Change the commands to see the effect on the report.

The Report Generator is not needed in every expert system, but forsystems that must format data for the user or communicate withother systems, it is very useful. (See Chapter F for more informationon the Report Generator.)

B - DEVELOPING EXPERT SYSTEMS 23

Page 57: Manual Exsys

B8: Creating Your First Expert System

Select a fairly small, well-defined problem on which you personallyhave expertise. (Attempting to extract rules from someone else whilelearning about EXSYS Professional makes the job much moredifficult.) Select a problem appropriate to either the "0 or 1" or the"0-10" confidence systems. Avoid the more complicated confidencemode in your first system.

If the problem can be diagrammed as a tree, diagram it as a guide forthe rules. If it cannot be easily diagrammed, start with identifying thechoices.

Next, create rules. Enter some rules to solve the problem and thentry to solve specific examples. If the system does not get the correctanswer, check the rationale with the commands of WHY, HOW, andTRACE to find the error in logic. Often the error is due to unrealisticsimplifications of the main problem. Once the specific error isidentified, the appropriate rules can be added to more realisticallyaddress that area. Professional works these rules into the overallsolution. This interactive testing and modification helps to convertintuitive knowledge and experience into rule form. Continue testingthe knowledge base until you are confident it is working properly. Itmay take a while to perfect the rules. You can use the validation andthe ability of EXSYS to diagram the logic of the rules to help you.

Study the simple knowledge bases provided and develop severalsmall ones before attempting a major problem. You may besurprised at how little practice is needed to separate seeminglycomplex problems into simpler parts, each requiring relatively fewrules for solution.

Building expert systems is like programming in a language that doesmuch of the work for you. Professional finds the correct rules andanswers questions. But, the developer must create the rules. As withprogramming, experience is the best teacher. Making mistakes andtrying new approaches is the best way to learn EXSYS Professional.As more systems are built using more of Professional's features, theuse of the features to enhance the power of each other becomeevident, i.e., use a report specification in the Command Language oruse a Report to pass data to an external program.

If you have problems getting a system to run, try running the HELPknowledge base that came with Professional. IF that does not solvethe problem, call EXSYS Technical Support. They have heardalmost every mistake that can be made many times. They willprobably be able to help you past the problem to get a systemrunning.

B - DEVELOPING EXPERT SYSTEMS 24

Page 58: Manual Exsys

TrainingTo really get started fast, you may also want to consider classes usingEXSYS Professional. Classes are available from many sourcesincluding college, universities, third party training and EXSYS Inc.Call EXSYS Inc. (505) 256-8356 for information on classes that areavailable.

B - DEVELOPING EXPERT SYSTEMS 25

Page 59: Manual Exsys

Chapter C

EXSYS Rule Editor

EXSYS expert systems are created and edited using the Rule Editorprogram, EDITXSP, which allows easy inputting, editing and testingof rules. This chapter includes directions for creating new rules as wellas editing existing ones. Chapter D covers the commands to run therules from either the Editor or Runtime program.

Rules can also be developed using a text editor and EXSYSProfessional's Rules Compiler, but it is better to learn the Rule Editorfirst. The Rule Editor can perform most operations faster and easierand, due to the menu driven structure, is easier to learn.

There are certain types of editing operations which are easier to dowith the Rule Compiler. These are discussed in Chapter K on theRule Compiler.

C - RULE EDITOR 1

Page 60: Manual Exsys

C1: Starting the Rule Editor

Click on the EDITXSP icon to start the program.

In some GUI operating systems, you may also run the program withoptional associated filename of the knowledge base file to run, andone or more configure commands:

EDITXSP <filename> <configure_commands>

The configure_commands are described in Chapter E.

EXSYS works with two main files for each knowledge base,filename.RUL and filename.TXT.

Note: Both the .RUL and.TXT Files must be kept in thesame Path/Directory (orMacintosh Folder) or theprogram will not work.

EDITXSP does not load the .TXT file into memory. The .TXT file isaccessed as needed from the disk, and if the file is on a floppy disk, itmust remain in the disk drive while the program is running.

C - RULE EDITOR 2

Page 61: Manual Exsys

C2: Opening an Existing Knowledge Base

Edit Rule Options KBfiles Questions

New

SaveSave AsRevert to Saved

Print

ExitAbout

File

Open

If you select Open, a list of all of the files with a .rul extension will bedisplayed. Double click on the file you want to use, or select a fileand click the Open button.

On some operating systems, all files will be displayed, not only thosewith .RUL extensions. To open a knowledge base, select any of thefiles in the knowledge base that start with the same filename as the.RUL file.

Once the knowledge base file is selected, the files will be read and thesystem title screen will be displayed. At that time, you can performoperations on the rules, run the rules, and perform a number of otheroptions.

C - RULE EDITOR 3

Page 62: Manual Exsys

C3: Starting a New Knowledge Base

Edit Rule Options KBfiles Questions

OpenSaveSave AsRevert to Saved

Print

ExitAbout

File

New

Pull down the main menu bar item File and select New.

If you select New, EXSYS will ask you for the name of theknowledge base you wish to create. Enter a file name, and ifappropriate for your operating system, enter the optional drive orpath. Whenever a new knowledge base is created, EXSYS asks youto define certain parameters for the new system. These steps arenecessary only when a new expert system is created. All parameters,except for the confidence mode, can be edited later.

C3.1: Subject

Enter a short subject name for the system you are developing.EXSYS requires you to use a subject name which it will display onthe system title screen. The text should be less than 200 characters.EXSYS will not continue past this screen unless you enter a subjectname.

C3.2: Author

The program asks for the author's name. Like the subject name,EXSYS requires you to enter the author's name which must be lessthan 200 characters in length. The author’s name is also used for thetitle screen. Like the subject, EXSYS will not continue past thisscreen unless an author is entered.

C - RULE EDITOR 4

Page 63: Manual Exsys

Knowledge Base Parameters

O K

Starting Text

Ending Text

Ext. Prog.

Subject:

Author:

Confidence Mode: Yes/No 0 -10 -100 to 100 Increment/Decrement Custom Formulas

Derivation Mode: All Possible Rules First Successful Rule All Non-redundant

Calculation Mode Average Dependent Prob. Independent Prob.

Rule Display Mode: Display Rules Do NOT Display Lock DIsplay OFF

Display Threshold:

Check New Rulesfor Consistency Yes No

1 Init Choice Value

C3.3: Confidence Mode

Select which of the five Confidence Modes to use in your new expertsystem. Click on the radio button next to the mode you wish to use.

Because this parameter directly affects the structure of the rules, itcan not be edited or changed later using the Rule Editor. (There is away to change the Confidence Mode using the Rule Compiler.)

When selecting a Confidence Mode, the most important rule toremember is:

Use the simplest system that will do the job.

YES / NO SystemIf the system does not require any estimate of probability, theYES/NO (0-or-1) System is best. This confidence system is very easyto use since the first rule that fires for a choice sets the value to 1 forYes or 0 for No. No intermediate values are assigned. Thisconfidence system is good for selecting choices from a list, anautomated questionnaire, or other systems which contain choices thatcan definitely be answered with a "yes" or "no".

C - RULE EDITOR 5

Page 64: Manual Exsys

0-10 SystemThe 0-10 System provides confidence values on a scale of 0-10. Thisis often quite compatible with the intuitive knowledge used in thedevelopment of an expert system. An assignment of 0 locks thevalue for the choice at 0 (No), and an assignment of 10 locks thevalue at 10 (Yes). Confidence values between 0 and 10 are averagedto provide a relative likelihood. This system can positively select orreject a choice (with a value of 10 or 0) but can also allowintermediate values to indicate choices that may be appropriate.

For example, suppose Choice 1 was in three rules which fired withassigned confidence values of 3, 7, 8; Choice 2 was in two rules withvalues of 7 and 10; and Choice 3 was in one rule with a value of 5.The final confidence values would be

Choice 2: 10 (the selection of one 10 locks the value at ten)

Choice 1: 6 (the average of 3, 7 and 8)

Choice 3: 5

This allows the end user to see not only which choices were selectedbut also provides a means of relative ranking.

When obtaining a human expert's intuitive confidence for confidencein an event, a 0-10 scale is often comfortable and easy to use. Unlessvalid statistical data is available, precision higher than 0-10 is difficultto obtain from intuitive knowledge.

Despite its simplistic calculations, the 0-10 System is very useful formany expert systems, and it is easy to use. We recommended thismode for beginning systems.

-100 to 100 SystemThe -100 to 100 System is effective if statistical data accurate to twosignificant figures is available or if the nature of the problem requiresthat confidence factors be combined as dependent or independentprobabilities.

Values can be assigned to choices in the range of -100 to 100. Thisprovides greater resolution than the 0-10 system. However, there isno value that locks the value at "yes" or "no.” Values of 0, 100 and-100 are treated like any other value. Also, there are three methodsof combining the confidence values—average, dependentprobabilities, or independent probabilities. These methods aredescribed in section C3.4 on Calculation Mode.

If the confidence factors are to be combined as dependent orindependent probabilities, only the range 0-100 can be used because

C - RULE EDITOR 6

Page 65: Manual Exsys

negative values have no meaning. If confidence factors are combinedby averaging, the full -100 to 100 range can be used.

This system is useful if you wish to use averages without lockingvalues, if you have statistical data, or if you require independentprobability.

Increment/Decrement SystemThis system is intuitive and easy to use. Values are added to orsubtracted from the total points for a choice. A rule can add orsubtract as much as 100 points from the total for a choice. At theend, the total value for a choice is displayed. This systemdifferentiates among possible solutions that would provide similar oridentical scores using other systems.

For example, suppose Choice 1 received three values of 9 and Choice2 received only one value of 9. In the 0-10 System, both Choices 1and 2 would have the same final score of 9. But in theIncrement/Decrement System, Choice 1 would have 27 and Choice 2would have 9. Clearly, Choice 1 had been selected in more rules.

Use this system if having multiple rules fire indicates a higherlikelihood for a choice. If multiple rules do not indicate a higherconfidence, the 0-10 system may be a better choice While locking ascore is not possible using this system, a large number of points canbe added or subtracted, thereby clearly pushing the value over orunder the display threshold value. This system allows the end user tosee a much wider point spread among selected solutions.

Custom Formula SystemThis is by far the most difficult of the systems to use and is notrecommended for beginners. It should be used only when a problemcannot be solved using one of the other systems. In this system, thedeveloper can write his own formulas for the combination ofconfidence values. This provides enormous flexibility. One methodof combining confidence values can be used in one part of an expertsystem and another method in the rest of the system.

Also, in addition to the confidence associated with a choice, thissystem allows both qualifiers and variables to have associatedconfidence values. The confidence values associated with qualifiers orvariables can be asked of the user, set to default values, or derivedfrom rules. The confidence of a choice can take into account theconfidence of the qualifier or variables that indicated the choice. Thisflexibility allows very complex systems of confidence factors to beimplemented.

However, this system requires much more work by the developer ofthe expert system. Since the program does not have a default

C - RULE EDITOR 7

Page 66: Manual Exsys

method of combining points assigned to choices, the formulas forhandling the confidence scores must be part of the rules. This addscomplexity and takes much more time than other systems. Thissystem should be used only if you need to have the followingelements in your system.

1. You require numeric confidence scores associated withqualifiers or variables.

2. You need to have user supplied confidence values for theiranswers that effect the final confidence values of choices.

3. Your require specialized formulas for combination ofconfidence values.

In most cases, developing an expert system using one of the otherConfidence Systems is faster and easier. However, the flexibility andpower of the custom formula system can lead to solutions not foundby the other systems. (See Section C40 for additional information.)

Confidence When to UseSystem

0 or 1 System does not require confidence factors.

Choices can be positively selected or rejected in individual rules.

Ranking of selected choices is not required.

0-10 Easy to use—very good for beginners.

Allows confidence factors to be combined, without requiring complex formulas.

Intuitive for most users to assign confidence factors.

Most effective general purpose system.

-100 to 100 Provides finer resolution of confidence factors.

Should be used only if statistical data isavailable with appropriate precision.

C - RULE EDITOR 8

Page 67: Manual Exsys

Allows factors to be combined as dependent or independent probabilities.

Increment/ Intuitive—easy to use.Decrement Good for distinguishing between choices

that would receive similar scores in other systems.

Allows wide point spread in selected items.

Custom Most flexible and powerful.Formulas

Most complex and most difficult.

Allows user supplied or derived confidence for qualifiers and variables.

Allows any formula to be used to assign confidence values to a choice.

Should only be used if none of the other systems can handle the problem.

C3.4: Calculation Mode

If the -100 to 100 Confidence Mode is select, the radio buttons forthe Calculation Mode will be activated. (If any other ConfidenceMode is selected, the Calculation Mode has no meaning and the radiobuttons will be inactive.)

The Calculation Mode selects how the values assigned to choices inthe -100 to 100 mode will be combined. There are three options:Average, Dependent Probability and Independent Probability.

AverageThe first is a simple average of all the individual values the choicereceived in the rules found to be true. This is the same as the 0-10system, but no assigned values lock the final value. If this mode isselected, the full range of -100 to 100 can be used.

C - RULE EDITOR 9

Page 68: Manual Exsys

Dependent ProbabilitiesThe second combines the probabilities as if they were dependentprobabilities—the probabilities are multiplied as percents. Forexample: if a choice appeared in two rules that were used, with valuesof 60/100 and 90/100, its final value would be (60% times 90%=54%) for a final value of 54/100. If this mode is selected, only therange of 0 to 100 can be used, since negative values have nomeaning.

Independent ProbabilitiesThe third way to combine the values is as if they were independentprobabilities. In this system, the combination of the two probabilitiesis 1 minus the product of 1 minus the individual probabilities.

1-((1-Prob1) * (1-Prob2))

In the example above this would be

1-((1-60%) * (1-90%))=96%

for a final value of 96.

If this mode is selected, only the range of 0 to 100 can be used, sincenegative values have no meaning.

C3.5: Threshold Level For Display of Results

The threshold level determines which choices, based on their finalvalues, are displayed in the final results screen. Only those choiceswith values greater than or equal to the threshold level are displayedas results. The default threshold is 1, which means all choices whichreceive a final value of 1 or greater are displayed in the program'sresults screen. In some cases, you may wish to show choices whichreceive a higher value. For example, if any choice which received afinal value of less than 5 is too unlikely to be considered, setting thethreshold to 5 would limit the display to only those choices whichhave a final value of 5 or more. This is especially useful in the -100 to100 System in which choices with low values can be so unlikely thattheir display is not useful.

The default value of 1 is a safe threshold to use while developing thesystem. This value can be easily changed later if you need to.

C - RULE EDITOR 10

Page 69: Manual Exsys

C3.6: Derivation Mode

Next it is necessary to select which of the three options for derivinginformation from other rules should be used.

EXSYS invokes appropriate rules in the expert system to derive theinformation as it is needed. The default option is to apply all possiblerelevant rules. This is a safe selection, but in some cases it can lead tounnecessary questioning of the end user. Therefore, EXSYS allowsthe developer to control the depth of search that will be made.

All Possible RulesThe "attempt to apply all possible rules" mode invokes all possiblerelevant rules that can derive needed information. Even if one rule isfound to be true, the remaining rules are still tested. If, due to thelogic of the rules, the additional rules do not provide moreinformation, this may lead to unnecessary questions being asked ofthe end user. However, this is always a safe mode to use whiledeveloping the expert system. The mode can be easily changed laterif you need to.

First Successful RuleThe "stop after first successful rule" mode does not invoke additionalrules after the first relevant rule is found to be true. If all of theneeded information about a qualifier can be provided by a single rule,this is the appropriate system. This also allows the program to run alittle faster. This system is not appropriate if deriving informationrequires several rules to provide parts of the total information.

Non-redundant RulesThe "apply all non-redundant rules" mode is appropriate for mostcases. A rule is redundant if it supplies no additional information,regardless of whether it is true or false. In this system, after one rulehas been determined to be true and provided information, additionalrules are invoked only if they add more information. Rules thatwould not add information, even if they were true, are not invoked.This system is appropriate unless

l. Backward chaining is being used as a control mechanism toforce rules to fire for procedural reasons. In this case, use"attempt to apply all possible rules." (It is better to use thecommand language for such procedural control. See Chapter Jfor more information.)

2 Information on the qualifier or variable is provided by asingle rule firing. In this case, "stop after the first successfulrule" may produce slightly better speed.

C - RULE EDITOR 11

Page 70: Manual Exsys

The difference between the modes is easier to understand if you lookat an example of how they work on different problems.

For example:

Rule 1:IF

Wood is neededTHEN

The shipment includes wood

Rule 2:IF

Construction materials are neededTHEN

The shipment includes wood

Rule 3:IF

Plastic is neededTHEN

The shipment includes plastic

If the program is attempting to derive information on "TheShipment" with the "attempt to apply all rules" option, it will test allrules that have some information on "The Shipment" in their THENpart.

1. The program will test Rule 1.

2. Even if Rule 1 is true, Rule 2 will be tested.

3. Even if Rule 2 is true, Rule 3 will be tested.

Since each rule could provide information on "Shipment", each istested.

With the "stop after first successful rule" option:

1. The program will test Rule 1.

2. If Rule 1 is true, the program will successfully derive someinformation on the contents of "The Shipment" and rules 2 and3 will not be tested.

C - RULE EDITOR 12

Page 71: Manual Exsys

3. If Rule 1 is false, Rule 2 will be tested. If Rule 2 is true, theprogram will successfully derive some information on thecontents of "The Shipment" and Rule 3 will not be tested.

4. If Rules 1 and 2 are false, the program will still not knowanything about "The Shipment" and Rule 3 will be tested.

If the shipment only includes one material, this might be a good modeto use since it minimizes the number of rules tested.

With the "apply non-redundant rules" option:

1. The program will test Rule 1.

2. If Rule 1 is true, Rule 2 will be ignored because theprogram will already know "The Shipment" includes wood.Rule 2 can add no additional information and is thereforeredundant.

3. The program will then test Rule 3 since it adds information(plastic) which is not redundant with existing information, evenif rules 1 or 2 are already known to be true.

Using the non-redundant option usually avoids unnecessary questions,while still allowing all information to be derived about a specificqualifier.

C3.7: Rule Display Mode

Select the mode to use for Rule Display while the system is running.Click on the appropriate radio button.

Display RulesThe Display rules as they are used means all rules are displayedimmediately after they fire. This can be useful for many things,including development or providing information to the end user inrule notes. However, usually end users find this mode annoying andthere are alternative ways to present the required data to the end userin a more convenient form (e.g. DISPLAY commands, reportgenerator, custom screens)

Not Display RulesThis mode will not display rules when they fire, but will allow the enduser to have rules displayed and to ask about rules with the HOWand WHY commands. This is the most commonly used system sinceit allows the end user to fully interrogate the expert system on thebasis for the recommendations.

C - RULE EDITOR 13

Page 72: Manual Exsys

Lock Display OffThe Lock Display Off mode prevents the end user from examiningthe rules at all—they are "locked out." The information in an expertsystem can represent very valuable knowledge. In some cases, theknowledge in the system should be protected, even though theproblem-solving capability of the system must be disseminated. TheDisplays Off mode locks the rule display, so the end user cannot seethe rules at all, even with the WHY or HOW commands. The enduser cannot override the option. If the developer selects this option,he must also select the password option when storing the system.Locking the rules applies ONLY to the Runtime and has no effect onrunning the rules within the Rule Editor during development.

C3.8: Starting TextEXSYS provides the option for the developer to write explanatorytext which is displayed at the beginning when the knowledge base isrun.

This explanatory text is primarily for the end user. Using starting text,the developer can explain what the knowledge base does and whatthe end user might expect from the program. The text is optional,but its presence can make the system easier for the end user. This isa good place to provide comments to the user about what input isexpected, what measurement units to use, who to contact withquestions, or provide any other information the end user may need.

To enter starting text, click the Starting Text button, and a windowwill appear. Enter the text you wish to appear on the screen, thenclick on the OK button. This text can be edited later if you need to.

C3.9: Ending Text

EXSYS also provides the option for the developer to writeexplanatory text which is displayed at the end of a run, just before theconclusions are displayed.

This explanatory text is primarily for the end user. The developer canexplain what the results mean, what thresholds are set or what actionsshould be taken next. The text is optional, but its presence can makethe system easier for the end user.

To enter ending text, click the Ending Text button, and a windowwill appear. Enter the text you want to appear on the screen, thenclick the OK button. This text can be edited later if you need to.

C - RULE EDITOR 14

Page 73: Manual Exsys

C3.10: Starting External Program

The developer can require the call of an external program at the startof a run. An external program is any program that can be run fromthe operating system. It can be a database, spread sheet, graphicsprogram, video disk driver, or custom user program written in anylanguage including interpreted languages such as BASIC. In the MS-Windows version, the program can be either a Windows based ornon-Windows (DOS) program.

To enter the name of the external program, click on the Ext. Prog.button and a window will appear. Enter the name of the program asit would be entered at an operating system prompt. Data can be, andusually is, passed back to EXSYS from the external program. Thisdata would be used during the running of the expert system. (SeeChapter H for more information on calls to external programs.)

The external program specified at this point is always called at thestart of a run and is not associated with any particular data elementsin the expert system. The external program can provide all or part ofthe information needed by EXSYS to reach its conclusions.

Embedded systems can easily be created using this technique. Insuch systems, all the information needed by the expert system isprovided by the called program. The end user has little or no directinterface with the expert system. Embedding is a very powerful wayto add expert system analysis capability to other programs. It worksespecially well with programs which contain a large amount of databut lack sophisticated ways to analyze that data.

EXSYS has many other ways to call external programs which arediscussed later in Chapter H.

C3.11: Initial Choice Value

If the Custom Formula Confidence Mode is selected, the buttons forthe Initial Choice Value will be enabled. In this mode, all choicesmust be given an initial value. This value is then used in confidenceformulas to arrive at the final value for the choice. For more detailon using custom formulas for confidence calculations, see section C40on Confidence Formulas.

To set the initial choice value, click the Init Choice Value button.Enter the value desired in the window that will be displayed, and clickOK.

C - RULE EDITOR 15

Page 74: Manual Exsys

C3.12: Finished Setting Parameters

This completes the description of parameters set at the start of a newexpert system. These parameters need be set only when creating anew expert system. When the parameters are set, click the OKbutton. The Subject and Author fields must be completed before youcan proceed. The other parameters are set to their normal defaultvalues. You will be able to change most of these parameters later byselecting the Parameters menu item from the Options menu. Theconfidence mode can not be changed once you start adding rules, somake sure your selection is correct. (It is possible to change theconfidence mode of a system later, but it requires use of the EXSYSRule Compiler and also usually requires substantial editing of the ruletext file.).

C3.13: Entering Choices

You will next be asked to input the choices. These are the goals oroptions that the system will decide among. If the system weremedical, it might be the diseases covered by the system. If it were ahelp desk, the choices would be the possible problems that the systemcould diagnose. When prompted, enter the first choice and click OK.You will be asked for another choice. Continue entering choices untilall of the ones you think you will use are entered. You can alwaysadd more, or delete, choices later. If you wish to examine the choicealready entered, click Cancel and a list of the choices will bedisplayed. To add more to the list, click on New Ch. and continueadding choices.

When all choices have been added, click Cancel and then click OK inthe choice list dialog box. A short cut is to just press the RETURNkey when asked for a choice, and then the RETURN key again toselect the default OK button.

C - RULE EDITOR 16

Page 75: Manual Exsys

C4: Main System Title Screen

Once a new expert system has been created, or an existing systemhas been read, the system title screen is displayed.

Title

Author

C - RULE EDITOR 17

Page 76: Manual Exsys

C5: Saving the Changes to a Knowledge Base

Edit Rule Options KBfiles Questions

NewOpen

Save AsRevert to Saved

Print

ExitAbout

File

Save

It is a good idea to periodically save to disk the work done on theexpert system. This is especially true when testing custom writtenexternal programs. EXSYS maintains most of the expert system inmemory. If the system crashes, all work since the last save will belost. Selecting Save from the File menu will save the knowledgebase to disk. If any rule editing windows are open, you will be askedif you wish to save the changes made in those windows before therules are saved to disk.

If you attempt to exit EXSYS without saving your work, you will beprompted to save the rules before exiting.

Password ProtectionEXSYS provides optional password protection for encryption of aknowledge base file. When the rules are saved, the program will askif password protection is desired.

Use Passwords? N O

Y E S

If the option of locking out rule display was selected, the passwordoption must be used. Locking the rule display prevents someonewith only the Runtime password from accessing or examining therules with WHY or HOW. Once locked, the rules can be unlockedonly with the Edit password. If password protection is used, the ruledisplay locking option may be selected from the Options Menuselecting Parameters, then clicking Lock Display Off. Locking of

C - RULE EDITOR 18

Page 77: Manual Exsys

rule display applies only to the Runtime program, not running therules from within the Editor.

If password protection is selected, the program prompts for an Editpassword and a Runtime password. These should be alphanumericstrings of 6 or more characters in length. The program has twopassword access levels, requiring two different passwords. TheRuntime password allows an end user to run the knowledge basewith the Runtime Program but not to edit or change any of the rules.The Edit password allows access to the knowledge base with theEditor Program. The Edit password does not work with the Runtimeprogram.

Use Passwords? N O

Y E S

Edit

Runtime

Show Current Passwords

O K Cancel

Hide typing

If password protection has already been selected, the defaultpasswords will be the existing passwords. These can be displayed byclicking Show Current Passwords.

Normally, when the passwords are typed, they will be displayed inthe editing box. However, if the situation requires that the passwordsnot be echoed to the screen, click on the Hide Typing box. In thiscase, the passwords will not be echoed to the screen. Instead, afterthe passwords are entered, the program will ask you to input thepasswords again to confirm the correct input. Use care when usingthis option since it is possible to make a typographical error bothtimes, in which case the system will be encrypted and you will notknow the password.

If passwords are not used, EXSYS creates unencrypted knowledgebase files.

C - RULE EDITOR 19

Page 78: Manual Exsys

C6: Exiting the Editor

Edit Rule Options KBfiles Questions

NewOpenSaveSave AsRevert to Saved

Print

About

File

Exit

To exit the EXSYS Editor, go to the File menu on the menu bar andselect Exit. If any edit rules are open and have been edited, you willbe asked if you wish to save changes to those rules. If the knowledgebase has been edited, you will be asked if you wish to save changes tothe knowledge base.

Macintosh Note: On the Mac, this menuentry is QUIT, not EXIT.

C - RULE EDITOR 20

Page 79: Manual Exsys

C7: System Help

Edit Rule Options KBfiles Questions

NewOpenSaveSave AsRevert to Saved

Print

Exit

File

About

To get help in using EXSYS Professional, select About from the Filemenu.

Macintosh Note: On the Mac, there is noAbout menu item, instead select theAbout EXSYS menu item under theApple menu.

This will bring up a dialog box with a HELP button.

EXSYS Professional EditorVersion 5.0© 1983-1996 EXSYS, Inc.Albuquerque, NM

Cancel

Help

Click on the help button. In Microsoft Windows, you can simplypress the F1 key to get to the system help functions. Help is alsoavailable by selecting the Help item from the Options menu.

C - RULE EDITOR 21

Page 80: Manual Exsys

A window will appear with a list of help topics.

Select help topic...

Help topics

Fresh Window Cancel Help

To get more information, either double click on a help topic, or selecta help topic with a single click and then click on the Help button. Awindow will display information on the selected topic. If you wish tohave the help information on the topic placed in a new help window,click the Fresh Window button.

Help Information

Cancel Prev Next Topics

C - RULE EDITOR 22

Page 81: Manual Exsys

Click the Prev button to see the information on the previous topic inthe help topic list. Click Next to see the information on the nexttopic in the help topic list. Click Topic to bring the help topic listwindow to the front. Click Cancel when done. Clicking Cancel ineither the Help Topic window or the Help Text window will closeboth windows.

There is fairly extensive help information in the Help Topics, andmany questions can be answered without referring to the manual.This is especially true for the syntax of the various commands inEXSYS, such as custom screen command, configure options, andreport generator commands.

C - RULE EDITOR 23

Page 82: Manual Exsys

C8: Copying Text from Other Applications

File Rule Options KBfiles Questions

CutCopyPaste

Edit

Text can be transferred from other applications and copied intoEXSYS or cut from EXSYS in any place where text input isexpected in a window. It is not possible to use these commands forinput requested by dialog boxes, since the main menu bar is inactivewhen the dialog boxes are displayed.

C - RULE EDITOR 24

Page 83: Manual Exsys

C9: Adding a New Rule to the Knowledge Base

File Edit Options KBfiles Questions

Edit RuleDelete RuleMove Rule

Use Rule Names

Qualifier ListVariable ListChoice List

Condition CutCondition CopyCondition Paste

Rule

Add Rule

To add a new rule, go to the Rule menu on the menu bar and selectAdd Rule from the pull down menu. The window that appears issimilar to the one which is used for editing a rule, but the rule will beempty.

EXSYS keeps track of the rule numbers internally, and will assign thenumber to the rule automatically.

See the section below on Editing a rule for the details on addingconditions to the rule.

C - RULE EDITOR 25

Page 84: Manual Exsys

C10: Editing a Rule in the Knowledge Base

File Edit Options KBfiles Questions

Add Rule

Delete RuleMove Rule

Use Rule Names

Qualifier ListVariable ListChoice List

Condition CutCondition CopyCondition Paste

Rule

Edit Rule

To edit an existing rule, go to the Rule menu on the menu bar andselect Edit Rule from the pull down menu. A dialog box appearswhich asks you to select the rule that you wish to edit.

Use Passwords? N O

Y E S

Edit

Runtime

Show Current Passwords

O K Cancel

Hide typing

Name: Number:

12345678

AAABABCDBBBBCCCDDDDEEEEFFFF

Enter Rule Name or Number:

OKCancel

New Rule

Last

C - RULE EDITOR 26

Page 85: Manual Exsys

The name list box contains the names of all of the named rules in thesystem, arranged alphabetically. The Number listbox contains a list ofthe numbers of each rule in the system.To select a rule, either

1. Click a rule number and then click the OK button.

2. Click a rule name and then click the OK button.

3. Double click a rule name or number.

4. Enter a rule number or name in the edit field.

When a rule name or number is selected, the corresponding numberor name will be highlighted in the other list box. To start a new rule,click the New Rule button. To edit the last rule entered, click theLast button and click the OK button.

Note: For large systems with many namedrules, creating and alphabetizing the list ofrule names can be a little slow. To disablethe display of the rule names (but still allowa rule to be called by name in the edit field),go to the Rule menu on the main menu barand select Use Rule Names. If this item ischecked, rule names will be used, if it is notchecked, rule names will not be displayed.

File Edit Options KBfiles Questions

Add RuleEdit RuleDelete RuleMove Rule

Qualifier ListVariable ListChoice List

Condition CutCondition CopyCondition Paste

Rule

Use Rule Names

C - RULE EDITOR 27

Page 86: Manual Exsys

After a rule is selected, or a new rule is started, the main Rulewindow will be displayed.

You can work on several rules at the same time and you can open upto 10 Rule windows simultaneously.

Rule Title and Number

IF:Qualifier

Var. / Math

Choice

Command

Repeat

IF PartTHEN PartELSE Part

AND ORNew OR

NoteReferenceName

Insert

O KChange

Delete

And/Or

CancelNextPrev

Three main types of conditions can be added: qualifiers, choices andmathematical expressions.

C11: Building a Rule

A rule is built by creating conditions in the IF, THEN, and ELSEparts of the rule. All rules must contain an IF part. The IF conditionsare statements that can be determined to be true or false. In a wellwritten rule, the conditions are easily read text statements ormathematical expressions.

C11.1: Positioning of New Conditions

The location that the new condition will be added depends on theInsert status.

C - RULE EDITOR 28

Page 87: Manual Exsys

When a new rule is started, the mode is set to add conditions tothe end of the IF part. When the IF part is complete, click onthe THEN Part radio button.

To add a condition to the end of the IF, THEN or ELSE part

1. Click on the radio buttons labeled IF Part , THENPart or ELSE Part.

2. Click on Qualifier, Variable, Choice or Commandand build a condition, or select Condition Pastefrom the Rule menu.

3. The new condition will be added at the end of thesection.

To add a condition somewhere other than the end of a section:

1. Click the Insert box. This puts the rule in insertmode.

2. Highlight a condition in the rule by clicking it.

3. Click Qualifier, Variable, Choice or Commandand build a condition, or select Condition Pastefrom the Rule menu.

4. The new condition will be added just before thehighlighted condition. All subsequent conditions inthe rule will have been moved down one. Theselected condition will remain selected. (If nocondition is selected, the new condition will be addedto the end of the currently active section.)

The "end of section" and insert modes can be mixed simply byclicking on the Insert box.. To return to the IF part after theTHEN part has been started, simply click on the IF Partbutton.

C11.2: Adding a Qualifier Condition

Qualifiers are multiple choice lists. Many factors in a decision-makingprocess are best expressed as multiple choice lists.

To add a qualifier condition, click on the Qualifier button in the Rulewindow. A dialog box will appear for adding a qualifier condition.

C - RULE EDITOR 29

Page 88: Manual Exsys

Qualifier

O K NOTEdit

Delete

New Qual.

Cancel

Select qualifer by text or name: Find Find Again Name

QUALIFER LIST

ASSOCIATED VALUE LIST

The Qualifier List area will contain a list of all of the qualifiers knownto the system. If you click on a qualifier, the list of values associatedwith that qualifier will be displayed in the lower window. Themeaning of "qualifier" and "associated values" are explained below inthe section on adding or editing a qualifier.

C - RULE EDITOR 30

Page 89: Manual Exsys

C11.3: Adding / Editing a Qualifier

To add a new qualifier or edit an existing qualifier, select a qualifierfrom the qualifier list and click on the Edit button or click on theNew Qual button. The Add/Edit Qualifier window will be displayed.

Add / Edit Qualifier

O K

Cancel

Qualifier ## NEW QUALIFIER Name:

QUALIFER TEXT

ASSOCIATED VALUE LIST

VALUE WORK WINDOW

Edit Replace Cancel Edit Add Delete

Display at endLimit input values to: Default Value:

Conf. Options

Data Acqu.

Qualifier and their associated values are simply multiple choice lists.Typically, the qualifier is part of a sentence up to and including theverb. "Values" are the possible completions of the sentence that theuser is able to select among. A qualifier can have a maximum of 30associated values.

The text of the qualifier is edited in the top edit region. The qualifiertext can be directly edited. If this is a new qualifier, the word"Qualifier" will appear here. For new qualifiers, replace the word"Qualifier" with the actual text of the qualifier. To do this, dragacross "Qualifier" or double click on it to highlight it. Then type thetext of the qualifier.

The bottom edit region also has the word “Values.” This is replacedwith the actual values you wish to use. After the text of a value isentered, click on the Add button to add it to the list in the middlelistbox. Notice that when text is entered in the "value" edit region,pressing <ENTER> (<RETURN> on some machines) will add thevalue to the list.

For example, suppose we are creating an expert system to identifyflowers and we want to create a condition dealing with the color of

C - RULE EDITOR 31

Page 90: Manual Exsys

the flower. We would click on New Qual in the Qualifier window.The new qualifier window would be displayed. Replace the word"Qualifier" in the top edit region with “THE COLOR OF THEFLOWER IS.”

Enter the list of values that the user may select among. In thisexample, the qualifier can have the values RED, BLUE, YELLOWand WHITE. Replace the word "Values" in the lower edit regionwith the first value "RED" and click the Add button or press<ENTER>. RED will appear in the middle list box as the first value.Enter "BLUE" in the lower edit region and click Add. BLUE willappear as the second item in the value list. Do the same forYELLOW and WHITE. The result will look like:

Add / Edit Qualifier

O K

Cancel

Qualifier ## NEW QUALIFIER Name:

QUALIFER TEXT

ASSOCIATED VALUE LIST

VALUE WORK WINDOW

Edit Replace Cancel Edit Add Delete

Display at endLimit input values to: Default Value:

Conf. Options

Data Acqu.

C11.4: Editing an Existing Qualifier Value

The middle listbox contains a list of the possible values associatedwith the qualifier. These values can not be directly edited, but mustbe moved to the lower Value Work Window. To do this, select avalue by clicking it and then click the Edit button. The value willappear in the work window, where it can be edited. When thechanges are made, click the Replace button to replace the existingvalue with the edited value or Add to add a new value to the list.

C - RULE EDITOR 32

Page 91: Manual Exsys

Note: When an edit to a value is acceptedby pressing the Replace or Add button, itimmediately takes effect. Pressing theCancel button will not undo it. Pressing theCancel before the value is accepted willcancel the edits made in the work window.

Not all values for the qualifier may be able to be displayed at onetime. If there are more values than can be displayed, the listbox willhave a scroll bar on the right side.

C11.5: Deleting an Existing Qualifier Value

To delete a qualifier value, select the value and click the Deletebutton. EXSYS will check all the rules to determine if the selectedvalue is in use in a rule. Values can be deleted only if they are notused. If the value is found to be in use, a list of the rules using thequalifier will be displayed. These rules must be modified to not usethe value prior to deleting the value.

C11.6: Options for Each Qualifier

Each qualifier can have several parameters set that effect how thequalifier will behave or be referenced. The parameters set for aqualifier can be changed later. Each qualifier can have differentparameters, giving the developer a great deal of flexibility. Theparameters are set / edited from the Add / Edit Qualifier window.

C11.7: Qualifier Name

The first parameter is an optional name to associate with the qualifier.To add a name to the qualifier, enter a name in the edit field labeled"Name". This name can be used from the Command Language andsome internal EXSYS commands. Referring to the qualifier bynumber is always available, but having a name is more convenient insome applications. The name of a qualifier is limited to 16 characters,including spaces. If the command language, CLEAR commands, orexternal programs are not used, naming the qualifier probably is notnecessary.

C - RULE EDITOR 33

Page 92: Manual Exsys

C11.8: Display of Qualifier Values with Results

The qualifier can be displayed in the Results Screen at the conclusionof the run. The usual selection is to not display the qualifier.However, if the qualifier provides some information that should bedisplayed to the user along with the conclusions, it can be done.Qualifiers that are derived from other rules or obtained from externalprograms are often displayed. To indicate that the qualifier should bedisplayed, click the check box labeled "Display at end".

C11.9: Maximum Number of Values

When the expert system is run, the user is able to select the value, orvalues, that are appropriate from the list associated with the qualifier.EXSYS normally allows the user to select multiple values or even allthe values. In some cases, the developer may want to limit the userto the selection of one or only a few values from the list. This isuseful when selecting several values is logically inconsistent. Beingable to force the user to select only a single value makes the logicalstructure of the rules much less complicated. Otherwise, the systemwould have to account for logically inconsistent input in the rules.To limit the number of values that can be input, enter the maximumnumber of values that should be accepted in the edit field labeled“Limit input values to.”

Using the flower color example from before, you may want the userto be able to select only one color for the flower. To do this, enter"1" in the edit field labeled “Limit input values to.” Now when thesystem is run, the user will be allowed to input only a single color forthis qualifier. Usually, a qualifier will be limited to a single value orallowed to have all values selected. Limiting the user to only two orthree values is possible but is often not logically necessary.

Note: Even though a qualifier may onlyallow the end user to select a single value,the developer can still select multiple valueswhen building the rule.

C11.10: Default Value

Normally, when information on a qualifier is needed, the system firsttries to derive information from other rules. If the information is notavailable that way, the user is asked to provide the information by

C - RULE EDITOR 34

Page 93: Manual Exsys

selecting from among the possible values of the qualifier. In somecases, the developer may not want a qualifier asked of the user.Perhaps the qualifier asks a more complex question than the userwould be expected to answer. In such cases, setting a default valueguarantees that the user will never be asked about the qualifier,regardless of other input.

The default value should be used rarely, and only in very specialcases. The default is a value to be used instead of asking the user forinput. Once a default value is set, the user is never asked to provideinput on that qualifier. However, if data on the qualifier can bederived from other rules or external sources, the default value will notused.

To set a default value, enter the number of the value to use in the editfield labeled "Default Value". Only a single value can be selected asthe default.

For example, suppose we have a qualifier:

The color is1 red2 white3 blue4 green

We could set a default value of 3, blue. When the program needed toknow the color, it would first check to see if any information wasalready available from external programs or other rules that had fired.It would then check the rules to see if any rules could provideinformation on the color. If any rules were found, they would betested. If, after testing the appropriate rules, a value had been set forthe qualifier, the default would not be used. However, if after testingthe other rules, nothing was known about the qualifier, the defaultvalue of 3 would be set and the program would continue. The userwould never be asked about the color.

Note: Default values for qualifiers aredifferent from initial values for variables.The initial value of a variable is always setat the start of a run. It is set regardless ofother rules that provide information aboutthe variable. Default values for a qualifierare used only if no other method providesthe information. They are set only whenneeded.

C - RULE EDITOR 35

Page 94: Manual Exsys

C11.11: Automatic Data Acquisition

Many external sources can be used to automatically set the qualifier'svalue, rather than asking the user for information. Data can beobtained directly from spreadsheets, databases, the blackboard, aframe, graphics and many other sources. To associate a dataacquisition command with the qualifier, click on the Data Acqu.button.

A list of the possible data acquisition commands will be displayed. Asource for the data can be selected, and EXSYS will prompt the userfor the information needed to build the data acquisition command.(See Chapter G for more information on data acquisition commands).

C11.12: Custom Formula Systems

If the confidence system using custom formulas was selected, otheroptions for the qualifier relating to user-supplied confidence, defaultconfidence values, and ranges are available. To set these options,click on the Conf Options button. (See Section C40 on using theCustom Formula system for more information on these options.)

C11.13: Finished Setting Qualifier Parameters and Values

When all values have been entered and parameters set, click the OKbutton to return to the Qualifier Window. The values and parameterscan be changed later from the qualifier list window by clicking aqualifier to select it, then clicking the Edit button.

C - RULE EDITOR 36

Page 95: Manual Exsys

C12: Selecting Qualifier Values to Build a Condition

Qualifier conditions are built from the Qualifier list window.

Qualifier

O K NOTEdit

Delete

New Qual.

Cancel

Select qualifer by text or name: Find Find Again Name

QUALIFER LIST

ASSOCIATED VALUE LIST

Click on the qualifier you wish to use. Once a qualifier is selected, itsassociated values will be displayed in the value listbox.

To build a condition, click the values you wish to use. If you want touse more than 1 value, click several. All highlighted values will beused. If a value is selected, clicking it again will de-select it. Click theOK button when you are finished selecting your values. A doubleclick on a value also indicates that the selection is complete. Thequalifier condition you have selected will be added to the rule.

In the IF part, you may also use NOT in association with values. Touse NOT, click the box in front of NOT, and an X will appear in thebox. This will build a condition of the form “qualifier is NOT value,”rather than the normal form of “qualifier is value.” After selectingNOT, select the values in the usual way.

If the number of an already entered qualifier is unknown, do notcreate a new qualifier and list of values identical to the previous entrybecause the program does not know they are the same and thereforeasks the user for the same information twice. Instead, use the existingqualifier. To FIND a qualifier with specific text in it, click on theFIND button. You will be asked for the text to find, and if thequalifier, values or names are to be searched. When you click

C - RULE EDITOR 37

Page 96: Manual Exsys

Search, the first qualifier with the specified text will be displayed. Tosearch for the next occurrence of the text, click on Find Again.

To select a qualifier by name, click the Name button. A list of all ofthe qualifier names will be displayed. Click the name you wish to use.

Using the previous example, suppose you want the IF condition tosay THE COLOR OF THE FLOWER IS RED. The qualifier wouldbe displayed as

Qualifier

O K NOTEdit

Delete

New Qual.

Cancel

Select qualifer by text or name: Find Find Again Name

THE FLOWER STEM ISTHE CENTER OF THE FLOWER ISTHE SIZE OF THE FLOWER IS

THE COLOR OF THE FLOWER IS

2 BLUE3 YELLOW4 WHITE

1 RED

Since you want RED, you would click "1 RED", and click OK, ordouble click RED.

If you want the condition THE COLOR OF THE FLOWER ISBLUE OR YELLOW, click "BLUE" to select it , then clickYELLOW to that color as well. If you want THE COLOR OF THEFLOWER IS NOT WHITE, click NOT, then click WHITE. Whenthe OK button is clicked, the condition will appear in the rule.

If multiple values are selected for a qualifier in the THEN/ELSE part,they will be connected by "and" rather than “or,” as they were in theIF part. This is because in the IF part, if any of the values are true,the rule is true. The IF values are ORed. In the THEN part, all thevalues are true if the IF part is true, so the THEN values are ANDed.

The form "NOT" plus value number(s) cannot be used inTHEN/ELSE qualifiers. The conditions in the THEN part must beaffirmative.

C - RULE EDITOR 38

Page 97: Manual Exsys

C12.1: Adding a New Value

A new value can be added to the list by selecting the qualifier andclicking on the EDIT button. Enter the new value for the qualifierand click the ADD button (this is the same thing as entering valuesfor the new qualifier). Up to the maximum of 30 values can beassociated with a qualifier.

C12.2: Correcting Typographical Errors

If a typographical error was made in the text of the qualifier or any ofits values, or if rephrasing is desired, select the qualifier and click theEDIT button. The qualifier text can be edited directly. To edit avalue, select the value and click on the EDIT button. The value willappear in the lower edit window. Make the required changes andclick the REPLACE button.

Note: If a qualifier or value is changed, it isautomatically changed in all rules where itappears.

Deleting a QualifierIf a qualifier with all its values needs to be deleted, select the qualifierand click the Delete button. The program checks all the rules to seeif the qualifier is used in any rule. If it is not used, it is deleted and theremaining qualifiers or values are renumbered accordingly.

If the qualifier or value is found to be in use, it cannot be deleted.The program instead displays a list of the rules in which the value isused. The rules must be edited so the qualifier is not in use before itcan be deleted. This prevents accidentally deleting a data elementthat is expected when the rules are run.

To delete a single value from the qualifiers list, select the qualifier andclick the EDIT button. Select the value to delete and click Delete.As with qualifiers, if the value is used in the rules, it cannot bedeleted.

C12.3: Qualifier Conditions Combined with OR

Several qualifiers can be combined with OR to produce OR blocks ina rule. OR blocks can only be created in the IF part of a rule, andmake sense only in the IF part.

C - RULE EDITOR 39

Page 98: Manual Exsys

If any condition in an OR block is true, the entire block is true.Groups of OR blocks can be ANDed to make complex statements.For example:

IF: The color is red

AND Today is MondayAND The weather is hot

will be true only if all three conditions are true.

On the other hand,

IF: The color is red

AND Today is MondayOR The weather is hot

will be true if "The color is red" and either the second or thirdcondition is true. The "OR" at the start of the third conditionindicates an OR block, which is ANDed with the first condition.

IF:The color is red

OR Today is MondayOR The weather is hot

will be true if any of the three conditions is true.

We could also create two OR blocks, such as:

IF:The color is red

OR Today is MondayAND The weather is hotOR The price is low

Now either the first or second condition must be true, and either thethird or fourth condition must be true. The AND in front of the thirdcondition indicates two OR blocks ANDed together.

When the rule is tested, the program asks the minimum number ofquestions. If any condition in an OR block is known to be true, theother conditions in the block are not tested.

C - RULE EDITOR 40

Page 99: Manual Exsys

An OR block is created by starting a new rule. The AND radiobutton will be highlighted. To start an OR block, click the OR radiobutton and enter a qualifier condition. The OR button will stayhighlighted, and multiple qualifier conditions can be entered whichwill all be part of the same OR block. To return to ANDingconditions, click on the AND button. To start a new OR block,which will be ANDed with the previous OR block, click on the NewOR button.

Rule Title and Number

IF:Qualifier

Var. / Math

Choice

Command

Repeat

IF PartTHEN PartELSE Part

AND ORNew OR

NoteReferenceName

Insert

O KChange

Delete

And/Or

CancelNextPrev

For example to build:

IF: The color is red

OR Today is Monday AND The weather is hot OR The price is low

Click the OR button and enter the condition "The color is red".Then enter the condition "Today is Monday". The OR button willstill be selected and the two conditions will be part of the same ORblock. To start the second OR block, click New OR and enter "Thewater is hot". EXSYS will automatically switch back to the ORbutton from the New OR button. Now enter "The price is low" andthe IF part is complete.

C - RULE EDITOR 41

Page 100: Manual Exsys

C13: To Change theAND / OR Blocks

To change the AND and OR blocks in a rule, press the AND/ORbutton in the rule window. You will be presented with each of the IFqualifier conditions in the rule sequentially.

Condition #1 / 5

Text of condition

AND

Part of OR Block

Last OR in Block

O K

Cancel

To AND with the previous qualifier, select AND and press the OKbutton

To start a new OR block, or OR the qualifier with the previousqualifier, select Part of OR Block and press the OK button.

To indicate the last OR in the block, select Last OR in Block andclick the OK button. This is only necessary if you wish toimmediately start another OR block. If subsequent conditions areANDed, you can simply press AND for the next qualifier. Theprogram will tell you if a condition is not a qualifier condition.

It is not necessary to indicate the last OR in a block unless a new ORblock is being started. The program will automatically mark the lastOR in the block.

C - RULE EDITOR 42

Page 101: Manual Exsys

C14: Using QualifiersWhen a qualifier is defined, you should consider the needs of yourend user—having consistent types of values makes EXSYS easier touse. For example, if a qualifier deals with an item, do not mix colordescriptors (black, yellow, green) with shape descriptors (big, small) inthe same qualifier. If a description of different features of the sameitem is necessary, the same qualifier text can be used more than once.The program keeps track of the qualifier by number, not text. Asystem could possibly have these two qualifiers:

THE LEGS ARE THE LEGS ARE YELLOW SHORT

GREEN LONG

However, using exactly the same qualifier may cause some confusionto the end user and definitely causes problems for the Rule Compiler.A better approach would be

THE LEG COLOR IS ...

AND

THE LEG LENGTH IS...

Occasionally you may want to use a condition such as “A can be Xor Y but not Z.” This can be done by repeating a qualifier in the IFpart. Suppose possible values for a bird's leg color are black, yellow,green, and red. A condition says leg color can be yellow or greenbut not black. This is accomplished by using two IF conditions:

IF THE BIRD'S LEG COLOR IS YELLOW or GREEN

AND THE BIRD'S LEG COLOR IS NOT BLACK

Both statements must be true for the rule to be true. If the userinputs both yellow and black in answer to the program's query aboutleg color, the first condition would be true but the second would befalse.

When creating rules, all IF conditions and OR blocks in a rule mustbe true for the THEN conditions to be considered true. However, ina given condition that has multiple acceptable values for a qualifier,only one value need be true for the condition to be true.

Since the program checks the conditions in a rule in the order theyappear, the most general conditions should appear first. If the

C - RULE EDITOR 43

Page 102: Manual Exsys

program determines that a frequently used condition is false, it maybe able to eliminate a large number of rules without asking the userunnecessary questions. If the expert system is asking unnecessaryquestions, it may need more general conditions at the start of somerules. The ability to copy conditions from previous rules and reorderconditions makes it easy to add general conditions to rules.

C - RULE EDITOR 44

Page 103: Manual Exsys

C15: Mathematical Expressions and Variables

Variables and mathematical expressions are used for a variety offunctions in EXSYS . Mathematical expressions can be added inboth the IF (to test a value) and in the THEN/ELSE parts (to assign avalue). EXSYS supports mathematical expressions with booleanoperators, trig functions and a variety of special functions to describecomplex relationships.

C15.1: Variables

A variable is any string of alphanumeric characters, including spaces,enclosed in brackets [ ]. Only the first 18 characters are significant.Only letters, digits, and spaces can be used in variable names.Variable names should be descriptive of what they represent. Thefollowing would be valid variable names: [COST], [COST OFSYSTEM], or [X].

The following would not be valid because they include illegalcharacters: [X#], [X/Y] or [NAME 1.2]. These are not valid namesbecause they all include characters other than letters, digits andspaces.

EXSYS supports only three types of variables—numeric, string andtext-only. Numeric variables can be assigned a numeric value.String variables can be assigned a string value, and text-only variablestake no value but are used to display special text to the user.

As with qualifiers, when the system needs the value of a variable toevaluate an IF expression, backward chaining will invoke the rulesthat assign a value to the variable in the THEN/ELSE parts todetermine the value.

C15.2: Math Expressions in the IF Part

In the IF part, variables are used to form an expression that can beevaluated to TRUE or FALSE. This requires the expression tocontain a conditional operator to test the left and right side of theexpression. For example, you might have the following expression:[X] > 0. It is important to remember that IF conditions are alwaysexpressions which can be determined to be TRUE or FALSE.

C - RULE EDITOR 45

Page 104: Manual Exsys

Additional details on conditional operators and mathematicalexpression syntax are described below.

C15.3: Math Expressions in the THEN/ELSE part

Math expressions are expressed differently in the THEN/ELSE part.In the IF part, the expressions are tests for validity, while in theTHEN part, the expressions are assignments of value to a variable.For example, in the IF part "[X] = 5" means "If the value of [X] is 5,the statement is true." In the THEN part, values are assigned tovariables and the expression would be phrased "[X] IS GIVEN THEVALUE 5" which means, "assign the value 5 to the variable [X]."

C15.4: Building Math Conditions in a Rule

To add a mathematical expression to a rule, click the Var / Mathbutton in the rule window.

IF PartIf you are adding a condition to the IF part of the rule, a window willappear for you to enter the expression you wish to add.

Add Formula

O K

Please enter a formula

Display Variables Cancel

Enter a formula that can be tested as a boolean expression (such asthe formula [X] > 0). To see a list of the variables currently definedin the system, click the Display Variables button.

The expression you enter can contain new variables. EXSYS willautomatically check for new variables and ask you to set theparameters for them. If a new variable is found in the expression,EXSYS will display the Add/Edit Variable window which is describedlater.

C - RULE EDITOR 46

Page 105: Manual Exsys

EXSYS will also perform a syntax check of the expression you haveentered and warn you of any syntactical errors.

C15.5: THEN / ELSE Part

In the THEN/ELSE part, the condition will be an assignment of avalue to a variable. In that case, you must first select the variable toassign the value to, then input the value or expression to assign to thevariable.

EXSYS first asks you to select the variable to assign the value to.This can be an existing variable, or a new variable. Since theassignment is usually made to an existing variable, the list of variablesin the system is displayed. The variables are arranged alphabetically.

Variables

Numeric

String

Text Only

O K

Edit Options

New Variable

VARIABLE LIST

VARIABLE TEXT Cancel

When a variable is selected from the list by clicking on it, its type isdisplayed by having the Numeric, String or Text Only buttonselected. The prompt text of the selected variable will be displayed atthe bottom of the window. These variables can not be edited orchanged from this window. They are presented for information only.To change the parameters for a variable, select a variable and clickthe Edit Options button.Either select a variable from the list to assign a value to, or click onNew Variable to add a new variable to the system. If a variable isselected from the list, either click the variable and then click the OKbutton, or double click the variable you wish to use.

C - RULE EDITOR 47

Page 106: Manual Exsys

If you have selected to either edit an existing variable or add a newvariable, the Add /Edit Variable window will be displayed. If editingan existing variable is selected, the current parameters for the variablewill be filled in.

Add / Edit Variable

O K

Name:

Prompt:

NumericStringText Only

Display at end

Initialize:Upper Limit:Lower Limit

Data Acquisition

Conf. OptionsCancel

C15.6: Variable ParametersEach variable has a variety of parameters that can be set.

Variable NameEach variable must have a unique name. The name can be up to 18characters in length and can contain spaces. Try to make the namedescriptive of what the variable represents. EXSYS requires you touse a name.

Variable PromptEach variable must have associated text that will be used when askingthe user for the value of the variable or for displaying the value of thevariable. Usually this text should describe what the variablerepresents (the exception to this is Text-Only Variables, describedbelow). The variable name used in the formula should only bedescriptive enough to identify what the variable means, but the textprompt can be very specific. For example, you might have a variable[LENGTH OF BEAM] which suggests what the variable means, butthe text you associated with it could be "The length of the beam fromthe base to the first cross beam as measured in centimeters." Thistells the user exactly what information is expected.

C - RULE EDITOR 48

Page 107: Manual Exsys

Variable TypeEXSYS has two types of variables—numeric and string variables.Numeric variables are stored as floating point numbers and arehandled in algebraic expressions. String variables are text strings andcan be used for string concatenation or comparison. Text-Onlyvariables are used in the THEN / ELSE part of rules to displayspecial messages.

To set the variable type, click the appropriate radio button forNumeric, String or Text Only.

Note: Once the variable type is set, and thevariable has been used in an expression,changing the type may be prohibited.

Numeric VariablesIf the variable is handled as a numeric, its value will be a floatingpoint value. Numeric variables can be used in algebraic expressionfor testing or assignment. Only numeric variables can have initialvalues or upper and lower bounds assigned.

The following would be valid expressions with numeric expressions:

[X] < 1.56[X] + [Z] >= [Z]/7.4SIN([LENGTH]) <= [X]*[Z][X] IS GIVEN THE VALUE [Z]/8.26

The following are not valid expressions if [X] is numeric:

[X] > "ABCD"[X] IS GIVEN THE VALUE [X] + "ABCD"

since both combine numeric and string expression.

String VariablesIf the variable is handled as a string, its value will be text and not afloating point value. This can be very useful for names or other textinformation. When the end user is asked for the value of a stringvariable, the text input will be taken as the string value of thevariable.

String variables can be used in the IF part in expressions comparingthem to other string variables or text strings (for example, you mayhave text enclosed in double quotation marks). The standardcomparison tests of <, >, =, <=, >=, and <> can be used. Validity of

C - RULE EDITOR 49

Page 108: Manual Exsys

the comparison is based on alphabetical order. For example, if [S]and [T] are string variables, the following would be valid expressions:

[S] = "EXSYS"[S] <= [T][T] <> "THIS IS A TEST"[S] + [T] <= "THIS IS A TEST"

The first would be true if the string value of the variable [S] were thestring “EXSYS.” The second would be true if the string value of [S]were alphabetically less or equal to the string value of [T]. The thirdwould be true if the string value of [T] were not “THIS IS A TEST.”The fourth would concatenate [S] and [T] and then do thecomparison.

The following would not be valid string expressions:

[S] > 4[S] = EXSYS[S] + 3 > [T]

The first compares a string variable with a numeric value. Thesecond does not have the comparison string in quotes. The thirdattempts to add a numeric value to a string variable.

String variables can also be used in the THEN or ELSE part of rulesin assignment of value statements. This is done the same as anumeric variable, but the value assigned must be another stringvariable or a string enclosed in double quotes. The following wouldbe valid:

[S] IS GIVEN THE VALUE "EXSYS"[S] IS GIVEN THE VALUE [T][S] IS GIVEN THE VALUE [T] + "ABC"

The following would not be valid:

[S] IS GIVEN THE VALUE 4[S] IS GIVEN THE VALUE EXSYS

The first assigns a numeric value to a string variable. The seconddoes not have the text in quotes.

Data for a string variable can also be passed in from externalprograms.

C - RULE EDITOR 50

Page 109: Manual Exsys

Text Only VariablesIn most cases, variables will have an associated value, since onlyvariables that have associated values can be used in calculations orassignments. If a variable is defined to be a Text-Only variable, it willnot have an associated value with the variable. Instead, the textassociated with the variable will be displayed in the rule as a note.This can only be done in the THEN / ELSE part of the rule. If therule fires, this note will be displayed with the final sorted list ofchoices at the end of the run. This allows text notes to be selected byrules for display with the results.

If a variable does not have a value associated with it, the program willonly display the prompt text associated with the variable in the rulesand the results. This is the one case where the prompt text does nothave to describe the variable. No calculations can be done with aText Only variable.

For example: We could have a variable [CAUTION 1] with theprompt text “DO NOT ALLOW THE COMPOUND TO BEEXPOSED TO WATER.” The first time this caution is appropriatein the THEN part of a rule, create a new variable named [CAUTION1] and define it to be text only. The prompt text associated with[CAUTION 1] would be “DO NOT ALLOW THE COMPOUNDTO BE EXPOSED TO WATER.” This text would be displayed asone of the rule's THEN conditions, and would be displayed with theresults if the rule fired. To add the caution to another rule, all thatwould be needed is to select the variable [CAUTION 1] and the sametext would appear. If any rule with [CAUTION 1] fired, the text"DO NOT ALLOW THE COMPOUND TO BE EXPOSED TOWATER" would appear with the results.

Display of VariableA variable can be displayed at the end of a run in the result screen.Usually, only variables that are calculated by the program during therun would be flagged for display. However, in development, havingthe variables displayed may be useful for checking the expert system.To indicate that the variable should be displayed, click the Display atEnd box. This display can be switched on or off later.

Initialization of Numeric VariablesIf the variable is numeric, the variable can be initialized to a value atthe start of the run. If a variable is initialized, the program will notask the user for its value. The initial value for the variable will alwaysbe set at the start of the run, before any rules are tested. Initializing avariable is most useful for running total variables (a variable thatcontains a partial value with amounts repeatedly added to it). Wemight have a variable [PRICE] that displays the total price of theequipment recommended by the expert system. Each rule thatrecommends a piece of equipment would include an expression thatwould add the cost of the equipment to the running total, [PRICE].

C - RULE EDITOR 51

Page 110: Manual Exsys

For example, to add 10 to the running total for [PRICE], use

[PRICE] IS GIVEN THE VALUE [PRICE] + 10

We do not want the program to ask the user for a starting value for[PRICE]. Instead, we want the program to start with a value of 0.0.This could be done in the command language, but it is easier to setthe starting value to 0.0 by initializing the variable [PRICE] to a valueof 0.0. Most variables should not be initialized. Variables that requireend user response should never be initialized. Only numeric variablescan be initialized.

To indicate that the variable should be initialized and set the initialvalue, enter the value in the edit field labeled Initialize .

Range LimitsIf the variable is numeric, the acceptable user input can be limitedusing pre-established upper and lower bounds. If limits are set, andthe user's input is outside the acceptable range, the program willindicate that the data is out of range and asks, again, for input. Anupper limit, lower limit, or both can be assigned. Range limits arevery useful when the rules only make sense if the user provides inputwithin a certain range. For example, you might have a rule that isvalid only if [X] is greater than or equal to 0. If the end users input anegative value for [X], they will get invalid answers. By setting alower limit of 0, you can guarantee that the value of [X] will beacceptable, and not have to handle unrealistic input in the rules.

To set an upper or lower limit, enter the limit value in the edit fieldlabeled Upper Limit or Lower Limit. The value selected as a limitwill be an acceptable value. If the limit is set to 0, the user will beable to input a value of 0. Limits can only be applied to numericvariables. Limits are optional and are not required.

Automatic Data AcquisitionMany external sources can be used to automatically set a variable'svalue, rather than asking the user for additional information. Datacan be obtained directly from spreadsheets, databases, the blackboard,a frame, graphics and many other sources. To associate a dataacquisition command with the variable, click the Data Acqu. button.

A list of the possible data acquisition commands will be displayed. Asource for the data can be selected, and EXSYS will prompt the userfor the information needed to build the data acquisition command.

(See Chapter G for more information on data acquisition commands)

C - RULE EDITOR 52

Page 111: Manual Exsys

If a data acquisition command has been associated with the qualifier,it will be displayed in the prompt. You can either directly edit thedata acquisition command, or press the Data Acquisition button tobuild a new command.

Custom Formula SystemsIf the confidence system using custom formulas was selected, otheroptions for the variable relating to user-supplied confidence, defaultconfidence values, and ranges are available. To set these options,click the Conf Options button. (See Section C40 on using theCustom Formula system for more information on these options.)

Finished Setting Variable Parameters and ValuesWhen all parameters have been set, click on the OK button. Thevalues and parameters can be changed later from the variable listwindow by clicking on a variable to select it and then clicking on theEdit button.

C15.7: Entering the Expression to Assign

After the variable to assign a value to has been selected, a window forentering the expression to assign will be displayed.

Add Formula

O K

Please enter a formula

Display Variables Cancel

This is the same window that appeared in the IF part for entering aconditional test, but in this case, enter just the expression to assign tothe variable. The condition that will appear in the rule has the form:

[VARIABLE] IS GIVEN THE VALUE expression

C - RULE EDITOR 53

Page 112: Manual Exsys

The [VARIABLE] has already been selected. The "IS GIVEN THEVALUE" is supplied automatically by EXSYS, so only the expressionis needed.

When the expression is entered, click the OK button. The formulawill be automatically checked for new variables. If any new variablesare found, EXSYS will display the dialog box for setting the promptand other parameters for the new variable. Once all the variables inthe formula are defined, the condition will be added to the rule.

C15.8: Expressions

An EXSYS expression can range from any algebraic expressionderived from a single number to complex expressions. Usually theexpression contain EXSYS variables. Expressions can be simple orcomplex.

C15.9: Arithmetic OperatorsThe following arithmetic operators are recognized:

* (multiplication)/ (division)+ (addition)- (subtraction)% (modulus operator)^ (exponential function- A^B is A raised to the B

power)

Parentheses can group expressions in the order of calculation thatyou wish to use. Spaces can be included between operators to makethe formula easier to read.

C15.10: Boolean Operators

The EXSYS expression evaluator supports boolean operators inexpressions. This is especially useful in operations in the IF part ofrules, since several expressions can be combined to make a morecomplex test expression. For example:

IF [X]>0 OR [Y]<100

A formula with boolean operators is entered the same as any otherformula, it just includes boolean operators.

C - RULE EDITOR 54

Page 113: Manual Exsys

The boolean operators supported are:ORANDNOT|| (same as OR)&& (same as AND)! (same as NOT)

These operators can be used with parentheses to produce complexexpressions. Remember, if the users ask WHY or HOW, they maynot easily read and determine the validity of expressions withcomplex boolean operations.

The result of a boolean operation is 0 if false or non-zero if true.Since the result of a boolean operation is a numeric value, it can beused with other numeric expressions. For example:

6 * (4=2) && 1

is acceptable. It would be evaluated as: (4=2) is a test expressionreturning 0, boolean FALSE. 6 * 0 is 0, a numeric variable. 0&&1is 0, a boolean expression returning false, 0. While this expression isacceptable, it is somewhat unusual, and when it is entered in anexpression, a warning message such as "Boolean where numericexpected" would appear. This is not necessarily an error. It is only awarning that the syntax is unusual and a numeric value is being usedas a boolean operator.

Note: Boolean true is not always 1, but it isguaranteed to be non-zero. It will not be 1in cases where numerics other than 0 or 1are used where booleans are expected.

Non-zero numeric values combined with booleans will be taken astrue, but the value will propagate through the expression. Forexample:

(4=4) && 7

will return TRUE, but it will not be equal to 1.

EXSYS will warn you if you use a boolean result as a numeric value.Even though it is allowable to use a boolean value where a numericvalue is expected, it is unusual—so unusual in practice that youprobably have made an error.

For example:66<[X]<99

does not test if [X] is between 66 and 99. Instead, it tests the booleanresult of:

66<[X]

C - RULE EDITOR 55

Page 114: Manual Exsys

which will be true or false, (1 or 0) either of which is less than 99.Therefore, this example is always TRUE.

What should have been entered is:

66<[X] and [X]<99

Another example which generates two warnings is:

[X] = 32 or 64 or 91

This example does not test if [X] is an element of the set [32, 64, 91].Instead it tests:

[X] = 32 or TRUE or TRUE

which is always equivalent to TRUE. What you should have enteredwas:

[X]=32 or [X]=64 or [X]=91

If you receive an error about using a boolean as a numeric, or visa-versa, carefully check the expression for a mistake similar to onelisted above.

C15.11: ANSI Standard Order of PriorityThe expression evaluator follows the ANSI standard for precedenceand associativity of operators.

The following are the Operators supported in EXSYS, arranged inorder of precedence:

OPERATOR Associativity

(), unary+, unary-, NOT right to left^ left to right%,/,* left to right+,- left to right<>,<,>,<=,>=, ==, !=, +, ~= left to rightAND left to rightOR left to right?: right to left

If you are not sure how an expression will be evaluated, addparenthesis to make it unambiguous.

C - RULE EDITOR 56

Page 115: Manual Exsys

C15.12: Conditional Tests

The conditional tests supported are:

= test for equality== test for equality< less than> greater than<= less than or equal>= greater than or equal!= not equal~= approximately equal

C15.13: Approximately Equal Operator

EXSYS maintains all numeric variables as double-precision floating-point numbers. When operations are performed on floating-pointnumbers, round off may lead to loss of accuracy in the leastsignificant digit. Normally this is not a problem, but if an integer isexpected, the round off can cause problems, especially incomparisons. For example, a calculation is supposed to give ananswer of 2, but due to round-off, it gives 1.9999999999. If it iscompared with 2, the answer is false because the value is not equal to2. However, the value would be 2 if it had not been rounded off. Toavoid this problem, the approximately equal operator: ~= is available.

[X] ~= [Y] is TRUE if the difference between [X] and [Y]is less than 0.1% of [X].

([X] - [Y]) / [X] < .001

If [X] values is equal to 0, this would produce a division-by-0 error.If [X] and [Y] are very small, [X] ~= [Y] will be TRUE if bothvalues are within .000001 of 0.

C15.14: Syntax Checking

The EXSYS expression evaluator provides extensive syntax checkingwhen a formula is entered in the editor and when it is run. Manytypes of errors are detected. The syntax check allows detection andcorrection of many errors when rules are being entered, rather thanwhen they are run.

C - RULE EDITOR 57

Page 116: Manual Exsys

If a formula contains embedded variables (variables in double squarebrackets, [[]], that will be replaced by their values before the formulais evaluated), the text of the formula is not known until Runtime, andwill not be checked for syntax when it is entered . At Runtime, thedouble square bracket expressions will be replaced with their valuesand the expression's syntax will be checked. If a syntax error isfound, it will be reported then.

The syntax checker evaluates constant expressions and would notallow ([X]/(1-1)) because the program would determine that theexpression would be a division-by-zero error.

C15.15: Conditional Operator

EXSYS supports a conditional operator similar to the one in the Cprogramming language. This operator allows a conditional test to beused when assigning a value, independent of the conditional tests inthe IF part of a rule. This can reduce the number of rules andsimplify some problems.

The syntax for the conditional operator is:

<boolean expression> ? <expression 1>: <expression 2>

The expression evaluates to a single value that can be used with othervalues or assigned. If the boolean expression is true, the firstexpression will be used. If the boolean expression is false, the secondexpression is used. For example:

([X] > 0) ? 5 : 10

will evaluate to 5 if [X] is greater than 0 or evaluate to 10 if [X] isless than or equal to 0. The expression evaluates to a single value,the value is not assigned to any variable in the boolean testexpression.

To use this form for assignment, use a form such as:

[Y] IS GIVEN THE VALUE ([X] > 0) ? 5 : 10

where the value assigned to [Y] will be 5 or 10, based on the value of[X].

The conditional operator can be used with other expressions in tests:

[Z] < (([X] > 0) ? ([X] + [Y]) : ([Y]/[X]))

which tests if [X] is greater than 0. If it is, the test [Z] < [X]+[Y] ismade. If it is not, the test [Z] < ([Y]/[X]) is made.

C - RULE EDITOR 58

Page 117: Manual Exsys

The conditional operator is very useful and can reduce the number ofrules in some cases The two rules:

IFQualifier 1 is true

AND [X] > 10THEN

[Y] IS GIVEN THE VALUE [X] + 5

IF Qualifier 1 is true

AND [X] <= 10THEN

[Y] IS GIVEN THE VALUE 100

Could be replaced with:

IF Qualifier 1 is true

THEN [Y] IS GIVEN THE VALUE

[X]>10?([X]+5):100

The conditional operator can also be used in cases where data couldlead to a division-by-zero error. For example:

[Y] IS GIVEN THE VALUE([X] < > 0) ? (100/[X]) : 10000000

where [Y] is normally given 100/[X], but if [X] is equal to zero,instead of getting an error message, [Y] is assigned a large value,10000000.

C15.16: Functions

The following functions are supported.

SIN( ) Sine in radiansCOS( ) Cosine in radiansTAN( ) Tangent in radiansASIN( ) Arc sine in radiansACOS( ) Arc cosine in radiansATAN( ) Arc tangent in radiansEXP( ) Exponential function base eLOG( ) Log base eLOG10( ) Log base 10ABS( ) Absolute value

C - RULE EDITOR 59

Page 118: Manual Exsys

SQRT( ) Square rootINT( ) Integer part (rounded down)MIN( ) MinimumMAX( ) MaximumTOPREC( ) Number of records in a dBase fileQCHK( ) Qualifier statusAGE( ) Time since value was set

The functions evaluate the expression in parentheses and perform theappropriate function on the result. The parenthetical expression mustimmediately follow the function name without a space in between.

C - RULE EDITOR 60

Page 119: Manual Exsys

C15.17: Special Functions

The following special functions are also available:

QCHK(<qual #>, <value#>)or

QCHK("qual name", <value #>)

This function returns 1, TRUE, if the value <value #> is set forthe qualifier specified by name or number. If the name form isused, the name must be in quotation marks ( “ ”). This can beused as an alternative to qualifier conditions where booleanoperators need to be combined with qualifiers, or in testexpressions in the command language.

Examples:

QCHK(5, 1)Will return TRUE(1) if value 1 of qualifier 5 is set.

Otherwise, it will return FALSE(0).

QCHK("color", 3)Will return 1 if value 3 of the qualifier named "color" is set.Otherwise, it will return 0.

QCHK(2,2) or QCHK(4,3)Will return 1 if value 2 of qualifier 2 or value 3 of qualifier 4 is set. Otherwise, it will return 0.

MIN(x1, x2, x3 ...)Returns the argument with the minimum value.(The number of arguments is not limited.)

The MIN and MAX functions can be used in the customformula confidence mode for systems where the confidence ofa choice is the minimum (or maximum) of the confidences ofthe IF conditions.

Example:

MIN([X],[Y],[Z])Will return the value of either [X], [Y] or [Z], whichever is lowest.

C - RULE EDITOR 61

Page 120: Manual Exsys

MAX(x1, x2, x3 ...)Returns the argument with the maximum value.(The number of arguments is not limited.)

The MIN and MAX functions can be used in the customformula confidence mode for systems where the confidence ofa choice is the minimum (or maximum) of the confidences ofthe IF conditions.

Example:

MAX([X],[Y],[Z])Will return the value of either [X], [Y] or [Z], whichever is highest.

TOPREC("<filename>")Returns the number of records in the dBase III database filespecified by the filename. This is most often used in thecommand language.

Example:

TOPREC("price.dbf")Will return the number of records in the dBase file "price.dbf."

INSTR(STR1, STR2)Returns TRUE if STR1 is in STR2 or else it returns FALSE.

If TRUE, the value is NOT 1, it returns the string offset wherethe sub-string was found. If FALSE, it returns 0. The test iscase sensitive.

Examples:

INSTR("in", "incalculable") ==1INSTR("able", "incalculable") ==9INSTR("on", "incalculable") ==0

INSTR(STR, STR, BOOLEAN)Same as INSTR except it allows you to specify whether or notit is case sensitive. (If there is a third operator, EXSYS willautomatically use this form.)

Examples:

INSTR("in","INCACULABLE",TRUE) ==0INSTR("in","INCALCUABLE" ,FALSE) ==1

C - RULE EDITOR 62

Page 121: Manual Exsys

GETENV(string)The string is the name of an environment variable. Thisfunction returns the value of the environment variable as astring. This function must be used as a string.

Example:

GETENV("EXSYS")will return the string value of the environmentvariable EXSYS.

TOUPPER(string), TOLOWER(string)Converts the string to upper or lower case.

C - RULE EDITOR 63

Page 122: Manual Exsys

C15.18: AGE Function

The AGE function is a special function for systems that are handlingreal-time data. The function returns the number of seconds since avalue was set for a particular qualifier or variable. This is very usefulfor real-time systems automatically obtaining data on a changingprocess. The program can check on how old the data is and get newdata if necessary.

Syntax:AGE(Q#)AGE(Q "name")AGE(V#)AGE([var name])

Example:

IFAGE([X]) > 300

THENRUN(GETX)

If the variable [X] has not had its value set within 300 seconds, theprogram GETX would be called to get a value.

AGE can also be used in a command file:

ASK Q 1RULES "START*"IF (AGE(Q 1) > 60)

ASK Q 1RULES "END*"

Qualifier 1 will be asked. The rules with names beginning with"START" will be run. The program will make sure that it has notbeen more than 60 seconds since Qualifier 1 was asked. If it has beenmore than 60 seconds, Qualifier 1 will be asked again. The rules withnames beginning with "END" will then be run.

C - RULE EDITOR 64

Page 123: Manual Exsys

C16: Adding a Choice Condition

Choices are the possible solutions to the problem that the expertsystem will decide among. Choices are usually found in theTHEN/ELSE parts of the rule. Choices are the basis of all EXSYSexpert systems since they are results that are displayed to the enduser.

Using the flower color example, you might have choices that includeROSE, DAISY and VIOLET . We might want a rule that says if thecolor is red, the violet and daisy are eliminated and the rose is thelikely answer.

IFTHE COLOR OF THE FLOWER IS RED

THENROSE: Confidence= 8VIOLET: Confidence=0DAISY: Confidence= 0

By combining the confidence set by one or many rules, the finalconfidence values for the various choices are set. These choices arethen displayed as the results of the expert system.

To add a choice, click the Choice button in the rule window.

C16.1: Choices in the THEN/ELSE Part

Usually choices are used in the THEN/ELSE part of a rule wherethey are assigned a value. Select a choice by clicking on a choice inthe list of choices.

C - RULE EDITOR 65

Page 124: Manual Exsys

Choices

O K

CHOICE LIST

Select Choice Find Find Again

Assign ValueEdit

Delete

New Ch.

Cancel

After selecting a choice, enter the confidence value that you wish toassign to the choice in the edit box. Depending on the ConfidenceSystem chosen at the start of the program, this is 0 or 1, 0-10, -100to 100, increment/decrement value or a custom formula. (If a customformula system is used, see Section C40 for more information.) Clickthe OK button and the text of the choice plus " - Confidence =" anda value will appear in the rule.

C16.2: Choices in the IF Part

Choices can be used in the IF part as well as the THEN or ELSEparts of rules. When a choice is used in the IF part, it is as a test ofthe choice's value in comparison to a fixed value or formula.

For example, you might want to know if the final value of the choice"ROSE" received a value greater than 7. In the rule, this conditionwould be written as "ROSE: Conf > 7". When the rule is tested,the value of the choice ROSE will be evaluated and then used todetermine if the condition is true or false.

If the value of the choice passes the test, the condition is consideredtrue. When a rule with a choice is tested in a backward chainingexpert system, the final value of the choice will be evaluated beforethe rule is determined to be TRUE or FALSE.

C - RULE EDITOR 66

Page 125: Manual Exsys

Choices

O K

CHOICE LIST

Select Choice Find Find Again

Test Type: = > >= < <= !=

Test Value:Edit

Delete

New Ch.

Cancel

Select a choice by clicking on a choice in the list of choices. Thenselect a test expression by clicking on the appropriate radio button inthe Test Type section. The tests available are: <, >, =, <=, >=, or <>. Then enter the comparison value to test against. The programasks for the value with which to compare the choice's final score.This information is input as an integer. Then click the OK buttonand the full text of the condition will appear as part of the rule. (Ifyou are using the custom formula mode, see Section C40 for specialinstructions on the comparison tests.)

If the system finds no way to determine the value of a choice used ina rule's IF part, an error message is displayed when running theexpert system. This can happen if no valid rules assign a value to thechoice. This mode can be changed with system configurationoptions.

C16.3: Adding a New Choice

To add a choice, click the Add Ch button. A window will bedisplayed where the text of the new choice can be entered. Enter thetext for the new choice and click the OK button. The new choicewill be added to the Choice list and automatically selected as thechoice to use for the condition.

C - RULE EDITOR 67

Page 126: Manual Exsys

C16.4: Deleting a Choice

To delete a choice, select a choice and click on the Delete button. Ifthe choice is not in use, it will be deleted. If the choice is in use, a listof the rules using the choice will be displayed. These rules must beedited to remove the choice before it can be deleted from the system.

C16.5: Editing a Choice

To edit a choice, select a choice by clicking it and then click the Editbutton. The Choice editing window will be displayed with the textavailable for editing. You will then be able to edit the text for thechoice. When you are finished editing your choice, click the OKbutton.

C - RULE EDITOR 68

Page 127: Manual Exsys

C17: Adding a Command Condition

To add a command condition, click the Command button. Awindow will appear giving the options for adding commands. Theseare discussed in Chapter G on Data Acquisition Commands.

C - RULE EDITOR 69

Page 128: Manual Exsys

C18: To Copy or Move a Condition

File Edit Options KBfiles Questions

Condition CutCondition CopyCondition Paste

Rule

1. Highlight a condition in a rule by clicking it.

2. On the menu line, pull down the Rule menu and selectCondition Cut or Condition Copy. (Both of thesecommands copy the condition into a buffer, but Cut alsodeletes the condition.)

3. Select another rule, or another part of the same rule inInsert mode.

4. On the menu line, pull down the Rule menu and selectCondition Paste.

5. If possible, the selected condition will be added to the rule inthe same place as if it were a new condition. Someoperations are logically impossible, for example in theTHEN part, choices are assigned values, while in the IF parttheir value is tested. It would not make sense to move aTHEN syntax choice condition to the IF part. EXSYS willcheck for such errors and will not allow you to performsuch operations. If a condition is copied or cut from the IFpart of a rule, it can only be pasted into the IF part ofanother rule. If a condition is copied or cut from the THENor ELSE part of a rule, it can only be copied to the THENor ELSE part of another rule.

C - RULE EDITOR 70

Page 129: Manual Exsys

Note: To move conditions, use theCondition Cut, Condition Copy andCondition Paste commands. Thestandard Cut, Copy and Pastecommands under the Edit menu are usedin some places in EXSYS to move text,but they can not be used to move ruleconditions. To the developer, conditionsappear as text, but internally they are farmore complex structures. Only theCondition Cut, Condition Copy andCondition Paste commands perform all ofthe required operations and checks.

C - RULE EDITOR 71

Page 130: Manual Exsys

C19: To Delete a Condition

1. Highlight a condition by clicking it.

2. Click the Delete button

C20: To Change a Condition

1. Highlight a condition by clicking it.

2. Click the Change button.

3. You will be presented with the window for adding acondition of the same type (qualifier, variable or choice) asthe selected condition. The new condition will replace theselected condition.

C21: To Scroll to the Previous or Next rule

Press the Prev or Next button. If there were any changesmade to the rule, you will be asked if you wish to save thesechanges before scrolling.

C22: To Add / Edit the Note, Reference and Name

Each rule can have an associated Note, Reference and Name.

C22.1: Note

The note can supply some additional information to the user. Thenote has no effect on the program and is used only to provideinformation to the end user. Whenever the rule is displayed, the notewill also be displayed.

C - RULE EDITOR 72

Page 131: Manual Exsys

The notes associated with rules that fired can be easily incorporated ina report using the report generator command NOTE. This can createa text explanation of how the system reached its conclusions.

To add a note, click the Note box. A edit box will be displayed withthe existing note if there is one. Make any changes and click OK. Ifthere is NOTE text, the Note box will be checked.

C22.2: Reference

A reference can also be associated with a rule. This, like the note, isoptional. The reference usually contains the source of the knowledgerepresented in the rule. If users question the rule, they can refer tothe reference. The reference, like the note, may also be used toprovide more information to the user. Unlike the note, the referenceis displayed only when the user requests it.

References from rules which fired can also be incorporated in areport using the REFERENCE command.

To add a reference, click the Reference box. An edit box will bedisplayed with the existing reference, if there is one. Make anychanges that you think are necessary, then click OK. If there isreference text, the Reference box will be checked.

C22.3: Name

A name can also be associated with a rule. The name is optional, butis very useful when referencing the rule from the command languageor report generator.

Names allow the knowledge base to be divided into sections when itis run or referenced. Names also allow rules to be moved with theknowledge base without affecting numeric referencing from thecommand language or report generator. For example, the commandlanguage command RULES 1-20 will run the rules numbered 1 to20. However, if the rules are moved or another rule is added, theCommand Language command would have to be corrected. If,instead, each of the relevant rules had a name that started with theletter 'A', we could just use the Command Language commandRULES “A*.” This would run all rules that have names that startwith 'A'. This is not affected by position or re-numbering.

Rule names are also useful when editing rules since the rule editselection dialog box displays all the rules by name as well as number.Adding a meaningful name can make the rule much easier to findlater.

C - RULE EDITOR 73

Page 132: Manual Exsys

To add a name, click the Name box. An edit box will be displayedwith the existing name, if there is one. Make any changes that youthink are necessary, then click OK. If there is name text, the Namebox will be checked.

C - RULE EDITOR 74

Page 133: Manual Exsys

C23: To Repeat a Condition from the Previous RuleHaving the same first few conditions at the start of several rules isoften quite useful. This enables a false condition to rapidly eliminatelarge blocks of rules so the user is not asked unnecessary questions.To repeat a condition from the numerically previous rule, click theRepeat button. The Editor copies the condition that was used in theprevious rule. If Repeat is selected as the first entry, theprogram/editor copies condition 1 from the numerically previous rule.If the first condition is input by number and then Repeat is clicked,the editor copies the second condition of the previous rule. If theprevious rule does not have enough conditions to match, EXSYS letsyou know this. If you want to copy something from some sourceother than the numerically previous rule, use the cut and pastcondition commands.

C - RULE EDITOR 75

Page 134: Manual Exsys

C24: Consistency Checking of New RulesWhen a new rule is entered in the system, it is automatically checkedfor consistency with the existing rules. This is done by the system,assuming that the new rule's IF and THEN parts are true. It thenchecks to see what other rules would also be true based on this data.Due to the complexities of simultaneous conditional math expressions,all mathematical expressions are ignored during this check. Theprogram displays any rules it finds and asks if the new rule should bechanged. The fact that other rules are found is not necessarily anerror—the Editor is merely ensuring that the developer is aware ofthem.

For example, the new rule is:

IF

THE COLOR OF THE FLOWER IS RED

THEN

CHOICE 1: Probability = 3/10

If, in checking the existing rules, the program found another rulethat said

IF

THE COLOR OF THE FLOWER IS RED

THEN

CHOICE 4: Probability = 6/10

the program would display the rule, since clearly if the new rule weretrue, this rule would also be true.

Likewise, if the program found the rule:

IF

THE COLOR OF THE FLOWER IS NOT BLUE

THEN

CHOICE 6 : Probability = 0/10

C - RULE EDITOR 76

Page 135: Manual Exsys

it would also display the rule, since the IF condition in the new ruleimplies that the IF condition in this rule would be true. Whenchecking rules, the program does not consider the effect of having anIF condition false to add ELSE conditions.

When possibly conflicting rules are found, the program will be displaya list of the possibly conflicting rules:

If Rule 75 were true,the listed rules couldalso apply

272334

Accept New Rule

Edit / Examine Rule

Clicking Accept New Rule will add the new rule to the knowledgebase. Selecting a rule from the list and clicking Edit / Examine Rulewill display the selected rule. Both the new rule and the selected rulewill be displayed for editing.

Switching Off Rule CheckingThe program supplies the option of switching off the rule-checkingfunction. Checking can be canceled by selecting the Parametersitem from the Options menu, and checking the No button marked“Check New Rules for Consistency.” Turning rule checking off is agood idea when mathematical expressions are used because the rulechecker does not check the validity of those expressions.

C - RULE EDITOR 77

Page 136: Manual Exsys

For example:

IF THIS IS VALUE 1

AND [X] < 20THEN

CHOICE 1 : Probability = 3/10

The rule checker might display the following rule, that had alreadybeen entered, as also possibly true:

IF THIS IS VALUE 1

AND [X] > 20THEN

CHOICE 2 : Probability 5/10

This program will not recognize that [X] <20 and [X]>20 cannotboth be true. Mathematical expressions are ignored when checkingrules for consistency. This approach was used because, for complexequations, determining if two or more equations can besimultaneously true is difficult, especially when variables are involved.

C - RULE EDITOR 78

Page 137: Manual Exsys

C25: Deleting a Rule

File Edit Options KBfiles Questions

Add RuleEdit Rule

Move Rule

Use Rule Names

Qualifier ListVariable ListChoice List

Condition CutCondition CopyCondition Paste

Rule

Delete Rule

To delete a rule, go to the main menu bar and pull down the Rulemenu. Select Delete Rule. A window will be displayed, allowingyou to select the rule to delete either by name or number. Select arule and click the OK button. The rule you have selected will bedisplayed along with a window asking you to confirm that this rule isto be deleted. If you click YES, the rule will be deleted and all otherrules will be re-numbered accordingly. Any rule windows open forediting will also be re-numbered.

C - RULE EDITOR 79

Page 138: Manual Exsys

C26: Moving a Block of Rules

File Edit Options KBfiles Questions

Add RuleEdit RuleDelete Rule

Use Rule Names

Qualifier ListVariable ListChoice List

Condition CutCondition CopyCondition Paste

Rule

Move Rule

Rules are tested in the order that they occur. Forward chainingsystems are particularly sensitive to rule order, but even backwardchaining systems will test the rules in order. Sometimes you maywant to move a block of rules to a particular place in the system.

To move a block of rules, go to the main menu bar and pull downthe Rule menu. Select Move Rule. A window will be displayed,allowing you to select the block of rules and destination either byname or number.

C - RULE EDITOR 80

Page 139: Manual Exsys

Name: Number:

12345678

O K

Last

Move from rule:

to Rule:

Before rule: To end

Cancel

aaabbbcccccdddd

To select the start of the block, click Move from rule and select arule. To select the end of the block, click to Rule and select a rule.To select the destination for the rules, click Before rule and select arule. To move the block to the end of the rule list, click the To endbutton. When you click on the OK button, the block of rules will bemoved and all rules will be re-numbered accordingly. Any rulewindows open for editing will also be re-numbered if necessary.

C - RULE EDITOR 81

Page 140: Manual Exsys

C27: Printing a Knowledge Base

Edit Rule Options KBfiles Questions

NewOpenSaveSave AsRevert to Saved

ExitAbout

File

Print

Selecting Print from the File menu allows you to print theknowledge base to a disk file or to a printer, in several differentforms.

Print to PRINTER

Print to FILE

Standard Output Format

Rule Compiler Format

C Code Replacement for Rules

Rules

Qualifiers / Variables

Cross Reference List

Formulas

One Per Page

Continuous

O K

CancelSmall Font

Having a print-out of the rules, qualifiers, variables, and choices issometimes useful while developing an expert system. Printing in therule compiler or C code formats allows special editing operations orembedding of the rules.

C - RULE EDITOR 82

Page 141: Manual Exsys

To send something to a printer or file, click the Print to Printer orPrint to File button. Normally, only the Standard Output Formatwould be sent to a printer. If a file is selected, enter the name of thefile.

Important Note : When selecting afilename, do not give it the same name asone of the existing expert system filenamesor the expert system will be destroyed.

Select a format for the output.

The Standard Output Format is a readable form withoutany special syntactical characters. In the Standard Outputformat, you can select which parts of the knowledge base youwish to print.

The Rule Compiler Format adds the special syntacticalcontrol characters and format needed by the EXSYS RuleCompiler. Text in this format can be edited with a text editorand then recompiled using the Rule Compiler. (See Chapter Kfor more information on the Rule Compiler.) If this format ischosen, the output should be sent to a disk file.

The C Code Format outputs a C Code replacement for therules which can be used with EXSYS Linkable Object modulesto embed the rules in a single executable file. The C Code isonly useful when used with EXSYS Linkable. If this format ischosen, the output should be to a disk file.

The Small Font box should be selected to print the rules to a printerusing a small font. The default font is too large on some printers anda smaller font may work better for your needs. However, be awarethat not all printers support a small font.

C - RULE EDITOR 83

Page 142: Manual Exsys

C28: Displaying the Qualifiers, Variables or Choices

File Edit Options KBfiles Questions

Qualifier ListVariable ListChoice List

Rule

To display the list of qualifiers, go to the main menu bar and pulldown the Rule menu. Select Qualifier List. The qualifier windowwill be displayed. This is the same window as adding a qualifiercondition to a rule. Once a qualifier is selected, it can be edited byclicking the Edit button or it can be deleted by clicking the Deletebutton. A new qualifier can be added to the list by pressing the NewQual button. The new qualifier window is the same as adding a newqualifier during the editing of a rule.

To display the list of variables, go to the main menu bar and pulldown the Rule menu. Select Variable List. A window will bedisplayed, allowing you to select a variable. This is the same asselecting a variable when adding a math condition to a rule. All theoptions for editing the variable are active.

To display the list of choices, go to the main menu bar and pull downthe Rule menu. Select Choice List. A window will be displayed,allowing you to select a choice. This is the same as selecting a choicecondition to a rule. All the options for editing the choices are active.

C - RULE EDITOR 84

Page 143: Manual Exsys

C29: Running the Rules

File Edit Rule KBfiles Questions

Cancel Run

Parameters

ValidationExamine Tree Diagram

Notebook

Help

Options

Run

To run the rules, go to the main menu and pull down Options.Select Run.

The rules will run as if they were being run from the Runtime. (SeeChapter D on the Runtime for details.)

C - RULE EDITOR 85

Page 144: Manual Exsys

C30: Canceling a Run

File Edit Rule KBfiles Questions

Run

Parameters

ValidationExamine Tree Diagram

Notebook

Help

Options

Cancel Run

To return to the Edit mode during a run, select Cancel Run fromthe Options menu. The run will be terminated and EXSYS willreturn to the edit mode.

C - RULE EDITOR 86

Page 145: Manual Exsys

C31: Changing the Knowledge Base Parameters

File Edit Rule KBfiles Questions

RunCancel Run

ValidationExamine Tree Diagram

Notebook

Help

Options

Parameters

To Change the general parameters of the knowledge base (ruledisplay, derivation mode, starting and ending text, etc.), selectParameters from the Options menu. The same window as seen atthe start of a new knowledge base will be displayed. Some itemswhich can only be set at the creation of a new knowledge base(Confidence mode) will be disabled. Make any desired changes andclick the OK button.

C - RULE EDITOR 87

Page 146: Manual Exsys

C32: Automatic Validation / Tree Diagrams

File Edit Rule KBfiles Questions

RunCancel Run

Parameters

Examine Tree Diagram

Notebook

Help

Options

Validation

C32.1: Introduction

Validating an expert system should be a major part of any expertsystem development project. It is important to make sure that endusers will receive valid answers to any input. The EXSYS automaticvalidation function greatly simplifies and automates this process.

EXSYS supports two methods of validation testing—systematic andrandom. Systematic testing allows all possible combinations of inputto be tested for a variety of possible errors. If the expert system islarge, and systematic testing the entire system would take too long,systematic testing of portions of the system or random testing of theentire system can be performed.

Three files are produced—two types of tree diagrams, and an errorreport file. The tree diagram shows all the possible combinations ofinput and the resulting output of the system. Regardless of thecomplexity of the logic of the system, the input and output canalways be diagrammed as a tree. The trees can be examined with aspecial display routine in EXSYS that enables you to scroll throughthe tree diagram. The nodes on the diagram are written in anabbreviated form (something like, “Q3:2” which represents qualifiernumber 3 value 2). When the tree diagram is displayed, clicking thenode expands the abbreviated form to the full text form of thequalifier or variable.

The two types of tree diagrams produced are linear and branchedtree diagrams. These two diagrams are equivalent in information

C - RULE EDITOR 88

Page 147: Manual Exsys

content, but are diagrammed differently. The branched tree diagramgraphically shows the branching in the system. For example:

Q7:1

Q7:2

[X]:30

[X]:35

[X]:40

Q4:1 >>> C3:7 C2:1Q4:2 >>> C3:5Q4:3 >>> C1:2 C4:8

Q4:1 >>> ERROR: Q6 could not be derivedQ4:2 >>> C5:7Q4:3 >>> C6:6

Q9:2 Q11:1 >>>C4:6Q11:2 >>>ERROR: Variable out ofQ11:3 >>>C5:2Q11:4 >>>C5:7

Q11:1 >>>Error: No choices setQ11:2 >>>ERROR: Q4 loop errorQ11:3 >>> C6:3 C5:1Q11:4 >>> C3:4

A branched tree diagram is convenient for seeing the overallstructure, but if a particular set of input produces an error, it maytake some scrolling to read all the information on the input. In alinear tree diagram, all the node values for a branch are displayed ona single line. If you took the same information from the abovediagram and assembled it into a linear tree diagram, it would bedisplayed as:

Q7:1 - [X]:30 - Q4:1 >>>C3:7 C2:1Q7:1 - [X]:30 - Q4:2 >>>C3:5Q7:1 - [X]:30 - Q4:3 >>>C1:2 C4:8Q7:1 - [X]:35 - Q4:1 >>>ERROR:Q6 could not be derivedQ7:1 - [X]:35 - Q4:2 >>>C5:7Q7:1 - [X]:35 - Q4:3 >>>C6:6Q7:1 - [X]:40 - Q11:1 >>>C4:6Q7:1 - [X]:40 - Q11:2 >>>ERROR: Variable out of ..Q7:1 - [X]:40 - Q11:3 >>>C5:2Q7:1 - [X]:40 - Q11:4 >>>C5:7

In the linear tree, it is easier to follow the data that lead to theconclusion, especially in large trees. However, it is not as easy to seethe overall structure. When random testing is selected, only a lineardiagram will be created. Due to the random nature of the testing, thedata will not be tree structured.

The error file contains reports of any detected errors and the inputwhich produced the error. In the random mode, only the error file isproduced.

C - RULE EDITOR 89

Page 148: Manual Exsys

The validation function will detect and report combinations of inputthat

1. Produced no conclusions.

2. Failed to derive needed qualifiers or variables that should bederived.

3. Created loop errors.

4. Assigned a variable a value which is outside of the limitsspecified for the variable.

5. Assigned more values to a qualifier than the maximumnumber allowed for that qualifier.

6. Special custom tests designed with the report generator.

Only the combinations of input that might actually be supplied by anend user are considered. This usually reduces the number of teststhat must be run to much less than the total number of possiblecombinations of data.

C32.2: Running in Validation Mode

To build the validation file, select Validation from the Optionsmenu.

Validation Test Mode: System.

Random

Cancel

A menu is displayed. Select either:

1. Test the system systematically

2. Test the system randomly

C - RULE EDITOR 90

Page 149: Manual Exsys

A systematic test will consider all possible combinations of inputwithin the ranges specified. This is the best type of validation,however the size of the file may get large very quickly. If thenumber of combinations becomes impractically large, limit the scopeof the systematic test or use random testing. Random testing willconsider random sets of input. This may not cover all possible input,but for large systems or systems with many numeric variables, it willallow testing of many possible inputs.

C32.3: Setting the Test Parameters

Both systematic and random test modes are initialized in a similarmanner. Parameters are defined for each qualifier and variable onranges of values to use, which elements should be derived and whatvalues should be locked. These parameters can be saved to disk forfuture use.

If either systematic or random testing is selected, a list of all of thequalifiers in the system will be displayed. Qualifiers can be handled inone of three possible ways during the validation testing:

1. Values will be set automatically, and all possible qualifiervalues will be used. When a value is needed for the qualifier,the validation function will automatically provide a value fromthe list of possible values. This value will be used for thesubsequent processing of the rules.

2. Values will be set automatically, but only one value, or afew values, from the list are to be used. When data on thequalifier is needed, the validation system will automaticallysupply a value, but the selected value will be restricted to onlyspecified values, rather than considering all possible values forthe qualifier. Limiting the number of values limits the scope ofthe test, while still allowing systematic testing of other parts ofthe system. For large systems, locking a few key qualifiers tosingle values can greatly reduce the time required to test partof the system.

3. Values will be derived from rules. A value must be derivedby the rules in the system, or an error will result. This is usedto mark the qualifiers which should be derived (never asked)from other data. The system will not automatically assignvalues to these qualifiers. This option should be used forqualifiers that are not supposed to be asked of the end user. Ifdata on the qualifier can not be derived, and the qualifier isneeded in the execution of the rules, it will result in an errormessage in the error file.

C - RULE EDITOR 91

Page 150: Manual Exsys

Select qualifier by text or name: Find Find Again Name

List of Qualifiers

List of Qualifier Values

O K

Derive

All Values

Limited Test

Set ALL Qual. to ALL Values

Save to File

Read from File Cancel

Each of the qualifiers in the list will be preceded by a 'D'. Thisindicates that the qualifier should be derived from other data in thesystem. Failure to derive a value would be considered an error. Allof the qualifiers that are intended to be asked of the end user (andassigned values by the validation function) must be marked.

If a qualifier is not to be derived, the test can include all or only someof the qualifiers values. Limiting the number of tested values willreduce the time to perform the test.

To mark all qualifiers to use all values, click the Set ALL Qual toALL values button. All of the qualifiers will now be preceded by an'A', indicating that all their values are to be used.

Individual qualifiers can be set by selecting the qualifier in theQualifier list. The values associated with the qualifier will be displayedin the Values list window. The current state of the qualifier will beindicated.

To mark the qualifier to be derived, select the qualifier and click theDerive button.

To mark the qualifier to use all values, select the qualifier and clickthe All Values button.

To mark the qualifier to use only some values, select the qualifier andclick the individual values to be used. The Limited Test button willautomatically be selected.

C - RULE EDITOR 92

Page 151: Manual Exsys

To save the parameters set to a file, click the Save to File button.You will be asked for the name of the file in which you wish to savedata. This is useful when there is a complex set of parameters for thequalifiers.

To read the parameters back from a file, click the Read from Filebutton. You will be asked to select the file containing the parameterdata. If the knowledge base has been modified since the data wassaved, EXSYS will notify of this. The parameter data will be readback from the file and displayed in the window for additional editing.

When the parameters are set correctly, click the OK button.

After the qualifiers are set, the variables must also be set.

Variable List Derive

Single Value

Range of Values

Numeric

String

Text Only

Lower:

Upper:

Step:

Save to File Read from File

Return to Qualifiers

Cancel

O KText of variable

At the start, each of the variables will be preceded by a 'D', indicatingthat they must be derived. To have EXSYS automatically test eachof the variables, it must be marked to have a single value or a rangeof values. If it has a single value, only that value will be used.

In the systematic validation case, the program will ask for an upperand lower bounds and an increment. The validation test willautomatically consider variable values from the lower bound to theupper bound by increasing the value by the specified increment. This

C - RULE EDITOR 93

Page 152: Manual Exsys

data will be combined with the selected qualifiers, so be careful whenyou choose an increment. If there are 10 increments between thelower and upper bounds, it will take 10 test cases every time thevariable is tested. If there are multiple variables, the number ofpossible test cases can get quite large. Therefore, it is better to usethe Random testing mode with multiple variables. For randomvalidation, the program will only ask for upper and lower bounds.The value will be randomly chosen at any point between thesebounds—not on specific increments.

Select a variable by clicking on it. The text of the variable will bedisplayed at the bottom of the window.

To mark the variable to be derived, select the variable and click onthe Derive button.

To mark the variable to be given only a single value, select thevariable and click on the Single Value button. You will then beasked for the value you want to use.

To test the variable over a range of values, select the variable andclick the Range of Values button. You will then be asked for thelower, upper, and (if systematic testing) the incremental step.

The type of variable is indicated by the Numeric, String and TextOnly buttons. You can not change the type of variables, this in onlyfor your information. Text- only variables can only be derived. Thisis because they can only be used in the THEN/ELSE part of rulesand will never be asked anyway. String variables can only bederived, or given a single value.

To save the parameters set (plus the parameters set for the qualifiers)to a file, click the Save to File button. You will be asked for thename of the file in which you want to save the data.

To read parameters saved to a file, click the Read from File button.You will be asked to select the file to read. Remember, the file readmay also set the qualifier parameters to new values.

To return to edit the qualifier parameters, click the Return toQualifiers button.

When the variable parameters are set correctly, click the OK button.

If random testing was selected, you will now be asked how manyrandom tests you wish to run.

EXSYS will now start the automatic validation process. A windowwill be displayed indicating that automatic validation is being used andgiving the option to cancel the test.

C - RULE EDITOR 94

Page 153: Manual Exsys

In the random mode, after the 5th test is run, the system will start tocalculate the approximate time to completion based on the averagetime spent on the tests run thus far. In the systematic mode, thenumber of the test will be displayed, but until the rules are actuallyrun, the system has no way to tell how many tests actually must berun. Because only possible combinations of input that might besupplied by a user are considered, the number of tests is usually farsmaller than the total number of possible combinations of data.

You can stop the run at any time by pressing a key and waiting forthe current record to finish. When the system finishes the tests, thediagram of the test results will be displayed.

RUNNING IN VALIDATE / TREE MODE: #

Stop Validation Tests

If you click on the Stop Validation Tests button before the tests arecompleted, you will cancel the remaining tests and be able to examineresults of the tests run to that point. If you let the test run tocompletion, you will be able to examine all the results.

C32.4: Validation Results

The validation tests will produce several files:

Error FileAll errors are written to the file name <knowledge base name>.ERR.It will show all cases where the input

1. Produced no conclusions

2. Failed to derive needed qualifiers or variables that should bederived

3. Created loop errors

4. Assigned a value to variable which is outside the limitsspecified for the variable.

5. Assigned more values to a qualifier than the maximumnumber allowed for that qualifier

C - RULE EDITOR 95

Page 154: Manual Exsys

The report includes the error and the data which produced the error.Since after detecting an error the system continues testing, the errorfile may contain multiple error reports.

Tree FilesIn addition to the error file, two tree files will be created. (Therandom mode produces only an error file and a linear file.) If you donot want the tree files created, and only want the error file, use theconfigure option ERROR_FILE_ONLY. Usually is only done if yoususpect your available disk space is insufficient for the tree files.

The file <knowledge base name>.TR1 will contain a list of all of thedata for all the runs. If the validation is systematic, the data will bearranged as a tree, but each line will contain all the input data. Insystematic test mode, a second file will be created, <knowledge basename>.TR2. This is a branched tree diagram showing the possibleuser input and resulting output. Both of these files are ASCII filesand can be examined or printed with a text editor. They can also beexamined with a special display routine in EXSYS.

In the random testing mode, the <knowledge base name>.TR1 filewill contain data and results from all the random test cases that wererun. The values are selected randomly, so they can not be convertedto a branched tree diagram.

The tree diagram shows how user input relates to the expert system'sresults. In a systematic test, all possible combinations of input will bediagrammed. If the tree is too large, you can reduce the scope of thetree by limiting some qualifiers to one, or a few, values.

For a systematic test, you will be asked if you wish to examine thebranched or linear tree diagram. For Random tests, only the lineardiagram is available.

Validation Tree to Examine:Branched

Cancel

Linear

If you select the Branched diagram, a window will be opened withthe tree diagram.

C - RULE EDITOR 96

Page 155: Manual Exsys

O K Click on a node or more informatio n

Q1:1 Q2:1 >>> C1:5

Q2:2 Q3:1 >>> Error: No Results

Q3:2 >>> C2:4

Q2:3 Q3:1 >>> C2:7

Q3:2 >>> C2:1

Q1:2 >>> Error: Variable 1 could not be derived

Q1:3 Q3:1 >>> C3:6

Q3:2 >>> C1:8

The tree diagram displays the structure of the knowledge base bydiagramming the input and output. Even very complex and non-treestructured systems can be diagrammed this way. The diagram uses ashortened notation for the qualifier and variable values. For exampleQ1:2 means the second value of qualifier 1. To see the full text of thequalifier and variable for the condition described at the node, click onthe node. A window will open with the full text of the qualifier,variable or choice.

The tree diagram can be resized using the resize control on thewindow. You can scroll horizontally or vertically in the window.

When you are finished examining the diagram, click the OK button.The information from the tree diagram is stored in the files

<knowledge base name>.TR1 - Linear diagram <knowledge base name>.TR2 - Tree Diagram <knowledge base name>.ERR - Error data and rule use

C32.5: Custom Reports

For customized reports, you can associate a report generatorcommand file with the expert system. This enables you to createreports of specific tests you wish to make. The optional reportgenerator file <knowledge base name>.OUT will be called at the endof each run automatically.

C - RULE EDITOR 97

Page 156: Manual Exsys

If a report generator file is used, be sure to use the /A option in theFILE command to append each record of data to the report file. Forexample suppose you wish to know all cases where two specificchoices are simultaneously given a high value. The following will listall cases of input which resulted in the value of choice 5 and choice 7both being greater than 8.

FILE CHK.RES /AC5 <=8 /G:endC7 <=8 /G:end"*******************************""Choices:"C" ""Input:"INPUT:endclose

If the value of choice 5 is less than or equal to 8, the /G option willcause it to go to the end of the report file. If choice 5 is greater than8, choice 7 will be tested. If choice 7 is less than or equal to 8, thereport file will also go to the end. If both values are greater than 8,the data output commands will be used and the choices and inputdata will be written to the file. This technique can be used toproduce customized tests that are systematically applied to all possiblecombinations of input.

C32.6: Validation Testing to Compare Versions of a Knowledge Base

The validation function allows systematic testing and also allowstesting of the effect of modification of the rules. At times, knowledgebases get modified in ways that are not supposed to effect the finalresults (as in the case of new modules or new external programs). Asystematic validation file can be created before and after a change.The resulting tree files can then be compared. They should beidentical if there were no changes in the results produced by thesystem. If there are differences, comparison of the result files willshow the input which lead to the different results.

C - RULE EDITOR 98

Page 157: Manual Exsys

C32.7: External Program Problems

The validation function is designed to run without any user input.However, EXSYS can only control interaction internal to EXSYS.Applications which call external programs that require userinteraction, or force user interaction through the command languagewill have to be modified before the validation testing can rununattended. To do this, make a copy of the expert system andremove the portions that force user interaction through RUN() orDISPLAY() commands or other external program calls. This is ofteneasiest to do with the rule compiler. Set the parameters for thequalifiers and variables that would be obtained from external sourcesto be automatically assigned, instead of asking the user.

If an external program does not require user interaction (such as oneswhich only process data or automatically obtain data) it can be usedin the automatic validation mode..

DATALIST should not be used to set data. Instead, remove thedatalist command and emulate the datalist by setting the validationparameters for the qualifiers and variables.

Command files can be used with the validation mode.

C - RULE EDITOR 99

Page 158: Manual Exsys

C33: Examining Existing Tree Diagram Files

File Edit Rule KBfiles Questions

RunCancel Run

Parameters

Validation

Notebook

Help

Options

Examine Tree Diagram

To examine an existing tree or linear diagram file, select ExamineTree Diagram from the Options menu. You will be asked whichtype of diagram you want to examine. The diagram will bedisplayed in the same way as it is after a validation test run.

C - RULE EDITOR 100

Page 159: Manual Exsys

C34: Notebook

File Edit Rule KBfiles Questions

RunCancel Run

Parameters

ValidationExamine Tree Diagram

Help

Options

Notebook

EXSYS maintains a system notebook file for each expert system.Notes can be added in this file by the developer or end user onvarious aspects of the system. This can be a way to get end userfeed-back on a fielded system, or suggestions for enhancements. Thefile is named <knowledge base name>.NBK.

To make a note in the knowledge base notebook file, go to the mainmenu and pull down Options and select Notebook. You will havethe option to Write, Read or change the notebook file name.

Notebook Option

Notebook Functions:

Write to Notebook

Read from Notebook

Change Notebook FileCANCEL

WRITE

READ

Notebook File:

To write, click Write and enter the note that you want to add. Thetext you enter will be added to the notebook and then will be datestamped with the current date and time. To read, click Read andthe notebook file will be displayed.

To change the name of the notebook file to be used, edit the filename displayed at the bottom of the window.

C - RULE EDITOR 101

Page 160: Manual Exsys

C35: Asking for Help

File Edit Rule KBfiles Questions

RunCancel Run

Parameters

ValidationExamine Tree Diagram

Notebook

Options

Help

To display the system help windows, select Help from the OptionsMenu. This is the same help system described previously.

C - RULE EDITOR 102

Page 161: Manual Exsys

C36: Editing the Knowledge Base Text Files

File Edit Rule Options Questions

ConfigureCommandReportScreenHelp

Other

KBfiles

In addition to the .rul and .txt files created by the EXSYS RuleEditor, there are also several associated files which can be created andedited with a text editor. To make it easy to modify these files fromwithin EXSYS, a small text editor is available.

The details of commands available in each of these files is discussed inthe appropriate section of this manual. Select the file to edit, and anedit window will appear, allowing you to enter or edit the text. IfOther is selected, you will be asked for the name of the file to edit.

C - RULE EDITOR 103

Page 162: Manual Exsys

C37: The Questions Menu

File Edit Rule Options KBfiles

Known DataWhy?Display RuleDisplay Choices

Explain Question

Undo Prev. Answer

Save InputRecover Input

Trace Window

Questions

Almost all the items in the Questions menu are identical to those inthe Questions menu of the Runtime program, and are discussed inChapter D on the Runtime. The one exception is the Trace Windowselection which is only found in the Editor.

C - RULE EDITOR 104

Page 163: Manual Exsys

C38: Trace the History of the Run

File Edit Rule Options KBfiles

Known DataWhy?Display RuleDisplay Choices

Explain Question

Undo Prev. Answer

Save InputRecover Input

Questions

Trace Window

When developing an expert system, it is often useful to trace whatrules are firing, where variables are being set, and a variety of otheractions. This is especially true when tracking down a bug in the rules.

There are two ways to create a history of a run. The first is to usethe configure option TRACE=file. This will create a history of therun in the file specified. The use of TRACE= is covered in Chapter Eon Configure Options. The second way is to create a trace window.This is done by selecting Trace Window from the Questions menu.A trace window will be created. All user or external program inputwill be written to the window. Also, as each rule fires and adds datato the system, the information will be added to the window.

C - RULE EDITOR 105

Page 164: Manual Exsys

O K Find Find Again

Trace Text

As the expert system executes, a history of the execution will bewritten to the trace window. The trace window can be brought tothe front at any time by clicking in it. To check on a specific dataitem, click the Find button. Enter the name of the data item thatyou want to find and the trace window will scroll to the item. Clickthe Find Again button to see the next occurrence of the item in thefile. To scroll the text in the window, use the scroll bar. When youare finished with the trace window, click the OK button.

C - RULE EDITOR 106

Page 165: Manual Exsys

C39: Hypertext

EXSYS supports hypertext to provide information on key wordsused in the expert system. To designate a word as a hypertext keyword, it is preceded and followed by ^^. For example, to makeEXSYS a hypertext keyword, it would be entered as ^^EXSYS^^.This makes it easy to add hypertext help to an expert system.Virtually all windows in EXSYS support hypertext during therunning of the system, including the screens to ask for qualifiers orvariables, display results, display known data or rules, and otheractions. Hypertext is not supported in the edit mode. In the GUIversions of EXSYS, hypertext keywords are highlighted in blue. Aclick on a hypertext keyword will bring up the screen associated withthat word.

For detailed information on using hypertext, see Chapter I. Thehypertext custom screens are stored in the file:

<knowledge base name>.SCR

and are marked in the screen file with ~~keyword. See the ChapterI on the GUI Custom Screen Language for details on creating thehypertext screens.

C - RULE EDITOR 107

Page 166: Manual Exsys

C40: Custom Formula Confidence

The Custom Confidence mode allows you to write your ownformulas to combine confidence factors. This mode is rarely neededfor system development, but it is very powerful and flexible. If thismode is selected, a few additional features are available to you.

C40.1: Using Custom Formulas Confidence System

EXSYS provides five systems for handling confidence values.

1. 0 or 12. 0 to 103. -100 to 1004. Increment/Decrement5. Custom Formulas

The first four systems all function similarly in terms of user input andinterface. However, the fifth system (custom formulas) has significantdifferences.

The custom formula confidence system in EXSYS allows developersto supply their own formulas for the combination of confidencefactors. This is by far the most complex of all the confidence systemsavailable in EXSYS and should be used only by advanced users whoneed the special flexibility this approach offers.

In this system, the end users can be asked to supply a confidencevalue for the data they provide about qualifiers or variables. Thisuser-supplied confidence rating may be used to calculate theconfidence in the choices or in backward chaining to calculate theconfidence of other qualifiers or variables. A backward chain maynot only determine a value for a variable or qualifier but may alsodetermine the confidence in that qualifier or variable. This confidencevalue can be displayed to the user at the end of a run.

C - RULE EDITOR 108

Page 167: Manual Exsys

C40.2: Confidence Variables

The custom formula system uses confidence variables for qualifiers,variables and choices. These behave just like standard numericvariables but are automatically defined to be confidence values.Confidence variables are indicated by starting the variable with a %,followed by the type (qualifier, variable or choice) and number of thequalifier, variable or choice. Also, they can be referred to by name orunique text. This ability makes the confidence variables independentof reorganizations of the expert system.

[%Q#] is the confidence in qualifier #

[%Q"abcd"] is the confidence in the qualifier with theassociated name "abcd"

[%V#] is the confidence in variable #[%%[X]] is the confidence in variable [X][%C#] is the confidence in choice #[%C"abcd"] is the confidence in the choice that

contains the text "abcd" anywhere in the text of the choice

Confidence variables are maintained as double precision floating pointvalues, so the confidence values are not limited to integers.

The confidence variables can be used in combination with othervariables in formulas for derivation of confidence values for otherqualifiers, variables or choices.

When a new variable or qualifier is used in a knowledge base, theprogram asks the developer a series of questions to determine theoptions that are to be used. The options include a button labeledConf Options. If the Custom Formula Confidence mode wasselected, this button will be active. Clicking this button allows you toset parameters for how the confidence of the qualifiers and variableswill be handled.

C - RULE EDITOR 109

Page 168: Manual Exsys

Display Confidence Value

Ask User for Confidence Value

Minimum

Maximum

Initialize Confidence Value

Initial Value

O K Cancel

o.oo

Display ValueIf the variable or qualifier is to be displayed, the confidence valueassigned to it also can be displayed or not, as desired. If theconfidence has been derived, it may be best to display it. If noderived confidence is associated with the variable, it may be better tosimply display the qualifier without a confidence value. To displaythe confidence value, click the Display Confidence Value box.

Qualifier / Variable ConfidenceThere are two options for assigning a confidence value to a qualifieror variable. The confidence value can be asked of the end user orassigned by the system automatically. The default is for the system toassign a value of 0.0. To have the system assign a value, click theInitialize Confidence Value radio button and enter the value in theedit-field labeled Initial Value. To have the end user asked to supplya confidence value, click the radio button labeled Ask User forConfidence Value and enter the minimum and maximum valuesthat will be accepted. If the user is asked for a value, minimum andmaximum values must be entered.

Initial Choice Confidence All choices in the system will have their initial value set to an initialvalue. In most cases, several rules will provide confidence data forthe choice, therefore the formulas that assign a value to the choicewill perform some operation on the current value. The choice muststart with some initial value. The default is 0. However, depending onthe formulas being used, a value other than 0 may be desirable. Tochange the value, select Parameters from the Options menu, clickthe Init Choice Value button and enter the new value. This valuewill be the initial value of each choice at the start of the run.

C - RULE EDITOR 110

Page 169: Manual Exsys

For example, you could have:

Choice 1 Confidence = [%C1]+[%C2]

where Choice 1 is given a value equal to its current value plus thefinal value of Choice 2. This is the type of operation the customformula system can do easily but which is very difficult to do in otherconfidence systems.

C40.3: Assigning a Confidence FormulaWhen the user selects a choice to assign a confidence to, EXSYS willask for a formula to use when calculating the value of the choice.The formula can contain confidence variables or numeric variables.The formula is entered just as if it were being assigned to a typicalvariable.

In these examples, only part of the expression that comes after theequals sign (=) is entered.

Choice 1 - Confidence = ([%[X]] + [%Q 3]) / 2

means the confidence in Choice 1 is the average of the confidence invariable [X] and Qualifier Number 3. We could also use othernumeric variables or choice confidence values. For example,

Choice 2 - Confidence= [%C 1] + [X] + [%[X]]

means Choice 2 is assigned the confidence of Choice 1 plus the valueof variable [X] plus the confidence in variable [X]. A formula likethis would probably not be realistic, but flexibility of the systemallows any expression to be used.

Formulas can also contain the value for the choice confidence that isbeing assigned. For example,

Choice 2 - Confidence = ([%C 2] + [%[X]]) / 2

which means the confidence in Choice 2 is given the value of thecurrent confidence in Choice 2 averaged with the confidence ofvariable [X].

If choices are used in the IF part of the rules, the test is against aformula which can include other confidence variables or numericvariables. For example,

IFChoice 1- Confidence > [%C 2] + 10

THEN....

which means if the confidence in Choice 1 is greater than theconfidence in Choice 2 plus 10, the rule is true.

C - RULE EDITOR 111

Page 170: Manual Exsys

C40.4: User-Supplied Confidence RatingsThe confidence factors for qualifiers and variables can come fromthree sources. When the custom-formula system is used, thedeveloper will be asked a series of questions on each new variable orqualifier that determines how the confidence for that qualifier orvariable will be obtained and displayed.

One of these questions is if the user should be asked to supply aconfidence value when asked about the qualifier or variable. If userinput of the confidence value is selected, the program asks for therange limits on the user-supplied confidence. Depending on theformulas being used, these limits may be 0 to 100, -1 to 1 or anyother range that is appropriate. After the user is asked for the valueof the variable or qualifier, the acceptable range of values will bedisplayed and the users will be asked for their confidence in thepreceding answer. The user-supplied value will be assigned to theconfidence variable associated with the qualifier or variable.

If the developer selects not to have the user provide confidence forthe data, the confidence value for the qualifiers or variables will beautomatically set at a value. This initial value for each qualifier andvariable can be set independently and can be modified by other rules.Typically, the initial value is either 0, 1, or 100 depending upon thesystem used.

Regardless of the initial source for the value of the confidencevariable, the values can be modified by formulas in the rules.Confidence variables can be assigned a value just like any othervariable.

For example,

IF......

THEN[%[X]] is given the value [%[Y]] + 20

means that, if the rule fires, the confidence in variable [X] is given thevalue of the confidence in variable [Y] plus 20.

Note: Asking users to supply confidenceratings of their answers may presume ahigher level of expertise than may bereasonable. Consider the end user beforeimplementing user-supplied confidencevalues. If precise data on which to base theconfidence is available, user-suppliedconfidence values may be valid. However,if the confidence ratings will be purelysubjective, and may vary widely dependingupon user and mood, they may invalidatethe entire expert system.

C - RULE EDITOR 112

Page 171: Manual Exsys

In many systems, it is often better to ask the user questions such as,

The color was seen1 very well2 well3 poorly

which the end user is more likely to answer consistently, and thenconvert these to numeric values internally with rules like,

IFThe color was seen very well

THEN[%[COLOR]] is given the value 90

IFThe color was seen well

THEN[%[COLOR]] is given the value 50

IFThe color was seen poorly

THEN[%[Color]] is given the value 20

C - RULE EDITOR 113

Page 172: Manual Exsys

C41: Custom Help Screens

EXSYS supports custom screens associated with the qualifiers andvariables to provide additional instruction on what a question means,where to get data, or any other information the user might need.These screens are described in Chapter I. These screens are kept inthe file

<knowledge base name>.HLP

However, these screens must be built using the GUI version of theCustom Screen Definition Language. If a screen is associated with aqualifier or variable, the Explain Question item of the Questionsmenu will be active. If the user selects that item, the screen will bedisplayed.

See Chapter I for information on creating custom screens.

C - RULE EDITOR 114

Page 173: Manual Exsys

C42: Loop Error MessagesEXSYS Professional will display an error message when it detectsrule loops that prevent full derivation of needed information. Suchloops force EXSYS to ignore certain values in some cases and shouldbe corrected by the user, even if the correct answer is achieved.

POSSIBLE LOGIC ERROR: Loop involving [var name] in rule #

POSSIBLE LOGIC ERROR: Loop involving Qualifier # in rule #

For example, if you had the following rule,

IF.......

THEN[X] IS GIVEN THE VALUE [A] + 1[A] IS GIVEN THE VALUE 12

you would not expect the program to fire the second THENcondition to establish a value for [A], even though it is relevant to thecalculation in the first condition. The "[A] is given the value 12" isignored when assigning the value to [X]. This is a very simple, andeasy to avoid example (simply reverse the THEN conditions).However, the same effect can happen in a more complex way.Consider the following rules:

Rule 1IF

[B] > 0

THEN..........

Rule 2IF

...........

THEN[X] is given the value [A] + 1[B] is given the value ...........

Rule 3IF

................

THEN[A] is given the value [B] + 1

C - RULE EDITOR 115

Page 174: Manual Exsys

When Rule 1 is tested, the program determines it needs the value of[B]. It invokes rule 2 to determine a value for [B] (We will assumerules 2 and 3 are true). The first condition in the THEN part of rule2 is applied. It requires that the value for [A] be known. Todetermine the value for [A], rule 3 is invoked. It also requires a valuefor [B]. Since the program has already used rule 2 (even though ithas not completed the adding of the THEN parts), it cannot againinvoke rule 2. The program must find another way to determine[B]—it would use other rules or ask the user, but it would not usethe second THEN condition in rule 2 when calculating [A]. Theprogram would then finish adding the first THEN condition in rule 2and would move on to the second. [B] would be assigned a valueafter it had been used to assign a value to [A] in rule 3. This mayresult in [A] having an incorrect value.

EXSYS will detect this error of logic and warn the user. If thesituation described above occurs, you will get the error messagePOSSIBLE LOGIC ERROR: Loop in ([variable name] or Qualifiernumber) in Rule #. This error message means the variable orqualifier cannot be fully derived because of the problem describedabove. That variable or qualifier should be placed, with anypreceding conditions it needs, into a second rule with the same IFconditions.

This could be prevented by not having the THEN part of rule 2include assignments to two variables that are derived from oneanother in other rules. If Rule 2 were broken into two rules, one for[X] and one for [B], the value of [B] would be fully calculated beforebeing used to calculate [A].

Here is an example:

IF...........

THEN[X] is given the value [A] + 1

andIF

...........

THEN[B] is given the value ...........

It is not practical to force the program to apply the second conditionin the THEN part of 2 prior to the first, since the first condition couldhave some effect on the value of the second, resulting in the sameproblem in a slightly different set of rules.

C - RULE EDITOR 116

Page 175: Manual Exsys

Chapter D

EXSYS Runtime

D1: Starting the RUNTIME

Click on the RUNTIME icon to start the program.

In some GUI operating systems, you may also run the program withan optional associated filename of the knowledge base file, and one ormore configure commands:

EXSYSP filename configure_commands

For example, in Microsoft Windows, selecting the RUN item from theFILE menu of the Program Manager allows you to enter a commandline. It is also possible in Microsoft Windows to associate commandparameters with an icon, but this would normally be done only forthe EXSYS Runtime.

D - RUNTIME 1

Page 176: Manual Exsys

D2: Opening an Existing Knowledge Base

Edit Rule Options KBfiles Questions

New

SaveSave AsRevert to Saved

Print

ExitAbout

File

Open

When you select Open, a list of all of the files with a .rul extension isdisplayed. Double click on the desired file, or select a file and click onthe Open button.

Note: For the Macintosh, all files will be displayed. The extensionpast the period in the name is ignored. Select any of knowledge basefiles (.RUL, .TXT, .CMD, .SCR, .HYT, .HLP, etc.).

PasswordsIf the developer selected password protection, the program asks forthe user’s Runtime password. When correct password is entered, thesystem continues. If the password is not known, click on the EXITbutton to exit the system.

D - RUNTIME 2

Page 177: Manual Exsys

D3: System Help

Edit Rule Options KBfiles Questions

NewOpenSaveSave AsRevert to Saved

Print

Exit

File

About

To get help in using EXSYS:

In Microsoft Windows, select About from the File menu, orpress the F1 key.

On the Macintosh, select About EXSYSP in the Apple menu.

In all operating systems, select the Help item from theOptions menu. This will go directly to the Help Topics dialogbox.

File Edit Rule KBfiles Questions

RunCancel Run

Parameters

ValidationExamine Tree Diagram

Notebook

Options

Help

D - RUNTIME 3

Page 178: Manual Exsys

This will bring up the following dialog box. Click on the HELPbutton.

EXSYS Professional EditorVersion 5.0© 1083-1996 EXSYS, Inc.Albuquerque, NM

Cancel

Help

In all operating systems an alternative is to select the Help item fromthe Options menu. This will go directly to the Help Topics dialogbox.

Select help topic...

Help topics

Fresh Window Cancel Help

Either double click on a help topic, or select a help topic with a singleclick and then click on the Help button. A window will displayinformation on the selected topic. If you wish to have the helpinformation on the topic placed in a new help window, click on theFresh Window button.

D - RUNTIME 4

Page 179: Manual Exsys

Help Information

Cancel Prev Next Topics

Click on the Prev button to see the information on the previous topicin the help topic list. Click on Next to see the information on thenext topic in the help topic list. Click on Topic to bring the helptopic list window to the front. Click on Cancel when done. Clickingon Cancel in either the Help Topic window or the Help Text windowwill close both windows.

D - RUNTIME 5

Page 180: Manual Exsys

D4: Notebook

File Edit Rule KBfiles Questions

RunCancel Run

Parameters

ValidationExamine Tree Diagram

Help

Options

Notebook

To make a note in the knowledge base notebook file, go to the mainmenu and pull down Options and select Notebook. You will havethe option to Write, Read or change the notebook file name.

Notebook Option

Notebook Functions:

Write to Notebook

Read from Notebook

Change Notebook FileCANCEL

WRITE

READ

Notebook File:

To write, click on Write and enter the note to add. The text enteredwill be added to the notebook and stamped with the current date andtime. To read, click on Read and the notebook file will be displayed.

To change the name of the notebook file to be displayed, edit the filename displayed at the bottom of the window.

D - RUNTIME 6

Page 181: Manual Exsys

D5: Display of Rules During RuntimeEXSYS allows the developer to limit options available to the enduser. This chapter describes what the end user sees, both if thedeveloper sets no limits and if limitations were set.

1. The developer may have selected to have all rules displayedduring Runtime. In which case, each rule is displayed as itfires.

2. The developer may have switched off display of rules butnot locked out the rule display. Even though the rules are notautomatically displayed during Runtime, the user can examinethe rules by selecting Why in the Questions menu.

3. The developer may have locked out the rule displayentirely, in which case asking Why is not possible. This modecan only be active when password protection has been selected.

D - RUNTIME 7

Page 182: Manual Exsys

D6: Title Screen

When you choose to run an expert system, the first screen you see is.

Title

Author

Run Expert System

To start the expert system, click on the Run Expert System button.

D - RUNTIME 8

Page 183: Manual Exsys

D7: Starting Text

When you run an expert system, you may see a screen whichincludes a description of the program or give you information thatyou need to know to run the program.

Continue

Text

After reading the screen, click on the Continue button.

D - RUNTIME 9

Page 184: Manual Exsys

D8: User Interaction

The expert system takes data from various sources and uses the rulesin the system to arrive at conclusions. The degree of user interactionfor data input varies depending on the system design. However,most systems ask the user for some data input. There are two typesof questions that can be asked - multiple choice selection, and arequest for a value for a variable. EXSYS has a default format forasking these questions. In addition, there is a custom screen languagethat allows the developer to completely modify and customize thesescreens. The default screens are discussed first.

D8.1: Asking for a Qualifier Value

When EXSYS needs the value of a qualifier, it uses the followingdefault screen format:

EXSYS Professional

O K

QUALIFIER VALUE LIST

QUALIFIER TEXT

Select one or more values:

Select values from the Qualifier Value List by clicking on them. Aclick on a value will highlight the value. Some screens allow only asingle value, others may allow multiple values. If the screen onlyallows a single value, clicking on another value will de-select the firstvalue and select the second. If the screen allows multiple values,clicking on several will highlight each of them. To de-select ahighlighted value, click on it again.

D - RUNTIME 10

Page 185: Manual Exsys

As you select values, their respective numbers will appear in the boxat the bottom of the screen. If you wish, you can type the numbersof the desired values desired into this box.

When the correct values have been highlighted, click on the OKbutton.

There is no Cancel button for a qualifier question. The expert systemrequires this information to continue processing. If you do not wishto continue, select Exit from the File menu. It is also possible tosave the input already entered prior to exiting by using the Quit andRecover options.

To ask Why the question is being asked, Undo a previous answer,get more information on the question, or display the current status,use the items on the Questions menu discussed later.

D - RUNTIME 11

Page 186: Manual Exsys

D8.2: Asking for a Variable Value

When EXSYS needs the value of a variable, it uses the followingdefault screen format:

EXSYS Professional

O K

VARIABLE PROMPT TEXT

Please input a value for the varia ble:

Enter a value to answer the question in the box at the bottom of thewindow.

When the correct value has been entered, click on the OK button orpress the Enter key. The value can be numeric or a string valuedepending on the nature of the question asked. For numeric values,the string can contain commas. The commas will be ignored inconverting the value.

There is no Cancel button for a variable question. The expert systemrequires this information to continue processing. If you do not wishto continue, select Exit from the File menu. It is also possible tosave the input already entered prior to exiting by using the Quit andRecover options.

To ask why the question is being asked, UNDO a previous answer,get more information on the question, or display the current status,use the items on the Questions menu discussed below.

D - RUNTIME 12

Page 187: Manual Exsys

D9: External Program InputThe developer may have called external programs to obtaininformation. An external program is any program, includingapplications such as data bases, graphics programs, spreadsheets orcustom programs written in any language; in other words, anythingthat can be run on the computer. This external program mightpresent graphical information, ask fill-in-the-blank type questions, orintegrate the expert system into other programs.

D10: Custom ScreensCustom screens are easily created, the developer may haveredesigned the default screens used by EXSYS. The redesignedscreens may include buttons, sliders, mouse regions. The flexibleEXSYS Custom Screen Language allows the screens to beredesigned in limitless ways. In all cases, it will be clear and easy forthe end user to understand the question and select an answer.Some custom screens may ask for multiple data items on a singlescreen.

The custom screens will look different than the default screen, butthe program will still ask the end user to select from a multiplechoice list or to enter a value, either numeric or text.

D - RUNTIME 13

Page 188: Manual Exsys

D11: Asking Why a Question is Being Asked

File Edit Rule Options KBfiles

Known Data

Display RuleDisplay Choices

Explain Question

Undo Prev. Answer

Save InputRecover Input

Trace Window

Questions

Why?

To ask why a particular qualifier or variable question is being asked,select Why from the Questions menu. EXSYS will explain why thedata is needed. Usually this results in the display of the rule that iscurrently being tested. If the data is needed because of backwardchaining, there may be a series of rules displayed. There may also besome other explanation of why the question was asked. Here's anexample:

1. The program may respond that the end user supplied the information.

2. The program may display a rule or rules that allowed it toderive the information. A rule used for derivation will haveinformation about the condition being queried in its THEN orELSE part. The rule used to derive the information will havealready fired, providing the needed information. (EXSYSautomatically calls all possible rules to derive neededinformation, rather than ask the user.) The end user couldcontinue asking how the program knew the rule’s IFconditions were true. When a rule is displayed, there are avariety of options available to get more information about therule. For more information, see Displaying a Rule.

3. The program may respond that it does not yet knowwhether the condition is true or not. This can occur when theuser asks the program WHY in response to a question. Therule displayed will not have been fully tested yet. Suchconditions will be displayed in blue.

D - RUNTIME 14

Page 189: Manual Exsys

4. If the information came from an external program, theprogram will indicate which external program returned thedata.

5. The program may indicate that particular statement is falseand display the source of the information that determined thestatement was false. In such a situation, the condition isdisplayed in red.

6. If a formula is questioned, the program displays a list of thevalues of all of the variables used in the formula. Clicking onany of the variables in the list will display information on thesource of that value.

With well written rules, tracing the logic of the knowledge base backthrough the rules which were used to derive information is easy.

After displaying a rule, the program may either repeat the questionoriginally asked or it may display another rule. Another rule isdisplayed if the first rule was only used to derive information neededby the second rule, and the second is the rule actually being tested.(One of the THEN or ELSE conditions in the first rule will be in thesecond rule’s IF conditions - this is backward chaining.) All of thequestions asking for information about the rule are available. Theprogram will continue showing the rules it is using to deriveinformation until it reaches the base rule it is trying to test.

Clicking on OK continues the program’s run. If more than one rulewas displayed, each time OK is selected, the program goes up onerule on the list being used in the derivation. Eventually, the programrepeats the question originally asked.

D - RUNTIME 15

Page 190: Manual Exsys

D12: Asking for More Information on a Question

File Edit Rule Options KBfiles

Known DataWhy?Display RuleDisplay Choices

Undo Prev. Answer

Save InputRecover Input

Trace Window

Questions

Explain Question

In some expert systems, the developer may have included additionalinformation on what a question means, or where to find the answerto a question. This information is optional and may not have beennecessary, or included. If there is additional information on thequestion being asked, Explain Question from the Questions menuwill be active. If there is no information, this item will be inactive andcan not be selected.

To ask for more information, select Explain Question. A window willappear which explains the question in more detail. This explanationscreen is designed by the developer with the custom screen languageand may be of any form, but it should have a button labeled OK (orsomething similar) which allows you to exit the screen and return tothe question. See Section I-12 for details on builing Custom Helpscreens.

D - RUNTIME 16

Page 191: Manual Exsys

D13: UNDO a Previous Answer

File Edit Rule Options KBfiles

Known DataWhy?Display RuleDisplay Choices

Explain Question

Save InputRecover Input

Trace Window

Questions

Undo Prev. Answer

Sometimes, during the running of a system, an end user may realizethat their answer to a previous question was incorrect. In EXSYS, itis possible to backup and correct the previous answer. The exactnumber of questions that can be undone is set by the developer.Most developers allow the user to correct between 3 and 10 previousanswers.

To undo a previous answer, select Undo Prev Answer from theQuestions menu. You will be asked the previous question. If youwish to backup farther, select Undo Prev Answer again. You maycontinue backing up as long as Undo Prev Answer is active. Whenyou reach the question which was incorrectly answered, enter thecorrect answer and processing will continue.

D - RUNTIME 17

Page 192: Manual Exsys

D14: Save Input

File Edit Rule Options KBfiles

Known DataWhy?Display RuleDisplay Choices

Explain Question

Undo Prev. Answer

Recover Input

Trace Window

Questions

Save Input

EXSYS provides the option of storing input data, exiting beforecompleting the program, and returning to the same point later. Thisoption can be useful if the user needs to look up information for theprogram or must leave the program but does not want to lose thedata already input.

To save the input entered to a disk file, select Save Input from theQuestions menu. You will be asked for the name of the file in whichto save the data. The file may be any legal filename, except the nameof the Knowledge Base. If a file with the same name already exists, itwill be erased and replaced with the new data. After saving the input,you may wish to exit the run. Data saved can be read back into thesystem with the Recover configure option, or by selecting RecoverInput from the Questions menu.

D - RUNTIME 18

Page 193: Manual Exsys

D15: Recover Input

File Edit Rule Options KBfiles

Known DataWhy?Display RuleDisplay Choices

Explain Question

Undo Prev. Answer

Save Input

Trace Window

Questions

Recover Input

Input saved with a Save Input command, or the SAVE commandlanguage command, can be recovered only at the start of anotherrun. To indicate that data is to be recovered, use the configureoption RECOVER or RECOVER=file. Alternatively, you may selectRecover Input from the Questions menu when the expert systemtitle screen is displayed. The only immediate effect of this will be toput a check mark beside Recover Input. This indicates that therecover mode is active. If there is already a check mark, selectingRecover Input will de-active it.

If the configure option RECOVER has been used, Recover Inputwill be checked automatically.

If recover mode is active at the start of a run, EXSYS will ask if youwish to recover data from a file. If you answer "YES", you will beasked for the name of the file. The data will be read in andprocessing will continue. To have the data read automatically withoutasking for user interaction, use the RECOVER=file configure option.

D - RUNTIME 19

Page 194: Manual Exsys

D16: Displaying the Known Data

File Edit Rule Options KBfiles

Why?Display RuleDisplay Choices

Explain Question

Undo Prev. Answer

Save InputRecover Input

Trace Window

Questions

Known Data

To display all of the data known to the system, select Known Datafrom the Questions menu. This will create a Known Data window.It lists all of the data known. If you wish to know the source of anyof the data displayed, select an item by clicking on it and click on theHow button, or double click on the item. The source for theinformation will be displayed. The display may also include the rulesif they are the source of the data.

KNOWN DATA

O K HOW

Known Data

If the Known Data window is kept active while the system is running,each new item of data will be added to the window as it is asked ofthe user or derived from rules.

D - RUNTIME 20

Page 195: Manual Exsys

D - RUNTIME 21

Page 196: Manual Exsys

D17: Displaying the Status of the Choices

File Edit Rule Options KBfiles

Known DataWhy?Display Rule

Explain Question

Undo Prev. Answer

Save InputRecover Input

Trace Window

Questions

Display Choices

To display the current status of the choices in the system, selectDisplay Choices from the Questions menu. This will create aChoice Data window. It lists the status of each choice. If you wish toknow the source of any of the data displayed, select an item byclicking on it and click on the How button, or double click on theitem. The source for the information will be displayed. Usually, thedisplay is the rules that set the value for the choice.

CHOICE DATA

O K HOW

Choice Data

ALL

The Choice Data window displays the choice and the value set.Initially, only choices with values over the threshold for choice display

D - RUNTIME 22

Page 197: Manual Exsys

are shown. To see all of the choices, click on the All button. If achoice has a value of "None", that means no rules have firedassigning any value to the choice. A value of "None" is not the sameas a value of 0, which means something has assigned a value of 0 tothe choice. After the All button is clicked, the button label willchange to > #, where # is the threshold value. To return the displayto only those choices over the threshold, click on the ># button,which will return the button label to All.

If the Choice Data window is kept active while the system is running,each new choice value will be added to the window as it is derivedfrom rules.

D - RUNTIME 23

Page 198: Manual Exsys

D18: Displaying a Rule

File Edit Rule Options KBfiles

Known DataWhy?

Display Choices

Explain Question

Undo Prev. Answer

Save InputRecover Input

Trace Window

Questions

Display Rule

Rules can be displayed in EXSYS in many ways. Often asking forthe source of a piece of data, or asking Why a question is beingasked will result in the display of a rule. It is also possible to ask tosee a specific rule by selecting Display Rule from the Questionsmenu. Select the rule to display by either name or number.

The rule display is color coded. A condition displayed in RED isfalse, a condition displayed in BLACK is true and a conditiondisplayed in BLUE is unknown. In addition, the status of the rule(TRUE, FALSE or NOT TESTED) appears on the top line of thewindow. (Note: "Not tested" may appear for a rule that is definitelytrue or false, it only indicates that the rule has not yet been used bythe expert system.).

Also the background color for the window indicates its status. ARED background indicates a FALSE rule, a GREEN background aTRUE rule and a BLUE background an untested rule. The colorcoding for the rules is updated as each new piece of data is added. If arule is displayed during a run, it is easy to notice the color changefrom BLUE to GREEN indicating the point at which it fired. Themenu bar also displays if the rule is true, false or unknown.

D - RUNTIME 24

Page 199: Manual Exsys

Rule #: FALSE

IF:

THEN:

ELSE:

Then conditions

If conditions

Else conditions

Optional Note text

O K Source PREV NEXT Jump Reference

Color Coding of RulesCondition TRUE BLACKCondition FALSE REDCondition UNKNOWN BLUE

Rule TRUE GREEN backgroundRule FALSE RED backgroundRule UNKNOWN BLUE background

To examine the source of the information for any of the IFconditions, click on the IF condition to select it and click on theSource button, or double click on the item.

To examine the numerically previous or next rule, click on the Prevor Next button respectively. To jump to another more distant rule,click on the Jump button, and select the rule to jump.

It is possible to have multiple rule windows open on the screen.However, as the number of rules becomes large, processing may slowdue to the need to update each rule as new data is added.

D - RUNTIME 25

Page 200: Manual Exsys

A rule may have a note associated with it. Notes are used to provideadditional information or to explain a complex rule in simpler terms.The note has no effect on the running of the rule. If there is a noteassociated with the rule, it will automatically be displayed.

Rules often also have a reference for the source of the factrepresented in the rule (e.g., personal observation, book, article). Toexamine the reference for the rule, click on the Reference button.The reference will be displayed. If no reference is available, thebutton will be inactive.

D - RUNTIME 26

Page 201: Manual Exsys

D19: Ending Text

The author of the expert system may have decided to include aending explanation of what the expert system results mean. If so, ascreen with this information will be displayed just before the Results.If the author did not include such a screen, the expert system willdisplay Results at the end of the run.

Continue

Text

After reading the screen, click on the Continue button.

D - RUNTIME 27

Page 202: Manual Exsys

D20: Displaying Results

At the end of a run, the results will be displayed.

Each choice has a probability value which is the final score obtainedby combining the points that each choice received.

A comparison of the scores displayed indicates the relative likelihoodof the choices. For example, if the first choice gets a 9 and thesecond an 8, both are almost equally likely. On the other hand, if thefirst choice got a 9 and the second a 3, the first is much more likelythan the second.

Text statements with no associated numeric value may be displayed.These are text messages to the user that were marked for display.They are not choices and always appear after the list of choices.

Numeric values calculated by the program or other statements offact that were derived by the program may also be displayed. Likethe text statement described above, the display of this data alwayscomes after the list of choices regardless of confidence system used.In the Custom Formula System, these statements of fact may have aconfidence factor associated with them.

D20.1: Confidence ModesThe developer chose one of five possible Confidence Modes whenbuilding the knowledge base. The selection made by the developerdetermines what the end user sees on the screen and the wayEXSYS manipulates the data. This section describes the differentConfidence Modes, the kind of responses expected from the enduser, and the effects of those responses.

0/1If the developer selected the 0-1 System, the user sees a confidencevalues of 0 or 1 . A value of 0 means "absolutely no" and a value of1 is equivalent to "absolutely yes". This mode has no realprobability, only yes or no.

0/10If the developer selected the 0 to 10 System, the user sees aconfidence value between 0 and 10. In the rules this is displayed as aratio with a denominator of 10. This mode is often encountered. Inthis mode, 0 is equivalent to "absolutely no". (A single rule assigninga value of 0 locks the value at 0 regardless of any other value thechoice may have received from other rules.) A value of 10 isequivalent to "absolutely yes" and also locks the value for the choiceat 10 regardless of any other values the choice may have received.

D - RUNTIME 28

Page 203: Manual Exsys

Values of 1 to 9 represent degrees of certainty ranging from "veryprobably no" to "very probably yes". The values from 1 to 9 do notlock the value but are averaged to give the final value for a choice.

For example: if the same choice appears in the three rules that hadtrue IF parts with values of 3/10, 8/10, and 4/10, the final value forthe choice will be the average - 5/10. If the values found were 3/10,9/10 and 0/10, the 0/10 would prevail and the result in a final valueof 0/10 despite the other values. If the values were 1/10, 3/10, and10/10, the 10/10 would lock the value at 10/10 regardless of theother values. Values of 1 through 9 are averaged to a final valueonly if not over-ridden by a 0/10 or 10/10. The first 0/10 or 10/10prevails and will not be changed even by another 10/10 or 0/10.

-100/+100If the developer selected the -100 to +100 System, the values will bebetween -100 and 100. (In the rules this will displayed as a ratio witha denominator of 100.). In this system, values of 0 to 100 can beassigned but the values of 0 and 100 do not lock the value. The finalvalue can be computed as an average of the probabilities or can becombined as dependent or independent probabilities. The first is asimple average of all of the individual values the choice received inthe rules found to be true. The second combines the probabilities asif they were dependent probabilities. That is, the probabilities aremultiplied as percents. For example, if choice appeared in two rulesthat were used, with values of 60/100 and 90/100, its final valuewould be 60% times 90% =54% for a final value of 54/100. Thethird way to combine the values is to treat them as independentprobabilities. In this system, the combination of the two probabilitiesis 1 minus the product of 1 minus the individual probabilities. In theexample above, this would be

1-((1-60%) * (1-90%))=96%

for a final value of 96/100. If negative values are used only theaverage mode can be used.

Increment/DecrementIf the developer has chosen the Increment/Decrement Mode, pointsare added or subtracted from the total points for a particular choice.Final values may be between -10,000 to 10,000. In the rules, therewill not be any ratios for the confidence values. For example, wemight have "Choice 1 - Confidence=5". This means that if the rulefires, Choice 1 will get 5 points added to its total. At the end of therun, the total number of points is displayed.

All choices getting values higher than a threshold will be displayedwith the results. No values lock a choice, but giving a choice a largenumber of points can push it over the threshold value.

D - RUNTIME 29

Page 204: Manual Exsys

Custom FormulaIf the developer selected the Custom Formula Mode, the confidencestatements for the choices have formulas in them. This mode allowsdevelopers to write their own formulas for the combination ofconfidence values. User-supplied confidence, derived confidence onvariables or qualifiers, and numeric variables can be included incomplex formulas to determine the confidence for a choice. This is amuch more complex system to use and it is described in greaterdetail in Section C3.3.

Results

O K

Results

HOW Change/Rerun All

In most systems, the results of the run will be displayed at the end ofa run. This includes all choices which received confidence valuesover the threshold value, and all qualifiers and variables which wereflagged to be displayed with the results. Some systems may alsodisplay intermediate results, or may simply output the results to a fileor pass data to another program to take some action.

To ask the source for any of the items, select the item by clicking onit, and then click on the How button; or double click on the item.

Initially only choices with values over the threshold for choice displayare shown. To see all of the choices, click on the All button. If achoice has a value of "None", that means no rules have fired whichassign any value to the choice. A value of "None" is not the same asa value of 0, which means value of 0 was assigned to the choice.After the All button is clicked, it will change to >#, where # is thethreshold value. To display only those choices over the threshold,click on the ># button, which will return the button label to All.

D - RUNTIME 30

Page 205: Manual Exsys

D21: Change and RerunEXSYS provides a very easy way to test what effect altering some ofthe input will have on the conclusions. One or more answers can bechanged, the remainder held constant, the data rerun, and the effectof the changes on the final results seen. The initial values for thechoices can be saved for comparison with the new scores. This issimilar to changing a number in a spreadsheet to see what effect ithas on other numbers.

To activate Change and Rerun, click on the Change/Rerun button. Awindow will display all of the data provided by the user.

Change / Rerun Data

RUN

Data

Change Original DataCancel

To change a data item, click on it to select it and click on the Changebutton, or simply double click on the data item. You will be askedthe data item that you are testing. Select a new answer. The windowwill display the selected item highlighted and then display the newvalue. You may change as many data items as you wish.

When you have finished modifying the data, click on the Run button.The data will run, possibly asking additional questions if themodifications lead to new rules firing, and then it will present theresults. However, this time the results screen will have two columnsof data, the original values and the values obtained as a result of themodified data. This allows side by side comparison of the effects ofmaking the changes.

D - RUNTIME 31

Page 206: Manual Exsys

The ability to change and rerun the data allows expert system modelsto be built and tested to see if an answer is vital to the final outcomeor really has little effect. Experiment with Change and Rerun; it is avery powerful feature.

If several changes to the input data were made, and the user wants toreturn to the original input, click on the Original Data button. Thedata will return to the original input values.

To Cancel the change and rerun, click on the Cancel button.

D22: Custom Results ScreensCustom results screens can be created with the Report Generator andDisplay commands. If there is no .CMD file, and there is a .OUTreport generator file, the report generator file will be executed beforedisplaying the results. (To prevent the normal results screen fromoverlaying the DISPLAY window, use the /N option on theDISPLAY command.) The report generator file can include anending DISPLAY( ) command to display the results in customizedformat, and can even use the Custom Screen language for highlycustomized screens.

D - RUNTIME 32

Page 207: Manual Exsys

D23: Exiting the Runtime

Edit Rule Options KBfiles Questions

NewOpenSaveSave AsRevert to Saved

Print

About

File

Exit

To exit the EXSYS Runtime, go to the File menu on the menu barand select Exit.

D - RUNTIME 33

Page 208: Manual Exsys

Chapter E

Configuration Options

There are a variety of command line options available in EXSYSProfessional. Command line options are given when the program iscalled from the operating system. For example:

EDITXSP <filename> <command line options>or

EXSYSP <filename> <command line options>

The command line options must follow the file name and can onlybe used in the command line if you have specified a file name.

Since EXSYS Professional has a large number of command lineoptions, some with fairly long commands; it can be inconvenient toenter all these options each time an expert system is called. Also,you may wish to always use the same options for all your expertsystems or for each time a particular expert system is run.Configure files can be defined containing the same command lineoptions. The configure file will be read each time the system is run.The configure files are much more convenient, especially for finaldistribution of an expert system to end users.

E1: Editor/Runtime Configure Files

EXSYS Professional has two types of configure files. The first isassociated with the EXSYS Professional programs, EXSYSP.EXEand EDITXSP.EXE. Each time the EXSYS Professional editor orruntime is called, the configure file associated with the program willbe used. The configure files associated with the EXSYS Programsare:

EDITXSP.CFGand EXSYSP.CFG

E - CONFIGURATION OPTIONS 1

Page 209: Manual Exsys

You can create the file EDITXSP.CFG with a text editor and list asmany command line options as you wish. Each time the EXSYSProfessional Editor program, EDITXSP.EXE is called, it will checkfor this configure file and use any options you have specified.

Likewise, the file EXSYSP.CFG applies to the runtime programEXSYSP.EXE.

NOTE: The editor configure file has noeffect on the runtime and visa versa. Ifyou have developed an expert system inthe editor, and it behaves differently whenyou run it with the runtime, make sure theconfigure options are identical.

E2: Knowledge Base Configure Files

Sometimes certain configure options will be needed for a particularexpert system, but not for all the systems you work on. In that case,you can have a configure file associated with that particularknowledge base.

The configure files for a knowledge base <FILENAME> would be

<filename>.CFG

The files EDITXSP.CFG and EXSYSP.CFG are automaticallycalled by EDITXSP and EXSYSP, and should contain anyconfiguration information needed by all your knowledge bases. The<filename>.CFG file should contain the special configureinformation needed only by the knowledge base specified by the<filename>.

The configure files are optional, and configure information can stillbe entered in the command line. In case of conflicting commands,the last one read takes precedence. EXSYS Professional first readsthe command line arguments; then reads the file EXSYSP.CFG orEDITXSP.CFG; then reads the configure file associated with theknowledge base.

E - CONFIGURATION OPTIONS 2

Page 210: Manual Exsys

E3: Creating Configure Files

When the .CFG files are used, they should contain one commandper line with a carriage return following each command. Forexample, if we always wanted EXSYSP to switch off color displayand allow the option to recover saved data, we would have a fileEXSYSP.CFG with

NOCOLORRECOVER

If, in addition, we had a knowledge base named LOANS which wewanted to run with the FORWARD and NOBACKWARD options,we would create a file LOANS.CFG with

FORWARDNOBACKWARD

The file EXSYSP.CFG or EDITXSP.CFG must be on the samedrive and in the same path/directory as the files EXSYSP.EXE orEDITXSP.EXE respectively. The file <filename>.CFG must be onthe same drive and path/directory as the <filename>.RUL file.

There are a large number of command options. Most are set by theauthor of the knowledge base and should not be changed by anotheruser. Many of these options are related to features covered in othersections on creating expert systems.

NOTE: Remember, the commands in the .CFG fileare automatically read in. If EXSYS seems to bebehaving in a non-standard way, check theconfigure files for changes to the standard defaults.Use caution when adding the files EXSYSP.CFGand EDITXSP.CFG. It is easy to forget that thesefiles are on a disk, but they will effect all the expertsystems you run!

E - CONFIGURATION OPTIONS 3

Page 211: Manual Exsys

Command Line or .CFG Option

Change Connector Words

AND=<and word>OR=<or word>NOT=<not word>

These three commands allow the user to change the connector wordsused in EXSYS qualifier conditions from and/or/not to other words.This makes it easier to use EXSYS Professional in languages otherthan English.

For example, to change the AND connector to the German wordUND, you can use

AND=UND

in the command line or configure file. In all rules and statementswhere EXSYS Professional uses qualifier conditions, the "AND","OR" or "NOT" will be replaced by the text specified in thecommand. This will not change the "AND" or "OR" used to buildrules.

E - CONFIGURATION OPTIONS 4

Page 212: Manual Exsys

Command Line or .CFG Option

Asks for Specified Data at the Start of a Run

ASK

You may sometimes wish to ask the user the same sequence ofquestions at the start of every run, regardless of what the users mayinput. The order in which the questions are asked can be forced bywriting a rule that is always true. However, this is a technique thatcan confuse users if they ask WHY. Instead, an ASK command canbe added to the knowledge base .CFG file. The questions will thenbe asked in the same order they are specified in the .CFG file.

To ask a qualifier, enterASK Q #

orASK Q "name"

where # is the number of the qualifier to ask, and "name" is thename associated with the qualifier. If the name form is used, thename must be in quotation marks ( “ ” ).

To ask a variable enter ASK V #

orASK [var name]

where # is the variable number and var name is the name of thevariable. If the name form is used, the name must be in brackets ( [ ] ).

For example, if the <filename>.CFG file contained

.....

.....ASK Q 11ASK Q "color"ASK V 7ASK [X]..........

The program would ask qualifier 11, the qualifier named "COLOR",variable 7 and variable [X] at the start of the run, before any otherquestions were asked.

(Also see the ASK command in the Command Language.)

E - CONFIGURATION OPTIONS 5

Page 213: Manual Exsys

Command Line or .CFG Option

Calling an External Program AfterChange and Rerun Commands

Two command line options control the running of an externalprogram called at the start of a run during a "change and rerun"operation. If the knowledge base has a starting external program,the EXSYS Professional default is to ask if you wish to rerun theexternal program during a change and rerun. In some cases, askingthis question can be undesirable, since the answer is always the sameand the end user should not be asked the question.

The command line or .CFG option:

CHANGE_NOEP

doesn’t allow Professional to run the starting external program and italso stops the program from asking the users if they want to run theprogram.

CHANGE_RUNEP

causes Professional to run the starting external program withoutasking the user.

E - CONFIGURATION OPTIONS 6

Page 214: Manual Exsys

Command Line or .CFG Option

Change the Name of the Configure FileUsed.

CFG=<file name>

Normally EXSYS Professional uses the file<knowledge base name>.CFG to set configure options. This can bechanged by using the command line option CFG=filename. Thespecified file will be used instead of the normal file. The filesEDITXSP.CFG or EXSYSP.CFG will still be read, as will any othercommand line arguments.

Note: This can only be used in thecommand line, EDITXSP.CFG orEXSYSP.CFG. Using this command inthe file <knowledge base name>.CFG willhave no effect.

E - CONFIGURATION OPTIONS 7

Page 215: Manual Exsys

Command Line or .CFG Option

Allow Data from External Programs to beModified During Change and Rerun

CHANGE_EXT

The CHANGE_EXT option allows data from external programs tobe displayed for modification during a change and rerun. Data fromexternal programs is not normally displayed. Displaying thisinformation is particularly useful for data that was returned from aprogram called with a /M option to allow multiple items of data tobe returned.

E - CONFIGURATION OPTIONS 8

Page 216: Manual Exsys

Command Line or .CFG Option

Change the Name of the Command FileExecuted.

COMMAND=<file name>

EXSYS Professional supports command files. A command file is anoptional file which contains commands that override the usualoperations of EXSYS. The default mode for EXSYS is backwardchaining, using all rules with results displayed at the end. Thecommand file can completely change the way in which rules areused. See chapter J for information on the command language.

If there is no command language file present, EXSYS will use itsdefault modes of operation. However, if the command file ispresent, EXSYS will use it. The default command file whichEXSYS looks for is <knowledge base name>.CMD.

For example, if the knowledge base was named ACCTS, EXSYSProfessional would look for the default command fileACCTS.CMD.

The default command file name can be changed with the commandline or .CFG option

COMMAND=<filename>

in which case <filename> will be used as the command file. If theCOMMAND= option is used, Professional will not look for<knowledge base name>.CMD.

E - CONFIGURATION OPTIONS 9

Page 217: Manual Exsys

Command Line or .CFG Option

Control of Runtime Menu Options

This series of commands allows the developer of an expert system tocontrol the options that are available to the end user. There aretimes when you may want to prevent the end user from doing anumber of functions such as displaying rules, quitting/saving, askingfor change/rerun, and so on. The following command line optionsallow various menu options to be turned on or off individually.

WHYOFF Disables WHY when asking for a qualifieror variable.

?OFF Disables ? when asking for a qualifier or variable (automatic if no .HLP file is available).

QUITOFF Disables QUIT/SAVE when asking for a qualifier or variable and when the final results are displayed .

HELPOFF Disables HELP during the run.

LIMITOFF Prevents the end user from changing the threshold limit value for displaying choices.

PRINTOFF Disables printing results from the final conclusion screen.

SORTOFF Prevents the end user from changing sort type in -100 to +100 mode.

CHANGEOFF Disables change and rerun.

HOWOFF Disables asking how a conclusion was reached from the final conclusion screen.

The end use can circumvent the options that prevent rule display byediting the .CFG file. However, to ensure that your end user will nothave access to the rule display, use the rule locking options withpassword protection.

E - CONFIGURATION OPTIONS 10

Page 218: Manual Exsys

Command Line or .CFG Option

Automatically Reads a Series of Records ofData and Executes the Rules

DATALISTDATALIST=<filename>

The DATALIST command tells EXSYS that there is a list of data inthe file RETURN.DAT which needs to be read. The list can containmultiple sets of data for batch mode analysis. The program willbehave as if an external program had already been called that wrotethe data to this file. This has two advantages.

1. The structure of the data in a DATALIST allows a seriesof records to be separated by the END statement. EXSYSProfessional will read the first set of data, analyze it, write itsreport on that data, then read the next set of data, analyze it,and continue with this process until it is finished. This is avery powerful technique that allows an expert system toanalyze large amounts of data in a batch mode. This process isdescribed in Section H14 on analyzing data base reports.

2. It allows you to run a very large program to create thereturn data. An external program must fit into memory at thesame time as EXSYS. The memory used by EXSYS reducesthe available memory and may prevent some externalprograms from running. With the DATALIST command, abatch file can be written to call a program and have it createthe RETURN.DAT file, then when that program exits, thebatch file calls EXSYS. This way both programs do not haveto be resident in memory at the same time.

E - CONFIGURATION OPTIONS 11

Page 219: Manual Exsys

The DATALIST command can also be used with a filename

DATALIST=<filename>

In this case, EXSYS will read the file <filename> rather thanRETURN.DAT for the data used in the datalist. However, therecould be a problem if a datalist call and an external program call arewanted at the same time. This could create problems because boththe datalist file and the external program would try to useRETURN.DAT for data. The form DATALIST=<filename> avoidsthis problem.

For example, the command

DATALIST=ZZZ.DAT

will cause Professional to read DATALIST data from ZZZ.DAT,leaving RETURN.DAT available for external program calls.

See chapter H on external program calls and Section H14 onanalysis of lists of data for more information on the use ofDATALIST.

E - CONFIGURATION OPTIONS 12

Page 220: Manual Exsys

Command Line or .CFG Option

Change the Standard Ending Message if NoChoices are Set

ENDMSG=text

This command option will replace the standard ending text messageif no choices fire. The specified text will then be used as the newending text.

The default ending message if no choices fire is

NO CHOICES RECEIVED A VALUE GREATER THANTHE THRESHOLD VALUE ___

In some cases it may be confusing or inappropriate to display thismessage to an end user. It may be better to provide some specificinstruction if no choices fire, such as informing the end use that heshould contact the author of the expert system for further instruction.

For example, you might have the program say

ENDMSG=ERROR: Call (911)555-1234 for assistance.

This replaces the standard ending message with instructions on howto get assistance. If you choose the replace the standard endingmessage, your new text must be at least one character long and mustbe on a single line.

E - CONFIGURATION OPTIONS 13

Page 221: Manual Exsys

Command Line or .CFG Option

External Program Flag File Control

EP_FLAG_FILE=fileEP_TIME_INC=#

These command options control the flag files necesary for callingexternal programs in MS Windows and Macintosh. See Sections H3and H4 for details of using these commands.

Add Extra Space When Printing Rules

EXTRA_SPACE=#

This command option adds extra space between lines when printingrules to a printer. This is helpful if you want to add space in theprintout for changes, notes, or some other form of additionalcomment. If you don’t invoke the command optionEXTRA_SPACE=#, then EXSYS will automatically calculate thespace between the lines.

The # parameter is a numeric value in pixels. In general, a characteris 12-15 pixels, so to add an extra character width between lines useEXTRA_SPACE=15

E - CONFIGURATION OPTIONS 14

Page 222: Manual Exsys

Command Line or .CFG Option

Stops Execution When Any Choice Has aFinal Value Set Greater Than 0

FIRSTONLY

The FIRSTONLY command tells EXSYS to stop execution afterany choice receives a value of 1 in the 0/1 system, or a value of 10in the 0-10 system of probability. This is useful for expert systemsthat are designed to pick only one solution to a problem. Once thesingle solution has been found, the FIRSTONLY command willcause the execution to stop and display the results. TheFIRSTONLY command does all this without asking the userunnecessary questions related to the other choices.

E - CONFIGURATION OPTIONS 15

Page 223: Manual Exsys

Command Line or .CFG Option

Forward Chaining Options

FORWARDNOBACKWARDFINALPASS

FINALPASS —This command makes EXSYS do a final forwardchaining pass through the rules after it has finished the backwardchaining. Backward chaining will invoke a rule only if it is relevantto a choice. This option allows a final pass to test all rules—even ifnot relevant to a choice—to see if they are valid. It can be used withthe RUN command to execute external programs that are notreferenced in rules related to choices.

FORWARD —This command line option keeps EXSYS fromperforming a backward chain on each of the choices. Instead, theFORWARD command makes EXSYS examine each rule in theknowledge base, in order of occurrence. Backward chaining is stillused to derive information needed in testing the IF conditions of arule. The FORWARD command can result in much faster executionthan backward chaining of the choices.

NOBACKWARD —This command line option prevents EXSYSfrom performing a backward chain function to derive information.However, EXSYS will still examine the choices in order.

Note: All rules that derive informationmust occur in the knowledge base prior tothe need for the derived information. Thiscommand is usually used in conjunctionwith the FORWARD command.

E - CONFIGURATION OPTIONS 16

Page 224: Manual Exsys

The effect of FORWARD, BACKWARD and FINALPASS can beseen in a simple example.

Consider the following set of rules:

RULE 1: RULE 4:IF IF

Y IS TRUE X IS TRUETHEN THEN

CHOICE 2 - Probability 3/10 CHOICE 1 - Probability8/10

RULE 2: RULE 5:IF IF

z IS TRUE z IS TRUETHEN THEN

Y IS TRUE W IS TRUEELSE

Y IS FALSE

RULE 3:IF

X IS TRUETHEN

CHOICE 2 - Probability 7/10

Normal Backward ChainingEXSYS normally tests rules by looking for the first rule with choice1 in its THEN or ELSE part. EXSYS then tests the IF conditions ofthat rule. If any information on the IF conditions can be derivedfrom other rules, those rules are invoked through backwardchaining. The program then looks for the next rule relevant to eachfollowing choice until it has gone through all of the rules. Theprocess is then repeated for those rules relevant to choice 2, choice3, and so on, until the list of choices is completely tested. If a rule isnot relevant to any choice, or does not assign values to a variablewhose value is displayed at the end of a run, it will not be used.

With no command line options, the set of 5 rules listed above wouldexecute in the following manner:

1. First the program would look for rules that containCHOICE 1. The first, and only place it finds CHOICE1 is in Rule 4. The program then looks to see if there isany way to derive information about the IF condition inthis rule. Since X is not in the THEN or ELSE part ofany other rule, EXSYS would then ask the user for thevalue of X. The user input would determine if Rule 4 isvalid or not.

E - CONFIGURATION OPTIONS 17

Page 225: Manual Exsys

2. The program would then look for the rules thatcontain CHOICE 2. EXSYS finds the first mention ofCHOICE 2 in Rule 1. Since the IF condition of thisrule can be derived from Rule 2, the program invokesRule 2 through backward chaining to deriveinformation. Since there are no rules that would aid indetermining if the IF condition in Rule 2 (Z IS TRUE)is valid, EXSYS asks the user about Z.

3. EXSYS will then look for the next rule withCHOICE 2 in it—Rule 3. Since the program alreadyknows the status of X, this rule can be tested and, if it isfound to be valid, EXSYS will use it.

4. When all the choices have been tested, the programstops and displays the results. Notice that rule 5 has notbeen used. This is because it does not have a choice init and W is not needed in any rule relevant to a choice.Irrelevant rules are not used.

The order of operations would be:

Test Rule 4—Used for Choice 1 Ask X Test rule 1—Used for Choice 2 Test Rule 2—Invoked by backward chaining from Rule 1 Ask Z Test Rule 3—Used for Choice 2

With the FINALPASS OptionThe FINALPASS option causes a final pass through the rules,testing any unused rules. In the example above, the rules wouldexecute as described above, however there would be a final pass totest all rules that had not been used previously. In this case, Rule 5would be tested and, if valid, it would be used.

The order of operations would be:Test Rule 4—Used for Choice 1 Ask X Test rule 1—Used for Choice 2 Test Rule 2—Invoked by backward chaining from Rule 1 Ask Z Test Rule 3—Used for Choice 2 Test Rule 5—Checked in Final Pass

E - CONFIGURATION OPTIONS 18

Page 226: Manual Exsys

Using the FORWARD OptionWith the FORWARD command line option, EXSYS tests the rulesin the order they occur, using backward chaining to derive anyaddition information that EXSYS needs. With this option chosen,this is how the rules would run:

1. Rule 1 is tested. Since the IF condition needsinformation on Y, backward chaining invokes Rule 2 toderive information. The user is then asked forinformation on Z.

2. Since Rule 2 has already been tested, the programmoves on to rule 3 and asks the user about X.

3. The program then tests rule 4. Since X is alreadyknown, the user is not asked any information.

4. The program then tests Rule 5, even though it is notrelevant to any of the choices.

The order of operations would be: Test Rule 1 Test Rule 2—Invoked by backward chaining from Rule 1 Ask Z Test Rule 3 Ask X Test Rule 4 Test Rule 5

Using the NOBACKWARD OptionThe NOBACKWARD option keeps EXSYS from using backwardchaining to derive information. However, rules are checked in theorder that the choices occur.

1. First the program looks for the first rule thatcontains Choice 1. — Rule 4. To test Rule 4, EXSYSasks the user for information on X.

2. The program then looks for the first rule withChoice 2 in it— Rule 1. Previously, when rule 1 wastested, backward chaining invoked rule 2 to deriveinformation about Y. Since backward chaining hasbeen switched off, the user is asked about Y. Theprogram has not needed to ask about Y previously.

3. The program then looks for the next rule withChoice 2—Rule 3. Since information is already knownabout X, the program doesn’t ask the user for additionalinformation.

E - CONFIGURATION OPTIONS 19

Page 227: Manual Exsys

4. In this case, both rules 2 and 5 are not used.

The order of operations would be:

Test Rule 4—Used for Choice 1 Ask X Test Rule 1—Used for Choice 2 Ask Y Test Rule 3

With BOTH the NOBACKWARD and FORWARDOptionsUsing both of these options allows a purely forward chaining runand allows for substantial improvement in speed. In this case, thereis a single pass through the rules with no backward chaining.

Note: All rules that derive information mustoccur in the knowledge base prior to the needfor the derived information.

In our example, Rule 2 derives information that is needed for Rule 1.To correct this, move Rule 2 to be the new Rule 1.

RULE 1: RULE 4:IF IFz IS TRUE X IS TRUE

THEN THENY IS TRUE CHOICE 1 - Probability 8/10

ELSEY IS FALSE RULE 5: IF

z IS TRUERULE 2: THENIF W IS TRUEY IS TRUE

THENCHOICE 2 - Probability 3/10

RULE 3:IFX IS TRUE

THENCHOICE 2 - Probability 7/10

E - CONFIGURATION OPTIONS 20

Page 228: Manual Exsys

1. The program tests Rule 1 and asks the user about Z.

2. The program tests Rule 2. Rule 1 has established thestate of Y, so no additional information is needed fromthe user.

3. The program then tests Rule 3. The program asksthe user about X.

4. The program then tests Rule 4.

5. The program then tests Rule 5.

The order of operations would be: Test Rule 1 Ask Z Test Rule 2 Test Rule 3 Ask X Test Rule 4 Test Rule 5

The options on order of rule execution can greatly improve thespeed of large expert systems through the use of the FORWARDNOBACKWARD option. The use of the FORWARDNOBACKWARD option can improve execution speed by adocumented factor of 20 to 50 for large systems.

If the knowledge base is structured so all the rules used to deriveinformation can be placed in the rule list prior to the point where thederived information is needed, the rules can be run with theFORWARD option. Unless the rules have complex derivation pathsthat require backward chaining, the NOBACKWARD option canalso be used. To be certain that the rules can be run in the forwardmode, use the print command to print a cross-reference list on thequalifiers, choices and variables. The list will show what rules eachqualifier and variable is used in and if it is used in the IF, THEN orELSE part. Make sure each qualifier, variable and choice is notused in a THEN or ELSE part after it is used in an IF part. In otherwords, all uses in the THEN or ELSE part of the rules must occurnumerically before the uses in the IF part.

Remember, using FASTERP rearranges rules and can have an effecton the use of forward chaining.

E - CONFIGURATION OPTIONS 21

Page 229: Manual Exsys

Command Line or .CFG Option

Sets an Alternate Knowledge Base Help File

HELP=file

EXSYS Professional usually expects to find the custom help for theknowledge base in <knowledge base name>.HLP. If you wish tochange to the use of another help file, use the command HELP=.

For example, HELP=TEST.ABC would use this file as the customhelp file for the system. This can be useful if there are different helpfiles for different users who need help aimed at differing knowledgelevels. This can also be used to assign a help file in a differentlanguage to a system without duplicating the rules.

This does not change the system help. See the commandEXSYS_HELP= for information on how to assign a path to thesystem help file EXSYSP.HLP

E - CONFIGURATION OPTIONS 22

Page 230: Manual Exsys

Command Line or .CFG Option

Limits Options Available to User of Runtime

LIMITOPTIONS

This command causes the EXSYS Runtime to limit the optionsavailable to a user.

1. When asking questions: QUIT is eliminated from themenus and ignored.

2. In the display of rules: the options to see what is known,examine choices, scroll and jump to other rules are eliminatedfrom the menus and ignored.

3. In the display of the results: the options to display all,display greater than, print, change sort method and quit are alleliminated from the menu and inactive.

This option is useful when creating expert systems for users thatmight be confused by more advanced options and where you wish toonly have the minimum functions available.

LIMITOPTIONS applies only to the Runtime and has no effect onthe editor.

For more information, see the Control of Runtime Menu OptionsCommand Line Options.

E - CONFIGURATION OPTIONS 23

Page 231: Manual Exsys

Command Line or .CFG Option

Turns Off Loop Error Checking

NOCHECK

This command prevents EXSYS from performing loop errorchecking during a run. This slightly increases speed, but isdefinitely not recommended for use during development since looperrors are difficult to detect without error checking and can lead toincorrect conclusions.

Loop errors should be found and corrected in a knowledge base.The lock on error checking is intended for use only when theknowledge base has been fully developed and is free of loop errors.

Displays Choices Without Sorting by Value

NO_CH_SORT

This option doesn’t allow EXSYS to display the choices sorted inorder of their final, assigned confidence. Instead, the choices aredisplayed in the numeric order of the choices themselves. Onlychoices over the threshold value will be displayed. For example,suppose the first choice, CHOICE1, has a value of 3 and the secondchoice, CHOICE2, has a value of 5. Normally, CHOICE2 would bedisplayed before CHOICE1 in the list because its final confidencevalue is higher. However, with the NO_CH_SORT option,CHOICE1 will be displayed first because it is the first choice in thelist over the threshold value. This is useful when the numeric orderof the choices is significant.

E - CONFIGURATION OPTIONS 24

Page 232: Manual Exsys

Command Line or .CFG Option

Switches Off Color Display

NOCOLOR

This command switches color off and forces the program to run inmonochrome. This command is not needed if you are using amonitor attached to the IBM monochrome display card, but it maybe necessary if you are using a monochrome monitor attached to acolor display card. Some monochrome monitors are unreadablewhen color text is sent to them.

This command also should be used when running on the MacintoshPowerbook.

Prevents Deletion of RETURN.DAT AfterReading

NODELETE

After EXSYS reads the data returned from an external program, iterases the file that returned the data. This prevents EXSYS frominadvertently reading the file again the next time an externalprogram call does not return data. If you do not want toautomatically delete the file returning the data, use the configureoption NODELETE.

This applies to RETURN.DAT or another file name if theRETURN= command has been used.

E - CONFIGURATION OPTIONS 25

Page 233: Manual Exsys

Command Line or .CFG Option

Prevents Display of Results at Any Time

NO_DISPLAY

This option prevents EXSYS from displaying results at any time.The screen will immediately go to the "RUN AGAIN?" question.This should be used with the RERUN=Y or RERUN=N configureoption described below. This option can be used to force restartingwithout showing results. Otherwise, a .OUT or .CMD file would beneeded to do this.

Disables Option to Use Passwords

NO_PASSWORD

If the NO_PASSWORD option is used, EXSYS will not ask for apassword when saving rules. All rules will be saved unencrypted.

If you never use passwords, put the NO_PASSWORD command inthe EDITXSP.CFG file.

E - CONFIGURATION OPTIONS 26

Page 234: Manual Exsys

Command Line or .CFG Option

Eliminates Starting Questions

NOQUESTIONS

This option prevents the Runtime program from asking users if theywish information on running EXSYS, or if they want to have therules displayed. The program simply displays the splash screen,then begins executing rules.

This command has no function in the Editor.

Do Not Display the Title and Author

NOTITLE

EXSYS Professional normally displays the title and author of asystem before the program is run. Adding the NOTITLE commandsuppresses this display and the system immediately starts running.

E - CONFIGURATION OPTIONS 27

Page 235: Manual Exsys

Command Line or .CFG Option

Prevents Display of Values Assigned toChoices

NO_VALUES

This command does not allow EXSYS to display any values forchoices in the final result screen. Only the values for qualifiers andvariables will be displayed. This is useful if all you need to know iswhich choices were selected, not the values assigned to them. Insome cases, the display of these values may actually confuse end-users. However, the end-user still has all the options for askingHOW.

E - CONFIGURATION OPTIONS 28

Page 236: Manual Exsys

Command Line or .CFG Option

Prevents Backward Chaining on SimpleExpressions

NOVARCHAIN

This command doesn’t allow EXSYS to backward chain expressionsof the type

[X] is given the value [X] + n[X] is given the value [X] - n[X] is given the value [X] * n[X] is given the value [X] / n

(where n can be any constant).

Backward chaining on large numbers in expressions similar to theone displayed above, can result in very long chains that use up theavailable stack space.

Note: This option should be used with caresince [X] must have a value assigned to itprior to encountering this expressionthrough initialization or any otherassignment.

E - CONFIGURATION OPTIONS 29

Page 237: Manual Exsys

Command Line or .CFG Option

Allows Choices with No Value Set to TestFalse.

NULLCHOICE

When a choice is used in the IF part of a rule, EXSYS attempts todetermine a value for the choice to test if the condition is true. If novalue for the choice can be derived, EXSYS issues an error messagebecause the condition is indeterminate. This is a good idea ingeneral, but there are some systems that operate on the principle thatchoices which don’t receive values are assumed to be false. Thiscan be a valid way to approach some problems. However, it is betterto not rely on undefined choices in the IF part.

The NULLCHOICE option turns off error messages if conditionchoices have no values. Such choices set the condition to FALSE.

Note: This option should be used withcaution, since it disables error messagesand can result in actual errors remainingundetected.

E - CONFIGURATION OPTIONS 30

Page 238: Manual Exsys

Command Line or .CFG Option

Changes the Name of the File Used to PassData to External Programs

PASS=filename

This option changes the name of the file that is used to pass data toexternal programs from EXSYSP or EDITXSP. When an externalprogram is called, data can be passed to the program in a file. Thedefault name of the file is PASS.DAT. If it you want to change thename of this file, use the PASS= command. Once the name ischanged, it applies for the entire run and must be used in all calls toexternal programs that pass data.

For example, passing data on a RAM disk is much faster thanpassing it on a conventional disk. For example, if you want to passdata on a RAM disk labeled drive D, but still want to use the namePASS.DAT., use the command

PASS=D:PASS.DAT.

If you redefine the file in which data is passed, be sure to modify thecalled program so it knows where to look for the data that is beingsent.

E - CONFIGURATION OPTIONS 31

Page 239: Manual Exsys

Command Line or .CFG Option

Load Password from Command Line or.CFG File

PASSWORD=key

The PASSWORD= command allows a password to be passed into afile. This tends to defeat the purpose of a password, but is usefulwhen several expert systems will be called sequentially from a batchfile. The password can be entered when the batch file is called. Thepassword is then passed to each expert system as a replaceableparameter. For example, the following DOS batch file would callthree expert systems with the same password.

EXSYSP SYSTEM1 PASSWORD=%1EXSYSP SYSTEM2 PASSWORD=%1EXSYSP SYSTEM3 PASSWORD=%1

The %1 in the batch file would be replaced with the parameterentered after the batch file name. For more information onreplaceable parameters in batch files, see your DOS manual.

The PASSWORD= command can also be used when calling EXSYSfrom another program. This enables you to have an encrypted filewith the password supplied by the other program. This prevents theknowledge base from being run by any source other than yourstarting program.

E - CONFIGURATION OPTIONS 32

Page 240: Manual Exsys

Command Line or .CFG Option

Reads Custom Help File when Rulesare Read

READHELP

This command is used with custom help files. (See Section I12 forinformation on custom help files).

When a user inputs ? in response to a request for information,EXSYS checks to see if information on the qualifier or variable is inthe custom help file <knowledge base name>.HLP.

The file is rapidly examined and only read once since file pointersare set during the read. While this process is rapid, it does takeabout 1 or 2 seconds per 10k of custom help file to reach the end ofthe file. In some cases you may want to have the examination of the.HLP file and the setting of pointers be performed when the rules areread in. The READHELP command tells EXSYS to read the .HLPfile when the rules are read and it also sets the file pointers at thesame time. Calls to the custom help file are then almostinstantaneous.

When this command is used with the Editor, EDITXSP.EXE, the.HLP file is examined and the file pointers are set whenever theRUN option is selected. This allows modification of the .HLP filebetween runs by using the <Ctrl-X> command to go to the operatingsystem to modify the .HLP file and then return to EDITXSP.

E - CONFIGURATION OPTIONS 33

Page 241: Manual Exsys

Command Line or .CFG Option

Recovers Data Saved Previously with QUIT

RECOVERRECOVER=<filename>

This option tells EXSYS that you may wish to recover data savedwith the QUIT command during an earlier run. If the RECOVERcommand is used, the menu option Recover Input under theQuestions menu will be checked. At the start of a run you will thenbe asked for the filename of the file that contains the saved data. Theprogram will read in the data and, after displaying the starting titlescreens, return to where you left off. The RECOVER command canalso be used with the filename RECOVER=<filename>.

In this case, without asking the user, the program automaticallyrecovers the input saved in the file <filename> and begins the runimmediately where it left off earlier under the QUIT command.

In the Editor, the recover option can be selected by selecting themenu option Recover Input under the Questions menu prior to arun.

The RECOVER command is REQUIRED to recover data in theRuntime.

E - CONFIGURATION OPTIONS 34

Page 242: Manual Exsys

Command Line or .CFG Option

Turns Off DISPLAY Command During"Change and Rerun"

REDISPOFF

When the CHANGE AND RERUN command is selected at the endof a run, all the rules that are used during the rerunning of theknowledge base and all valid rules fire. If those rules haveDISPLAY( ) commands in them, the text will be displayed on thescreen. In some expert systems, you may want to turn off theDISPLAY( ) commands during CHANGE AND RERUNoperations.

The REDISPOFF command prevents EXSYS from runningDISPLAY commands encountered in the rules during a CHANGEAND RERUN. This is useful if only the final conclusion isimportant and the DISPLAY commands are not directly relevant tothe conclusions being tested.

If this command is not used, the default is to run the DISPLAYcommands in change and rerun.

E - CONFIGURATION OPTIONS 35

Page 243: Manual Exsys

Command Line or .CFG Option

Releases Memory Used for String Variables

RELEASE_STRINGS

When EXSYS assigns values to string variables there is a smallportion of memory that is not released and is lost. This is due to theway certain operations (CHANGE AND RERUN and UNDO) areperformed and the need for data in other operations. Normally, theamount of memory lost per cycle is about the size of the stringsbeing assigned and is inconsequential. However, if a system makesextensive use of string variables and will cycle hundreds orthousands of times, the memory loss can become significant.

This is very rarely a problem, but the RELEASE_STRINGScommand prevents this small amount of memory from disappearing.Unfortunately, RELEASE_STRINGS prevents UNDO andCHANGE AND RERUN from working since they both require thatthe earlier data be available. The RELEASE_STRINGS optionallocates memory only once for all string variables. The memory isreleased when the run finishes. CHANGE AND RERUN andUNDO cannot be used with this option. The default maximumstring length is 256 characters. If this needs to be changed useRELEASE_STRINGS=<max length>.

For example, RELEASE_STRINGS=1000 would allow 1000character strings. Strings longer than the maximum are truncatedand null terminated. Remember, each string variable will have thismuch memory allocated for it, so try to use the minimum. If youhave 50 string variables, but the longest string that will be input is20 characters, RELEASE_STRINGS=20 will use only 1k ofmemory, while just RELEASE_STRINGS will use over 12k (50 *256).

The release strings options should rarely be needed. If it is not used,the minimum amount of memory will be used by EXSYS.

Note: The RELEASE_STRINGS optiondisables the CHANGE AND RERUNand UNDO functions that require thememory not be released.

E - CONFIGURATION OPTIONS 36

Page 244: Manual Exsys

Command Line or .CFG Option

Changes the Name of the ReportSpecification To Be Used

REPORT=<filename>

The default report generator specification associated with aknowledge base is <knowledge base filename> .OUT. TheREPORT= command allows a different report specification file beassigned to a knowledge base.

If there is a knowledge base named TEST, the default reportspecification would be in the file TEST.OUT. You could assign adifferent report specification named OTHER.RPT with

REPORT=OTHER.RPT

in the command line or configure file.

Note: This command effects only the reportproduced at the end of a run. It does noteffect reports produced as a result of rulesfiring.

E - CONFIGURATION OPTIONS 37

Page 245: Manual Exsys

Command Line or .CFG Option

Turns off Report Generator During "Changeand Rerun"

RERPTOFF

When the CHANGE AND RERUN command is selected inEXSYS, the report generator will be called at the end of the run if areport specification file is present. In some expert systems, youmany to not run the report generator during CHANGE ANDRERUN operations since it might overwrite the original data.

When used in the command line or a .CFG file, this commandprevents EXSYS from running the report generator during a changeand rerun operation. This is useful in allowing a user to experimentwith CHANGE AND RERUN without affecting the file originallyproduced by the report generator.

If this command is not used, the default is to run the ReportGenerator in CHANGE AND RERUN.

E - CONFIGURATION OPTIONS 38

Page 246: Manual Exsys

Command Line or .CFG Option

Changes the Default to Rerun Rules at End

RERUN

When EXSYS finishes a run, the user is asked if he wishes to rerunthe rules. The default for this option is NO. In some cases thesystem may be designed to rerun the rules many times. TheRERUN command changes the default to YES. The user can stilloverride the default value of YES.

RERUN=YThis prevents Professional from asking the user if he wishes to runthe system again. ESXYS instead assumes an answer of YES andautomatically restarts after the results screen.

RERUN=NThis doesn’t allow EXSYS to ask the user if he wants to run thesystem again. EXSYS instead assumes an answer of NO andautomatically exits (runtime) or returns to edit mode (editor) afterthe results screen.

E - CONFIGURATION OPTIONS 39

Page 247: Manual Exsys

Command Line or .CFG Option

Changes the Name of the File Used toReturn Data from External Programs

RETURN=filename

This option changes the name of the file used to return data toEXSYS from an external program. The default name that will beused if this option is not selected is RETURN.DAT. If you arecalling a program that supplies its own file extension or if for somereason you want to return data in a file with another name, use theRETURN= command to define the new default name. Only onename can be used in an expert system. If you change the file name,that file must be used for returning data from all external programcalls. The RETURN= command can also be used to change thedefault drive that data is passed on. It is often desirable to pass dataon a RAM disk for maximum speed.

For example, if you have a RAM disk defined as drive D, and youwant to pass data on D in a file TRANS.DAT use the command

RETURN=D:TRANS.DAT

in either the command line or a configure file.

Note: Make sure that the external programcalled by EXSYS writes its data to thissame file.

E - CONFIGURATION OPTIONS 40

Page 248: Manual Exsys

Command Line or .CFG Option

Changes How Rounding is Handled inCalculations

ROUND

EXSYS can be made to calculate the final value of a choice slightlydifferently than older versions of EXSYS. Older versions ofEXSYS use truncation of fractions. For example, if you are usingthe 0-10 confidence system and you assign it values 4, 6 and 7, theexact average would be 5.66666... EXSYS would display a finalvalue of 5 (truncated value) while 6 would be the rounded value.

ROUND causes rounding rather than truncating of the choice values.The default mode for EXSYS is truncation which providescompatibility with earlier versions. The command ROUND causesEXSYS to use the rounding mode.

Important Note: If you use ROUND withsome expert systems that rely on truncation,especially if you are testing on choice values,you could get different results when you usethe new version of EXSYS on programsdesigned under an older version of EXSYS. Ifthe ROUND option is not used, both the newversion of EXSYS and all its previousversions will provide the same results.

E - CONFIGURATION OPTIONS 41

Page 249: Manual Exsys

Command Line or .CFG Option

Writes a File of Information on RuleExecution, Data and Other Functions.

TRACETRACE = filename

When a knowledge base is run, you can turn on a trace (TRACE) ofthe execution of the rules as they fire. This can be very useful whentrying to debug a knowledge base. The trace file can be created ondisk or sent to the printer. The trace feature is turned on by entering

TRACE=filename

in the command line or a .CFG file. For example, if you start byentering

EDITXSP TEST TRACE=XXX.TRC

it will cause EDITXSP to write information to the file XXX.TRCwhen the rules are run. This command option allows you to collectinformation on which rules fired, when the rules fired, what valueswere set, and a wide selection of other information. The trace filethis creates is an ASCII file that can be printed or examined with anASCII editor. The TRACE from each run of the rules is appendedto the trace file until you restart the editor.

If a variable [X] is finishing with a different value than you believeit should have, you can search the trace file for [X] to see where thevalue of [X] is being set and why it is different from what youthought it should be. Using TRACE greatly simplifies checking forlogic errors in your rules.

E - CONFIGURATION OPTIONS 42

Page 250: Manual Exsys

Command Line or .CFG Option

Sets the Number of Times UNDO Can beCalled.

UNDO=#

EXSYS allows a user to change his mind and undo previousanswers. This is particularly useful when a user running a systemmakes a typographical error. The default is to allow the user tobackup a maximum of 3 steps. The command line option UNDOallows this maximum to be changed to anything from 0 to 10.

The command UNDO=0 will disable the UNDO function.

When UNDO is active, and there is some data to undo, the menuasking for input will include the item UNDO-<Ctrl-U>. Pressingthe Ctrl and U keys simultaneously will cause the program to backup one question. Doing the same thing again will back up anotherquestion, until the program no longer displays the UNDO menuoption.

The default value of 3 is usually appropriate, but there are timeswhen it might be desirable to change it. First, if an error in input isnot likely to be detected until more than 3 questions later, the limitshould be raised. Second, if memory is very limited, you may wantto reduce the number of steps the user can back up, or disable thefunction with UNDO=0. The UNDO option does have somememory overhead, which can become significant for large systemsclose to the memory limitations.

UNDO can only work within a single knowledge base. If an earlieranswer leads to exiting one module and starting another, EXSYSwill not be able to step back. Likewise, if the rules are being runfrom the command language, it can only back up within a singleRULES command.

E - CONFIGURATION OPTIONS 43

Page 251: Manual Exsys

Command Line or .CFG Option

Sets WORKING Screen Color

WKG_COLOR=color

The screen which displays the WORKING message has a cyanbackground. If several external programs are called that havedifferent backgrounds, you may want to change the backgroundcolor of the WORKING screen.

The color parameter is the name of the color to use.

color:REDGREENBLUECYANMAGENTAYELLOWBLACKDKGRAYGRAYLTGRAYWHITE

E - CONFIGURATION OPTIONS 44

Page 252: Manual Exsys

Command Line or .CFG Option

Sets Printer Width

WIDTH=#

This option causes the EXSYS Professional report generator to doword wrap on a line whose width is specified by # in characters perline. The default value is 80. This is useful when printing reportson wide paper.

E - CONFIGURATION OPTIONS 45

Page 253: Manual Exsys

Chapter F

Report Generator

EXSYS Professional has a built-in report generator. This enables theuser to control what data is output to a disk file or printer. Thereport specifications can include (among many other things) thecommands to print notes, choice, value or qualifier values, restart theprogram and exit to the operating system.

The report output specification is an ASCII file with the same filename as the expert system with an .OUT extension. For example, ifyou have an expert system named ENGINES, you would have twofiles on your disk— ENGINES.RUL and ENGINES.TXT. A reportgenerator specification would be put in a file called ENGINES.OUT.

The .OUT file is an ASCII file created with a text editor or a wordprocessor that can create ASCII files without additional controlcharacters. By having the .OUT file created and modifiable by texteditors, the end user (who has only the runtime program) will be ableto make modifications to the generated report. The EXSYSProfessional Editor is not used to modify the output specification.

F1: Commands

The report specification is made up of a series of commands, each ofwhich may cause one or more lines to be printed to the output file orcause some other operation to be performed. Many commands canhave several basic forms. These are listed in order of complexity.

Most report specification commands have a variety of optionscontrolled by "/" followed by a letter. The following list ofcommands gives the basic command first, followed by the availableoptions. If options are selected, they follow the basic command onthe same line.

Special Note to UNIX users: In the UNIXversion of EXSYS, replace the / in allcommands with -. For example, /D wouldbecome -D. This prevents confusion withUNIX path names.

F - REPORT GENERATOR 1

Page 254: Manual Exsys

Report Generator Command

Make a Beep Noise

BEEP

The BEEP command causes EXSYS to make a beep noise to alert auser.

F - REPORT GENERATOR 2

Page 255: Manual Exsys

Report Generator Command

Print Data on Choices

CC <choice #>C <choice #> <test exp>C <choice #> <test exp> <2nd test exp>C "choice text">C "choice text" <test exp>C "choice text"<test exp> <2nd test exp>C <test exp>C <test exp> <2nd test exp>

choice #—the number of the choice to be output.

choice text—a text string unique to a single choice. Thestring must be in quotes.

test exp.—the first test you should use to determine if thechoice should be output. The available tests are <,>,=,>=,<=,and <>. The type of test is followed by the integer value totest the choice against (e.g. =10, <5, >9). If no test expressionis specified, >0 is assumed.

2nd test exp.—an optional second test you should use todetermine if the choice should be output. The available testsare <,>,=,>=,<=, and <>. The type of test is followed by theinteger value against which EXSYS will test its choice. Thesecond test expression can be used to select choices only in aspecific range. For example, C >5 <8 would display thosechoices with final values of 6 or 7. There must be a spacebetween the first and second tests.

The choice commands print data on the final values provided to thechoices at the end of the run. The data is output to the current filethat has been opened with the FILE command.

There are several forms of the choice command that allowspecification of what choice and under what conditions informationwill be output. A variety of options allows printing of otherinformation when the choice meets the test criteria.

F - REPORT GENERATOR 3

Page 256: Manual Exsys

1. The simplest form of the command is just C.This outputs to the file (one choice per line) the choice text and finalvalue of all choices that received a value greater than 0.

2. The second form of the command,

C <choice #>

allows specification of a particular choice for output if the valuereceived is greater than 0. Only that particular choice will be output.The choice text and value will be output.

3. The third form of the command,

C <choice #> <test exp>or

C <test exp>

outputs the text and value of the choice only if the final value meetsthe test condition. If the choice number is omitted, all choices aretested against the test expression and all those passing the test will beprinted.

4. The fourth form of the command,

C <choice #> <test exp> <2nd test exp>or

C <test exp> <2nd test exp>

outputs the text and value of the choice only if the final receivedvalue meets both the first and second test conditions. If the choicenumber is omitted, all choices are tested against the test expressionsand all choices passing the test will be printed.

Options:

/T Output the text of the choice only. The value is notoutput.

/V Output the value of the choice only. The text of thechoice is not output.

/L Add an extra blank line following the output if the test istrue.

/S Causes EXSYS to suppress the line feed at the end ofthe line.

F - REPORT GENERATOR 4

Page 257: Manual Exsys

/"string"If the test(s) on the choice value is true, do not outputthe choice text or value but instead output the text inthe string. The string must be enclosed in double quotesand the first quotation mark must immediately followthe /.

/[var#]If the test(s) on the choice value is true, do not outputthe choice text or value, instead output the value ofvariable var#. The number of the variable must be inbrackets ( [ ] ), and the left bracket ( [ ) mustimmediately follow the / without any spaces in between.

/[var name]If the test(s) on the choice value is true, do not outputthe choice text or value, instead output the value of thevariable named in the brackets ( [ ] ). The name of thevariable must be in brackets, and the left bracket ( [ )must immediately follow the / without any spaces inbetween.

/Q Forces the program to terminate and exit to theoperating system if the test condition was met. If thecommand also causes output, the output will be writtenbefore exiting.

/G Goto a specified line if the conditional test is met. Seethe GOTO command in this section for moreinformation on branching.

/U Print the choice only if it had no value assigned (no rulesfired which assigned a value to the choice). Thisautomatically does a /T, since there is no value to output.This can be combined with other options such as /".

Examples:

C will cause the text and final value of all choices withvalues greater than 0 to be sent to the output file.

C2 = 10 will cause the text and value of choice 2 to be sent tothe output file if the final value of choice 2 is 10.

C "Part 1234"will cause the text and value of the choice whose textcontains "Part 1234" to be sent to the output file.

F - REPORT GENERATOR 5

Page 258: Manual Exsys

C4 >7 /[9] will output the value of variable 9, either numeric, stringor text, if choice 4 received a value greater than 7.

C4 >7 /[X]will output the value of variable [X], either numeric,string or text, if choice 4 received a value greater than 7.

C >=5 <=8 /Twill cause only the text (not the value) of all choices thatreceive values greater than or equal to 5, but less thanor equal to 8, to be sent to the output file.

C4 >9 "THE DATA IS GOOD" /Lwill cause the text "THE DATA IS GOOD" to be sentto the output file if choice 4 has a final value greaterthan or equal to 9 and then an extra blank line will beadded.

C5 /V will cause the final value of only choice 5 to be sent tothe output file.

F - REPORT GENERATOR 6

Page 259: Manual Exsys

Report Generator Command

Close a File for Display

CLOSE

This command closes an open file without opening a new one. Thiscommand is only needed with the DISPLAY command whichrequires that the file be closed. The FILE command or the end ofthe report specification will also close an open file. With the CLOSEcommand, a file can be created, closed and displayed without havingto create extra files. For example,

FILE XXXcommands....CLOSEDISPLAY XXX

WARNING: Do not execute reportgenerator commands other than DISPLAYafter a CLOSE command without firstexecuting another FILE command to opena file.

F - REPORT GENERATOR 7

Page 260: Manual Exsys

Report Generator Command

Display a File in a Window

DISPLAY <filename> <options>DISPLAY [string variable] <options>

filename—the name of the file to display.

string variable —a string variable which has a value that isthe name of the file to display.

Options/C - File to display uses GUI Custom ScreenCommandsThe /C option should be used if the file to displaycontains Custom Screen Commands. See chapter I fora discussion of the GUI Custom Screen Language.

/N - No wait after screen is displayedThe /N option allows the DISPLAY command to displaythe requested file in a window and immediately continueprocessing. This can be useful for report files that arecreated and displayed. By using the /N option, severalreport data windows can be simultaneously active.

/S - Small textThe /S option causes the DISPLAY command to displaya text file using a small font. The default is to use alarger font. This option only applies to ASCII files.

/F - Fixed size fontThe /F option causes the DISPLAY command to displaya text file using a fixed size font. This is useful foraligning columns of data. The /S and default fonts areproportionally spaced and aligning data can be difficult.This option only applies to ASCII files.

The DISPLAY command displays the contents of an ASCII file orCustom Screen Language Command file on the screen. Users cango forward or backward in the file as they examine it. When theyare finished reading the file, the report generator function continues.

1. The first form

DISPLAY <filename>

allows the name of the displayed file to be explicitly specified.

F - REPORT GENERATOR 8

Page 261: Manual Exsys

2. The second form

DISPLAY [string variable name]

allows a variable to set the name of the file to display. In this way, theknowledge base can set the name of the file to be displayed.

The DISPLAY command is very useful for displaying the reportproduced by the report generator to the user.

Important note: When displaying the fileproduced by the report generator, close thefile before displaying it.

Examples:

DISPLAY INFO1.T

displays the contents of the ASCII file INFO.T for the user to read.

FILE F1.. (report generator commands).CLOSEDISPLAY F1

creates a file F1 containing output from the report generatorcommands. The file F1 would be closed by the CLOSE command.The DISPLAY command would then display the contents of therecently created report on the screen or terminal. The CLOSEcommand must be used to close F1 before it is displayed.

DISPLAY SCR1.SCR /C

displays the file SCR1.SCR which contains Custom ScreenCommands.

F - REPORT GENERATOR 9

Page 262: Manual Exsys

Report Generator Command

Exit to the Operating System

EXIT

The EXIT command forces EXSYS to close the output file and exitto the operating system. This is useful when EXSYS is used in abatch mode with other programs. The EXIT command makes iteasy to run EXSYS, send the results to a file, exit EXSYS and thenuse the batch file to call other programs which will use the data file.

F - REPORT GENERATOR 10

Page 263: Manual Exsys

Report Generator Command

Select the Output File

FILE <filename>

This command should be the first one in a report specification. It tellsthe program which file it should direct its output toward. If the FILEcommand appears again in the report specification, the first file willbe closed and all subsequent output will be to the new file. Thecurrent contents of the existing file to be opened are lost unless youuse the /A option.

The file name can contain a drive designator and path. To sendoutput to a printer attached to a PC, make the file name LPT1.

Any open output files will be closed when the end of the reportspecification is reached. It is not necessary to have a final FILEcommand to close files.

The <filename> may be any legal filename or logical device name.For PC machines using MS-DOS, names such as LPT1, PRN, CON,COM1:, AUX are legal. Depending on the version of DOS you areusing, you may or may not need to add a colon ( : ) after devicenames.

Options: /A —opens the file for output with the data appended to the

existing contents of the file. If the file does not exist, the filewill be created. If /A is not added, the contents of the existingfile will be lost and replaced by the new data.

Example:

FILE B:REPORT.A.. (output commands).

FILE C:\DATA\LIST.RPT /A.. (output commands).

FILE LPT1.. (output commands).

F - REPORT GENERATOR 11

Page 264: Manual Exsys

would open the file B: REPORT.A, deleting any previous data in thisfile. All data would be sent to this file until the second FILEcommand is reached. This second FILE command would close thefile B: REPORT.A and open the file C:\DATA\LIST. RPT. Since thesecond FILE command used the /A option, the new data will beappended to the data already in the file. All data would be sent toC:\DATA\LIST.RPT until the third FILE command. The third FILEcommand would close file C:\LDATA\LIST.RPT and open theprinter attached to the LPT1 port of the PC for the subsequentoutput.

F - REPORT GENERATOR 12

Page 265: Manual Exsys

Report Generator Command

Print Text Only for First Set of Data inDATALIST

FIRST "string"

When the FIRST command precedes text in double quotes, the textwill be printed only during the processing of the first record beingexamined with the DATALIST command. This allows a title to beput on reports without having the text print each set of data in aDATALIST file. If there is no datalist, the FIRST command behavesas a simple, quoted string.

Example:

FILE XYZ.RPT /AFIRST "REPORT OF EXPERT SYSTEM"CRESTART

could be used with a DATALIST command to examine a series ofsets of data. The title "Report of Expert System" would be printedonly once. The choices would be printed for each set of data in theDATALIST.

F - REPORT GENERATOR 13

Page 266: Manual Exsys

Report Generator Command

Unconditional and Conditional Branches

GOTO and /G:

EXSYS Professional supports conditional and unconditional GOTOcommands in the report generator. The line which GOTO willtransfer to is indicated by a single line that starts with a colon ( : ),followed immediately by the label name.

The command GOTO LABEL will transfer execution to the linefollowing the line marked “label.” For example:

commands...:XXXcommands...GOTO XXX

will cause the execution to return to the line ":XXX" in the reportfile.

Alternatively, the /G:label option can be used with the C, Q or Vcommands in the report generator to produce a conditional GOTO.In this case, the GOTO will be executed only if the C, Q or Vcommand is valid. For example:

V1 > 4 /G:end

will transfer the line ":END" only if variable 1 has a value greaterthan 4.

By combining conditional and unconditional GOTO commands, thereport file can be made much more flexible.

Note: If you use GOTO to jump over aFILE command, the FILE command willnot be executed.

F - REPORT GENERATOR 14

Page 267: Manual Exsys

For example, the report file

FILE FILE1...

GOTO XXX.

FILE FILE2..

:XXX..

would not open FILE2, but would continue writing to FILE1.

F - REPORT GENERATOR 15

Page 268: Manual Exsys

Report Generator Command

Print the Data Input by the User

INPUT

The INPUT command sends all the data input by the user to the fileopened with the FILE command. Data on all qualifiers and valuesasked for by the program or obtained from external programs will besent to the output file.

Options:

/L Adds a blank line after each line of data is output

F - REPORT GENERATOR 16

Page 269: Manual Exsys

Report Generator Command

Print the Notes and References

NOTENOTE <rule#>REFREF <rule #>

rule # —the number of the rule to print the note or reference from.

The NOTE and REF commands cause the report generator to printthe note or reference of a specified rule to the report file if the rulehas fired. The optional rule number can be left off, in which casenotes or references from all rules that fired will be printed to thereport file in the order of the rules.

This provides a convenient way to provide the information in thenotes and references to a user, even if rule display is turned off.

Example:

NOTEREF 4

would cause the printing of the notes from all rules that fired,followed by the reference from rule 4, if rule 4 fired.

F - REPORT GENERATOR 17

Page 270: Manual Exsys

Report Generator Command

Data on Qualifiers

QQ <qual#>Q <qual#> <test>Q "Qual name"Q "Qual name" <test>

qual #—the number of the qualifier to output. If the numberis omitted, all qualifiers are tested.

test—a qualifier is tested by checking to see if its values aretrue. The test condition is a list of the qualifier's values such asnumbers separated with commas (just like creating a conditionwhen building a rule). If any of the values specified in the testare set, the test is true. For example, Q2 1,3,7 would be trueif qualifier 2 has values 1,3 or 7 true. The test will be true ifany of the listed values are true.

Qual name—the name associated with the qualifier.

Note: This is not the text of the qualifier,but the name used to identify the qualifier.The name must be in quotes.

The qualifier command outputs the text of a qualifier with all thevalues that have been set to the file opened with the FILE command.

There are three main forms of the command.

1. The simplest form is just Q.

This outputs the text of all qualifiers that had values set.

F - REPORT GENERATOR 18

Page 271: Manual Exsys

2. The second form of the command is

Q <qual#>Q "Qual name"

This outputs the qualifier specified by number or name if any of itsvalues were set during the run. Any values set are also output.

3. The third form of the command is

Q <qual#> <test>Q "Qual name" <test>

This outputs the qualifier specified by number or name if any of itsvalues were set during the run and the set values match at least oneof those specified in the list of values in the test. Any set values arealso output.

Options:/L Adds a blank line after the qualifier is output.

/S Suppresses the line feed at the end of the line.

/"string"If the test is true, the qualifier/values are not output, butinstead the string in quotes is output.

/[var#]If the test(s) is true, do not output the qualifier/values,instead output the value of variable var#. The numberof the variable must be in brackets ( [ ] ) and the leftbracket ( [ ) must immediately follow the slash ( / )without any spaces in between.

/[var name]If the test(s) is true, do not output the qualifier/values,instead output the value of the variable whose name isspecified in the brackets ( [ ] ). The name of thevariable must be in brackets ( [ ] ) and the left bracket ([ ) must immediately follow the slash ( / )without anyspaces in between.

/Q forces the program to exit to the operating system if thetest condition was met. If the command also causesoutput, which will be written before exiting.

/D causes output of the data on the qualifier(s) to be in aform that can be read in with a DATALIST command.This makes it possible to have one expert system callanother and then pass data between them. Suchchaining of knowledge bases can be very powerful.

F - REPORT GENERATOR 19

Page 272: Manual Exsys

For example, suppose qualifier 7 is

THE COLOR IS:1. RED2. WHITE3. GREEN4. BLACK

and values 1 and 3 are chosen.

The report generator line Q 7 would output :

THE COLOR IS RED OR GREEN

However, the line Q 7 /D would output Q7 1 3 (a formthat could be read in with the DATALIST commandline option).

There can also be an optional number specifiedimmediately after the /D (no space between D and thenumber). This number will be used in the output of thedata as the destination qualifier number. This allows youto specify a different qualifier to be used when the datais read in by another expert system using DATALIST.To use the qualifier example above, the reportgenerator line Q 7 /D outputs Q7 1 3. However, theline Q 7 /D12 would output Q12 1 3. The 12 specifiedafter the /D caused qualifier 12 to be specified as thedestination of the data. This allows data from oneexpert system to be passed to another, even though thequalifier numbers do not necessarily match. If a numberis not specified after the /D, the number used will be thesame as the qualifier or variable specified.

See Chapter M on blackboarding for more informationon passing information between knowledge bases.

/G Go to a specified line if the conditional test is met. Seethe GOTO command in this section for moreinformation on branching.

/U Print the qualifier only if it did NOT have a valueassigned, (no rules fired which assigned a value to thequalifier, it was not asked of the user and no externalprogram assigned a value). This can be combined withother options such as /".

F - REPORT GENERATOR 20

Page 273: Manual Exsys

Examples:For these examples use qualifier number 6 with an associated name"COLOR" and four values:

Qualifier 6: The color is1 red2 white3 blue4 green

Q6 or Q "COLOR" causes the status of qualifier 6 to be output.

Q6 2,3 causes the status of qualifier 6 to be output if the statement“the color is white” or the statement “the color is blue” is true.

Q6 1 /"RED PAINT WILL BE NEEDED"causes the text REDPAINT WILL BE NEEDED to be output if the qualifier statement"The color is red" is true.

F - REPORT GENERATOR 21

Page 274: Manual Exsys

Report Generator Command

Restart the System

RESTART

The RESTART command resets all choices, qualifiers and variablesto their initial state at the beginning of a run. This is particularlyuseful in two cases.

1. Analysis of a data report—An EXSYS knowledge base can bedesigned so it sequentially analyzes many sets of data through the useof an external program or by the command line option DATALIST.In such a case, start the output specification with:

FILE filename /A

to have each new report appended to the existing report. End withRESTART to cause EXSYS to restart and run the next set of data.The program will end automatically when the end of the DATALISTis reached and EXSYS returns to the operating system.

2. Monitoring—An EXSYS expert system can be designed usingexternal programs to obtain data that monitors the status of aprocess. If no action is necessary, it is only necessary to restart therun. If action is necessary, data can be output, alarms can betriggered, and a variety of other actions can be performed.

F - REPORT GENERATOR 22

Page 275: Manual Exsys

Report Generator Command

Call an External Program

RUN <filename> <parameters>

The RUN command allows external programs to run from the reportgenerator. The filename can be any program executable from theoperating system.

The parameters can be constants or EXSYS variables. Theparameters can be any parameter that could be used in a RUN( )command from within EXSYS. See Chapter H for more informationon the RUN( ) command.

Options:

/C Causes the parameters to be passed as command linearguments. If the /C is not present, the parameters willbe passed in PASS.DAT.

/# Causes the first # arguments to be passed on thecommand line, with the rest passed in PASS.DAT.

See Chapter H on calling external programs for more /options.

For example,

RUN BASIC GRAPH1 /C

executes the basic program GRAPH1 from the BASIC interpreter.

RUN TEST [X] [Y] [Z]

runs the program TEST with the values of variables [X], [Y] and [Z]passed in PASS.DAT.

RUN TEST [X] [Y] [Z] /C

runs the program TEST with the values of variables [X], [Y] and [Z]passed in on the command line.

RUN TEST [X] [Y] [Z] /2

runs the program TEST with the values of variable [X] passed on thecommand line and the values of variables [Y] and [Z] passed inPASS.DAT.

F - REPORT GENERATOR 23

Page 276: Manual Exsys

Report Generator Command

Save the Input Data for a RECOVER

SAVEDATA <filename>

This command is the same as selecting the QUIT mode when theresults are displayed and you are entering the filename. The inputwhich is provided by the user and then used to obtain the conclusionsis stored in the file <filename> in such a way that it can be recoveredby the option to recover previously saved input. This is not the sameas the INPUT command which writes the user input to the specifiedfile as ASCII and which can not be read back into the program.

F - REPORT GENERATOR 24

Page 277: Manual Exsys

Report Generator Command

Print Text String

"text"

Placing a string in quotes causes the report generator to output thequoted text to the file opened with the FILE command. The stringmust start and end with a double quotation mark ( " ). The quotationmarks will not be output. A line feed will automatically be added tothe end of the line in the output file.

Example:

FILE CON:"The report is being produced"FILE XYZ.RPT .

.

.

Will write the message "The report is being produced" to the screen,then open the file XYZ.RPT for output. The message will stay on thescreen until the report specification is finished. This is a usefultechnique for giving the user status reports when very large reportfiles are used.

F - REPORT GENERATOR 25

Page 278: Manual Exsys

Report Generator Command

Print Data on Variables

VV <variable #>V <variable #> <test exp>V <variable #><test exp><2nd test exp>V <test exp>V <test exp> <2nd test exp>[variable name][variable name] <test exp>[variable name]<test exp><2nd test exp>

variable #—the number of the variable to output. If thenumber is omitted, all variables will be tested for output.

variable name—The name of the variable to output. Thename must be enclosed in brackets ([ ]).

test exp—A test to determine if the variable should be output.The available tests are >,<, =, >=, <=, and < >. The testexpression must be followed by either a numeric value (fornumeric variables) or a string in quotes (for string variables).If string variables are used, the validity of the test is based onalphabetical order.

2nd test exp—A second test to determine if the variableshould be output. The available tests are >,<, =, >=, <=, and< >. The test expression must be followed by either a numericvalue (for numeric variables) or a string in quotes (for stringvariables). If string variables are used, the validity of the test isbased on alphabetical order. This second test is used to selectvariables only within certain bounds. For example: V2 >23.5<78.4 would output the text and value of variable 2 only if itsvalue was between 23.5 and 78.4. There must be a spacebetween the first and second tests.

The variable command outputs the value of variables to the fileopened with the FILE command.

There are a number of forms of the variable command, most of whichhave the option of either specifying the variable by number or by name.

F - REPORT GENERATOR 26

Page 279: Manual Exsys

1. The simplest form of the command is just V. This outputs the textand value of all variables that received a value during the run. Thetext of the variable and the value will both be printed, unless optionsare selected. If a variable is a text only variable, it will be displayedonly if it was applied by a rule that fired.

2. The second form of the command,

V <variable #>or

[variable name]

specifies which variable is to be output. Both the text of the variableand the value will be printed, unless options are selected. If a variableis a text-only variable, it will be displayed only if it was selected by arule that fired.

3. The third form of the command,

V <variable #> <test exp>or

V <test exp>or

[variable name] <test exp>

specifies which variable is to be output and sets a test condition whichthe variable must meet to be printed. Either numeric or stringvariables can be tested. The text of the variable and the value willboth be printed, unless options are selected. If a variable is a textonly variable, it will be displayed if it was selected by a rule that fired.If the variable number is omitted, all variables will be tested againstthe test expression and all variables passing the test will be printed.

4. The fourth form of the command,

V <variable #> <test exp> <2nd test exp>or

V <test exp> <2nd test exp>or

[variable name] <test exp> <2nd test exp>

specifies which variable is to be output and sets two test conditionswhich the variable must meet to be printed. Either numeric or stringvariables can be tested. The text of the variable and the value will beprinted unless options are selected. If a variable is a text-onlyvariable, it will be displayed if it was selected by a rule that fired. Ifthe variable number is omitted, all variables will be tested against thetest expressions, and all variables passing the tests will be printed.

F - REPORT GENERATOR 27

Page 280: Manual Exsys

Options:

/T Output the text of the variable only, not the value.

/V Output the value of the variable only, not the text.

/L Add an extra blank line after the output.

/S Suppress the line feed at the end of the line.

/"string"If the test is true, do not output the variable, but insteadoutput the quoted text in the string. The string must beenclosed in double quotes and the first quotation markmust immediately follow the slash (/).

/[var#]If the test(s) is true, do not output the variable text orvalue, instead output the value of variable var#. Thenumber of the variable must be in brackets ([ ]), and theleft bracket ( [ ) must immediately follow the slash (/)without any spaces in between. This is very useful forprinting identifiers, such as a person's name, if they meetthe test conditions specified.

/[var name]If the test(s) is true, do not output the variable text orvalue. Instead, output the value of the variable named inthe brackets ([ ]). The name of the variable must be inbrackets, and the left bracket must immediately followthe slash (/) without any spaces in between.

/Q Forces the program to exit to the operating system ifthe test condition was met. If the command also causesoutput, the output will be written before exiting.

/D Output data on variables in a form that can be read inwith a DATALIST command. This makes it possible tohave one EXSYS expert system call another and passdata between them. Such chaining of knowledge basescan be very powerful.

For example, suppose variable 3 has a value of 7.9. Thereport generator line V 3 /D would output V 3 7.9to the output file rather than printing the text to describevariable 3 followed by the value.

There can also be an optional number specifiedimmediately after the /D (no space between D andnumber). This number will be used in the output of the

F - REPORT GENERATOR 28

Page 281: Manual Exsys

data as the destination variable number. This allows youto specify a variable to send the data into. To use theexample above: the report generator line

V 3 /D

outputs V 3 7.9. However, the line V 3 /D12 wouldoutput V 12 7.9. The 12 specified after the /D caused12 to be specified as the destination of the data. Thisallows data from one expert system to be passed toanother, even though the variable numbers do notnecessarily match. If a number is not specified after the/D, the number used will be the same as the variablespecified.

See Chapter M on Blackboarding for more informationon passing data between knowledge bases.

/F-m.nFormats the output variable value with formatcontrolled by the parameters. This can be used only fornumeric variables.The optional hyphen – causes left justification. Thedefault is right justification.

The optional parameter m is the total field width.

The optional parameter n is the number of placesdisplayed right of the decimal point.

For a variable with value 1234.5678:/F6.0 outputs 1235/F6.2 outputs 1234.57/F10.3 outputs 1234.568

/E prevents EXSYS from printing the equal sign betweenthe text and the value of the variable.

/G Go to a specified line if the conditional test is met. Seethe GOTO command in this section for moreinformation on branching.

/U Print the variable only if it did NOT have a valueassigned (No rules fired which assigned a value to thevariable, it was not asked of the user and no externalprogram assigned a value.) This automatically does a /T,since there is no value to output. This can be combinedwith other options such as /".

F - REPORT GENERATOR 29

Page 282: Manual Exsys

/, Commas can be inserted into a numeric variable value inthe report generator by using the /, option. This wouldnormally be done in conjunction with the /F#.# option toformat the output. For example, a variable [X] equal to123456578.9 could be output various ways:

Report Generator Command Output[X] 12345678.9[X] /, 12,345,678.9[X] /F15.2 12345678.9[X] /F15.2 /, 12,345,678.9

Note: if there are preceding format spacesfrom a /F#.# command, the /, command willremove one space for each comma added.This preserves the total field widthproduced by the /F command. Enoughextra spaces must be left to allow for thecommas. If there is not enough space, thetotal field width will expand.

Examples:

Vcauses the text and value of each variable to be output.

V2 > 1.5 /Tcauses the text of variable number 2 to be output if the value of thevariable is greater than 1.5.

V4 <0 /[8]outputs the value of variable 8 if the value of variable 4 is lessthan 0.

V4 <0 /[X]outputs the value of variable [X] if the value of variable 4 is less than0.

V7 = "ABCD" /Lcauses the string variable number 7 to be printed if its value string isABCD, then a blank line will be output.

[X] /Vcauses the value of the variable [x] to be output.

[X] >= 2.7 /"THE VALUE WAS HIGH"causes the string THE VALUE WAS HIGH to be output if the valueof the variable [X] is greater than or equal to 2.7.

F - REPORT GENERATOR 30

Page 283: Manual Exsys

Examples:

FILE B:RESULTS"RESULTS OF EXSYS RUN"C > 2"USER INPUT"INPUT

will cause EXSYS to:

1. Open the file B: Results.2. Send the text RESULTS OF EXSYS RUN to the file.3. Send the text and value of each choice with a value greater than 2

to the file.4. Send the text “USER INPUT.”5. Send all the input data obtained from the user.

FILE C:\ANALYSIS\TEST.RPT /AV3 /V /LC = 10 /T"*********"FILE LPT1V3 /VC > 5BEEPEXIT

will cause EXSYS to:

1. Open the file C:\ANALYSIS\TEST.RPT so output is appended to the end of the file, if one exists.2. Output only the value of variable 3, followed by a blank line.3. Output a list of only the text of all choices with values of 10.4. Output "*********" to separate records in the file.5. Close the first file and open the printer for output.6. Print the value of variable 3 to the printer.7. Print all choices that had values greater than 5.8. Make a beep sound to alert the user.9. Exit EXSYS and return to the operating system.

FILE LPT1FIRST "POSSIBLE CANDIDATES"FIRST "____________________"FIRST " "C3 >8 /[6]RESTART

This would be used with a DATALIST command line option toprovide data.

F - REPORT GENERATOR 31

Page 284: Manual Exsys

It causes EXSYS to:

1. Open the printer for output.2. After analyzing the first record, EXSYS prints the report title

"POSSIBLE CANDIDATES" (This will be printed for the firstrecord only).

3. Underline the title.4. Skip one line.5. Print the value of variable 6 (possibly a name) if choice 3 received

a value > 8.6. Read the next record of data and restart the analysis.

F - REPORT GENERATOR 32

Page 285: Manual Exsys

Chapter G

Internal Commands andData Acquisition

In general, EXSYS Professional does not care what text you enterfor a qualifier or variable, provided you don't duplicate the names ofthe special commands that EXSYS recognizes. These internalcommands can be used to perform a variety of functions, controlEXSYS rule execution and interface to external sources of data.

The EXSYS Internal commands can be associated with a qualifier orvariable, added as part of the THEN or ELSE part of a rule or (inmost cases) included in the command file (<knowledge basename>.CMD).

G1: Internal Commands in a Rule

To add a command in the THEN or ELSE part of a rule, click on theCommand button in the rule editing window. Note, commands maynot be added in the IF part of a rule, but may be associated with aqualifier or variable that is tested in the IF part.

G - INTERNAL COMMANDS 1

Page 286: Manual Exsys

Rule Title and Number

IF:Qualifier

Var. / Math

Choice

Command

Repeat

IF PartTHEN PartELSE Part

AND ORNew OR

NoteReferenceName

Insert

O KChange

Delete

And/Or

CancelNextPrev

G2: Commands Used for Data Acquisition

Data acquisition commands may also be associated with a qualifier orvariable. Within the editing screens for the qualifier and variable,clicking on the Data Acquisition button will allow you to associatecommands that return data with the qualifier or variable. Onlycommands that can provide the data needed by the qualifier orvariable can be associated. Commands the perform actions--CLEAR,EXIT, etc. may not be associated with a qualifier or variable.

G - INTERNAL COMMANDS 2

Page 287: Manual Exsys

Add / Edit Qualifier

O K

Cancel

Qualifier ## NEW QUALIFIER Nam e:

QUALIFER TEXT

ASSOCIATED VALUE LIST

VALUE WORK WINDOW

Edit Replace Ca ncel Edit Add Delete

Display at endLimit input values to: Default Value:

Conf. Options

Data Acqu.

Add / Edit Variable

O K

Name:

Prompt:

NumericStringText Only

Display at end

Initialize:Upper Limit:Lower Limit

Data Acquisition

Conf. OptionsCancel

G - INTERNAL COMMANDS 3

Page 288: Manual Exsys

G3: Internal Command WindowIn either case, the Internal Command window will assist you inbuilding the desired command. In many cases, the same syntax youuse for the command can also be used in the command language,report generator and even custom screen language. The use of thecommands in this way is discussed in the section on the appropriatesubject.

Data Acquisition Commands

Direct Command Input

Run External Program

Lotus 123

dBase III Interface

Table Lookup

Display a File

Frame / Array Lookup

LINDO Interface

Report Generator

Clear Data or Rules

Stop Rule Exec.

O K

Cancel

The edit region at the top of the screen will display the command.This command can be edited directly, or its value can be createdusing the windows that build the commands. To guarantee correctsyntax for the commands, we recommend you use the individualcommand windows. To select a command window, click on thedesired command. When the command in the top edit box is correct,click on the OK button.

G3.1: Direct Command Input

Use direct command input if you know the exact command syntax toenter. A window is opened to enter the command. This is reallyabout the same as editing in the edit region of the general commandwindow. This is especially useful if you are editing an existingcommand and want to make a minor change. In general, however, itis better to use the individual command windows since the syntax ofsome commands can be complicated.

G - INTERNAL COMMANDS 4

Page 289: Manual Exsys

Internal CommandQualifier / Variable

THEN/ELSECommand File

Report Generator

Blackboard Interface

BB_RD(parameters)BB_WR(parameters)BB_DE(parameters)

Blackboard files can be used to share data between expert systemmodules.

See Chapter M for a full discussion of blackboard files and commandsyntax.

G - INTERNAL COMMANDS 5

Page 290: Manual Exsys

Internal CommandQualifier / Variable

THEN/ELSECommand File

Report Generator

dBase III Interface

DB_GK(parameters)DB_PK(parameters)DB_GN(parameters)DB_PN(parameters)

Four internal commands allow EXSYS to read or write directly fromdBase III files.

Note: Underlined items can be repeated multiple times.

Get data from db file by key:DB_GK(<db file>, <index file>, <index value>,<field name>, <address>)

Put data in db file by key:DB_PK(<db file>, <index file>, <index value>, <fieldname>, <var name>)

Get data from db file by record number:DB_GN(<db file>, <rec #>,<field name>, <address>)

Put data in db file by record number:DB_PN(<db file>, <rec #>,<field name>, <var name>)

<db file> The full name of the dBase III file to beused.

<index file> The full name of the file that has the indexof the <db file>.

<index value> The value to search for in the index.

G - INTERNAL COMMANDS 6

Page 291: Manual Exsys

<field name> The name of the field that containing thedata to be read from or the name of thefield to be written to.

<var name> The name of the EXSYS variable in [ ].The value of the variable will be read fromor written to the specified db field. Thevariable name ALWAYS applies to thefield name specified to its left.

<address> The item in which to store the obtaineddata. The item can be a variable, qualifieror choice. For a variable, use the name ofthe variable in [ ] For a qualifier, use "Q"followed by the number of the qualifier orthe name of the qualifier in quotes For achoice, use "C" followed by the number ofthe choice or a unique text string in quotes.There must NOT be any spaces in thestring between the C, V, or Q and thenumber or quotation mark.

<rec #> The number of the db record to work with.

The database file name, index name and index variable may be stringvariables that are set by expert system. <var name> must be anEXSYS variable.

Since the field name and associated variable may be repeated asmany times as desired, multiple fields from the same record can bepassed or returned on a single call.

G - INTERNAL COMMANDS 7

Page 292: Manual Exsys

dBase Command Window

The window for building dBase Interface commands allows you tobuild commands that retrieve multiple data items with a single call.

dBase Data Acquisition

PUT data by KEY value PUT data by RECORD NUMBER

DB Filename:

Index Filename

Index Value

Record Number

FIELD containing data to read

EXSYS Address to put data in

O K Prev. Field Next Field Cancel

GET data by KEY value GET data by RECORD NUMBER

To build a dBase internal or data acquisition command, select GET orPUT by KEY or Record Number then enter the database filename.If an index file is used, enter the index filename and index value usedto select a record. If record numbers are used, enter the recordnumber used to select a record. Fields in the record and EXSYSaddresses are used in pairs. Each field must have a correspondingEXSYS address. With GET, the value of the field will be put in theEXSYS address. With PUT, the value in the EXSYS address will beput in the field specified.

Enter the first pair of field and address names. To enter a secondpair in the same command, click on Next Field . The Field andEXSYS Address edit boxes will clear and you can enter another pair.This can be done repeatedly. To examine a field or variable pairalready entered, click on Prev Field . This will display the previouspair.

When all field or variable pairs have been entered, click on OK. Thegeneral Command window will return, with the dBase command inthe top edit window. When you click on OK again, the commandwill be added to the rule, qualifier or variable (depending on how thewindow was called.)

G - INTERNAL COMMANDS 8

Page 293: Manual Exsys

Use in Rules

In rules, dBase commands are usually used to set data as the result ofa rule firing. In some cases, a rule may also trigger a dBasecommand to get data into a particular variable. Since the commandsto get data have a variable associated with them, they can be calledindependently of a specific variable.

The following example,

IF......

THENDB_PN(parts.dbf, 5, price, [X])

will WRITE the value of variable [X] into field "price" of record 5 ofdatabase "parts" if the rule fires.

Use in a Variable

When a dBase command is associated with a variable, it willautomatically be called if a value for the variable is needed. Ratherthan asking the end user for the value, the call to dBase will be made.If a value for the variable is never needed in the system, the dBasecall will never be made.

To associate the dBase call with a variable, the dBase commandprecedes the text entered as the Prompt Text for the variable. ThedBase call will not be displayed when the prompt text is used inreports, final results, etc. For example, if we had a variable [X] witha prompt "The price is," we would associate a dBase call with thevariable by changing the prompt to:

DB_GN(parts.dbf, 5, price, [X]) The price is

If the value of [X] is needed, the program will READ the value offield "price" from record 5 of database "parts" into variable [X]. Ifneeded, there could be additional field and address pairs in theexpression to get more data from the record.

If the variable is a string variable, the value returned willautomatically be handled as a string--even if it contains numeric data.If the variable type is numeric, the value returned will automaticallybe converted to a numeric. Be sure to return string data (names,addresses, etc.) to string variables. If the data from the database is tobe used in numeric calculations, make sure it is returned to numericvariables.

When the data acquisition windows are used to build the command,the command will automatically be added to the prompt text.

G - INTERNAL COMMANDS 9

Page 294: Manual Exsys

Use in a Qualifier

The use of a dBase command in a qualifier is very similar to the usein a variable. The dBase command precedes the qualifier text. Thecommand will not be displayed when the qualifier text is used inreports, conclusions, etc. However, when a value for the qualifier isneeded, the dBase call will automatically be used.

For example, if we had a qualifier named "COLOR,"

The color is1 red2 blue3 green

and we wanted to get the color from the data base, we could change"The color is" to

DB_GN(parts.dbf, 5, part_color, Q "COLOR") The color is

When the qualifier's value was needed the dBase call wouldautomatically be made and the value in the field part_color in record5 would be used to set the qualifier named "COLOR."

The data returned from the database for qualifiers must be in theform of a string containing the numbers of the values to select. Ifmore than one number is returned, they must be separated by spacesof a comma. For example, if the database call returned "1,2" to aqualifier, it would set the first two values of the qualifier to be true. Ifit returned "3," it would set the third value to true.

When the data acquisition windows are used to build the command,the command will automatically be added to the qualifier text.

Use in Choices

The command text cannot be associated directly with a choice.Instead, dBase commands that assign values to choices must be in theTHEN /ELSE part of a rule or used in one of the other commandfiles. When a value is to be assigned to a choice, the data returnedfrom the database must be consistent with the confidence mode beingused. For example, if the mode is 0-10, the value must be an integerbetween 0 and 10.

The value returned will be combined with the other values given tothe choice by rules that fired. For example (in the 0-10 system), avalue of 10 assigned by a database call would lock the value at 10. Avalue of 5 would be averaged with any other values assigned to thechoice.

G - INTERNAL COMMANDS 10

Page 295: Manual Exsys

DB_GN(parts.dbf, 5, val, C 4)

will return the value of field "val" into choice 4.

Use in the Report Generator

In the report generator, dBase commands are usually only used towrite data out to a database file as part of the conclusion of thesystem.

Commands to get data can be used, but must be used with care sincethey can change the data used by the system and thereby confuse theresults. Commands to get data would usually only be used inconjunction with a command file to control the execution or to getdata that is only written out as part of the report and not used by therules.

For example, the following command in the report generator

DB_PK(parts.dbf, part.ndx, A567, price, [X], conf, C 7)

will WRITE the value of variable [X] into field "price" of the recordin database "parts," indicated in the index file "part.ndx" by the value"A567," and write the confidence value to choice 7 into the "conf"field of the same record.

Use in the Command Language

Database commands in the command language can be used tocontrol when data is obtained, rather than associating the dataacquisition commands with a specific qualifier or variable. This oftengives more control and is easier to read. There may also be dBasecommands at the end of the command file to write results back to adatabase.

Top Record Function

The EXSYS function TOPREC( ) returns information on the numberof records in a database file. This is particularly useful when runningan expert system against every record in a file. To call the functionin an expression, use

TOPREC(<filename>)

where <filename> is the name of the database file in quotes.

For example,

TOPREC("price.dbf")

G - INTERNAL COMMANDS 11

Page 296: Manual Exsys

would return the number of records in the database file "price.dbf."This function can be used like sin( ), cos( ) or any other EXSYSfunction in an expression. It can be used most effectively in thecommand language, such as in the following:

SET [I] 0WHILE ([I] <TOPREC("price.dbf")) RULES ALL REPORT DBRPT CLEAR ALL SET [I] ([I]+1)WEND

The above example would initialize the variable [I] to 0 then run therules against each record in a database. After each record, the valuesare cleared and [I] is incremented and checked against the totalnumber of records in the data base. If there is another record, therules are run again. Each run adds the report produced with thereport specification DBRPT. A simple command file like this can runan expert system against each record in a database to select thosewith particular characteristics and write them to a report.

G - INTERNAL COMMANDS 12

Page 297: Manual Exsys

Internal CommandTHEN/ELSE

Command File

Clear Out Known Data or Rules

CLEAR(....)

The internal command CLEAR( ) allows a qualifier, variable, choiceor rule to be reset to an unknown or unused state. Normally,EXSYS will only ask a qualifier or variable once and will only fire arule once in a run. There are cases, however, where it is desirable toclear user input or re-use a rule. The CLEAR command makes thispossible.

When the CLEAR command is encountered, EXSYS will reset therule, qualifier, variable or choice to its original unknown state or flaga rule as unused. This allows user input to be erased. If the qualifier,variable or choice is needed later during the run, it will be reasked orrederived from other rules. If a rule is reset with CLEAR, it can bereused if needed.

There are many forms of the CLEAR( ) command. The easiest are

CLEAR(Q #) Clear Qualifier #CLEAR(V #) Clear Variable #CLEAR([var name]) Clear Variable [var name]CLEAR(C #) Clear Choice #CLEAR(R #) Clear Rule #

For example, suppose we want to allow the user to ask for moreinformation on a qualifier. We could have the qualifier

Qualifier 7:The model needed is:

1 Model A2 Model B3 Model C4 Need more information

G - INTERNAL COMMANDS 13

Page 298: Manual Exsys

and a rule

Rule 22IF

1 The model needed is Model A or Model B or Model C

THEN......

ELSE1 DISPLAY(model.inf)2 CLEAR(Q 7)3 CLEAR(R 22)

where the THEN part of rule 22 performs some action relevant tothe run. If the user selects a model from the list, the THEN part willcontinue execution. If the user selects value 4, NEED MOREINFORMATION, the ELSE part will fire and display the fileMODEL.INF (an file created to provide assistance to the user),CLEAR qualifier 7 to unknown and reset rule 22 to unasked. Theprogram would then go back and again ask for information onqualifier 7 and re-use rule 22. This same effect could be achievedmore easily with hypertext help associated with some of the word; itis used here only to show the use of the CLEAR command.

Clearing RangesThe internal command CLEAR( ) can also be given a range to clear,rather than your having to specify each item individually.

CLEAR(X a-b)

will clear all items between a and b. The X can be Q, V, C or R forqualifier, variable, choice or rule. In the following example,

CLEAR(R 34-56) will clear all rules from 34 through 56

CLEAR(Q 1-5) will clear the first 5 qualifiers

CLEAR(X ALL)

will clear ALL items. The X can be Q, V, C or R for qualifier,variable, choice or rule. In the following example,

CLEAR(R ALL) clears all rulesCLEAR(V ALL) clears all variables

CLEAR(ALL)

will clear ALL qualifiers, variables, choices and rules.

G - INTERNAL COMMANDS 14

Page 299: Manual Exsys

CLEAR(R THIS)

clears the rule that the command occurs in. This applies ONLY torules. The command prevents problems when rules are reorganized.In the following example,

IF......

THEN......

ELSECLEAR(R THIS)

will clear the rule if the rule is false, regardless of the rule's number.

Clearing by Name

In EXSYS, both rules and qualifiers have optional names. Thesenames can be used in the CLEAR command with wild cardmatching. The name must be in quotation marks used in place of anumber to specify the rule or qualifier. Names may be given togroups of rules for convenience when referring to them.

Wild card matching allows referring to groups of rules. In wild cardmatching, a "?" may be used anywhere in the name to match anysingle character and a final "*" will match any string. The "*" mayonly be used as the last character.

For choices, rather than names, the choice can be identified by anyunique text sub-string in the choice.

CLEAR(Q "name") Clear Qualifier nameCLEAR(R "name") Clear Rule nameCLEAR(C "text") Clear the Choice containing

the string "text."

In the following example,

CLEAR(Q"A*") will clear all qualifiers whose NAME starts with A

CLEAR(R"XXX") will clear the rule named XXXCLEAR(C"ZZZ") will clear all choices that have the

string "ZZZ" in themCLEAR(R"?XX") will clear all rules with 3 character

names ending in "XX"

G - INTERNAL COMMANDS 15

Page 300: Manual Exsys

CLEAR Command Window

CLEAR:

Qualifier

Variable

Choice

Rule

Everything

By:

Number

Name

Range of Numbers

All

This O K Cancel

To build the command using the CLEAR command window, click onone of the buttons on the left to indicate what is to be cleared. Theappropriate items on the right will be enabled or disabled. Select oneof the items on the right an, if necessary, enter the number or name ofthe item. Then click on OK. The general Command window willreturn, with the CLEAR command in the top edit window. Whenyou click on OK again, the command will be added to the rule.

While LoopsClearing rules can also be used to create WHILE loops, in effect, in aset of rules. In the above example, until the user selects a Modelfrom the list, the question will be reasked. The same effect could beobtained from a value calculated by other rules or external programs.The rule(s) would loop until the IF conditions were true.

Note: The preferred, and recommended, techniqueof creating WHILE loops is through the commandlanguage.

CAUTION: CLEAR allows certainproblems to be handled by EXSYS that arenot possible otherwise, but clearing alreadyasked or derived information should bedone with great care. The changing of thenormal EXSYS flow can easily result in aninfinite loop or errors of logic.

If you experience problems with CLEAR, use TRACE to see what ishappening as the rules fire. This should help to find the error in thelogic. Experience has shown that it is almost impossible for ourtechnical support to help with CLEAR( ) problems over the phonedue to the very convoluted logic that can result from use of thiscommand.

G - INTERNAL COMMANDS 16

Page 301: Manual Exsys

Internal CommandTHEN/ELSE

Command File

Read a File of Data

DATAREAD(filename)

The DATAREAD command will read a file of data and set the valuesfor various EXSYS variables, qualifiers and choices. The format ofthe data is identical to that in a return file from an external programor datalist file.

Data passed back to EXSYS must be in an ASCII file with only onedata item per line. The format of each line must be

For qualifiers: Q <qual #> <value(s)>or

Q "name" <value(s)>

For variables: V <var #> <value>or

[var name] <value>

For choices: C <choice #> <value>or

C "text" <value >

<qual #>, <var #> or <choice #>:The number of the qualifier, variable or choice that thedata is being passed back to.

"name": The name associated with the qualifier.

"text": A unique text sub-string in the choice.

<value>: The data to assign.

See Section H6 for more details on the syntax of data passedto EXSYS.

This is useful if you have several files of data created by a singleexternal program. Normally, an external program call will read onlyone file of return data, but with DATAREAD, other files can be alsoread.

G - INTERNAL COMMANDS 17

Page 302: Manual Exsys

DATAREAD Command Window

The window to build a DATAREAD command only asks for thename of the file containing the data. If an EXSYS string variablecontaining the file name is desired, it must be put in [[ ]] forreplacement.

File containing data to read:O K

Cancel

G - INTERNAL COMMANDS 18

Page 303: Manual Exsys

Internal CommandTHEN/ELSE

Command FileReport Generator

Display a File In a Window

DISPLAY <filename> <options>DISPLAY [string variable] <options>

filename: the name of the file to display

string variable: a string variable whose value is the name ofthe file to display

Options/C: File to display uses GUI Custom ScreenCommandsThe /C option causes the DISPLAY command to parsethe file for Custom Screen Commands. See Chapter Ifor a discussion of the GUI Custom Screen Language.

/N: No wait after screen is displayedThe /N option causes the DISPLAY command todisplay the requested file in a window then immediatelycontinue processing. This can be useful for report filesthat are created and displayed. With the /N option,several report data windows can be simultaneouslyactive.

/S - Small textThe /S option causes the DISPLAY command to displaya text file using a small font. The default is to use alarger font. This applies only to ASCII files.

/F: Fixed size fontThe /F option causes the DISPLAY command to displaya text file using a fixed-size font. This is useful foraligning columns of data. The /S and default fonts areproportionally spaced and aligning data can be difficult.This applies only to ASCII files.

The internal command DISPLAY(filename) causes the file "filename"to be displayed on the screen in a window. The file can be an ASCIIfile or a file containing EXSYS Custom Screen language commands.If it is an ASCII file, the user can move forward and backward in the

G - INTERNAL COMMANDS 19

Page 304: Manual Exsys

file as needed. If it is a Custom Screen file, it can have buttons, scrollbars, mouse regions, etc. The window can be set so that when theuser finishes reading the file, execution of the rules continues, orexecution can continue as soon as the window is drawn and the usercan read it later.

This is used to display a larger section of text than is possible in anote or reference. Also, it allows the text to be displayed to the usereven though the rule display is switched off.

The custom help screen feature can also be used to display text to theuser and sometimes is more appropriate than the DISPLAYcommand See Chapter I for information on custom help screens.

The DISPLAY command is very useful for displaying the reportproduced by the report generator to the user. When displaying thefile produced by the report generator, CLOSE THE FILE BEFOREDISPLAYING IT.

Here are some examples:

DISPLAY INFO1.T

would display the contents of the ASCII file INFO.T for the user toread.

FILE F1.. (report generator commands).CLOSEDISPLAY F1

would create a file F1 containing output from the report generatorcommands. The file F1 would be closed by the CLOSE command.The DISPLAY command would then display the contents of thenewly-created report on the screen or terminal. The CLOSEcommand must be used to close F1 before it is displayed.

DISPLAY SCR1.SCR /C

would display the file SCR1.SCR which contains Custom ScreenCommands.

IF..

THENDISPLAY(FILE1)

G - INTERNAL COMMANDS 20

Page 305: Manual Exsys

would display the contents of the ASCII file FILE1 on the screen ifthe rule fired. The text will be displayed immediately when the rulefires, even if execution were not yet complete.

IF..

THENDISPLAY([X])

would display the contents of the ASCII file whose name is stored inthe string variable [X] if the rule fired.

Display Command Window

The window to build DISPLAY commands provides some specialcommands because of the GUI interface.

DISPLAY Command

File to Display:

Use Custom Screen commands

No wait after display

Normal font

Small font

Fixed space font

O K Cancel

Enter the name of the file to display.

Two types of files can be displayed: simple ASCII text files and fileswith Custom Screen Commands. If you are using custom screencommands, check the Custom Screen box. If the file is just text, donot check the box.

G - INTERNAL COMMANDS 21

Page 306: Manual Exsys

In a GUI, after a window is created, the processing of the expertsystem can either continue or wait until the window is closed. If youwish the file to be displayed and processing to immediately continue,check the No Wait box. If the box is not checked, the window willbe displayed, and processing will wait for the user to click OK todismiss the window.

There are three possible fonts to use in the display box. These onlyapply to the display of simple ASCII text files. The default is a fairlylarge font. If there is a large amount of text, it may be better to usethe small font. If positioning of the text is important for alignment ofcolumns, use the Fixed font. The default and Small font areproportional and it is difficult to align columns.

When the correct parameters are set, click on the OK .

G - INTERNAL COMMANDS 22

Page 307: Manual Exsys

Internal CommandQualifier / Variable

THEN/ELSECommand File

Report Generator

Frame Interface

FRAME(parameters)

Frame files can be used to share data between expert system modulesand to store data.

See Chapter L for a full discussion of frame files and commandsyntax.

LINDO Linear Programming Interface

LINDO(parameters)

EXSYS can be used to create LINDO linear programming modeland interpret the results of the LINDO analysis.

See Chapter N for a full discussion of the EXSYS / LINDO interface.

G - INTERNAL COMMANDS 23

Page 308: Manual Exsys

Internal CommandVariable

THEN/ELSECommand File

Report Generator

Lotus 123 Interface Commands

SS_RD(parameters)SS_WR(parameters)

Two commands allow EXSYS to read or write directly from Lotus123 files.

The same commands can be used from within rules, the reportgenerator or the command files. The syntax of the call is the same ineach case.

Note: Underlined items can be repeated multiple times.

To read Cells from a Spreadsheet, use the following:

SS_RD(ssname, cell, [varname])

To write Cells to a Spreadsheet, use the following:

SS_WR(ssname, cell, [varname])

ssname The name of the spread sheet to use, withthe .wks or .wk1 extension.

cell The cell to read from or write to. The cellcan be specified in the 123 form, columnletter followed by row number (e.g.. A4),or by column number, dash or rownumber (e.g. 4-3 for column 4 row 3). Ineither case, variable replacement can bedone with [[ ]] replacement of variablevalues. For example, if you want variable[R] to select the row in column G, youcould use G[[R]]. The value of [[R]] willbe replaced with the value of [R]. If [R]has the value 3, the cell will be G3.

G - INTERNAL COMMANDS 24

Page 309: Manual Exsys

If the variable must select the column, usethe #-# form. For example, if variable [C]contains the column to use, you could use[[C]]-5 to select a specific column in row 5.You can also use [[C]]-[[R]] to select anarbitrary column/row determined by thevariables.

NOTE: In all cases, there must not be anyspaces in the cell specification; B2 willwork, but B 2 will not. Likewise, theremust not be any spaces between charactersif the #-# form is used.

var name The name of the EXSYS variable to use. Ifthe SS_RD is used, the data is read INTOthis variable. If the SS_WR command isused, the data is written FROM thisvariable to the cell. The variable alwaysapplies to the cell on its left.

The <cell> and <var name> pairs may be repeated as many times asneeded in a single call. For example,SS_RD(salary.wks, C3, [X], D5, [Y], E12, [Z])

will read the contents of cell C3 into [X], D5 into [Y] and E12 into[Z]. The same can be done for the SS_WR command as well.

If the variable is numeric, the data will be assigned as numeric--assigning a text string will produce a 0 value. If the variable type isstring, the data will be assigned as a string, even if it is numeric data.Likewise, if the variable type is numeric, the data will be written tothe spreadsheet as numeric. If the variable type is string, the data willbe written as a string.

Note that if the SS_RD command is used as the text of a variable; toget data for that variable, you must include the variable name in theSS_RD command. For example, if you want the value of variable[X] to be obtained automatically from cell D7 of a spread sheet, youcould make the text associated with [X]

SS_RD(data.wks, D7, [X]) The value of ...

This will automatically read the data from D7 if [X] is needed. But,you must specify that the data is for [X] in the third parameter of theSS_RD command. This is unlike a RUN( ) command that would"know" the data was for [X].

G - INTERNAL COMMANDS 25

Page 310: Manual Exsys

The SS_WR command will not work with Lotus 1 or 1a, since theseignore multiple cells with the same address. It will work with Lotus 2and clones that allow multiple cells with the same address.

Note: The SS_WR command writes thenew cell information to the end of thespreadsheet. The SS_RD command readsthe first cell with the correct address that itfinds. Consequently, SS_WR followed by aSS_RD for the same cell new value. If thecell had no old value, then the new valuewill be read. Once the spreadsheet is readand saved by 123, the SS_RD will returnthe new data because 123 will haveremoved the old data. 123 will correctlydisplay the new data.

Here are some examples:

In a Rule,

IF......

THENSS_WR(price,F35,[X])

will WRITE the value of variable [X] into cell F35 of the spreadsheet"price," if the rule fires.

In a Variable,

SS_RD(parts,E22,[X],E23,[Available]) The price is

is the text associated with a variable [X]. If the value of [X] isneeded, the program will read the value cell E22 from the "parts"spreadsheet into variable [X] and the data in E23 into a variable onpart availability. If needed, there could be additional cell and variablepairs in the expression to get more data from the spreadsheet.

In the Report Generator or Command Language, the line

SS_WR(price,H78,[TOTAL COST])

in the report generator will WRITE the value of variable [TOTALCOST] into cell H78 of the "price" spreadsheet.

G - INTERNAL COMMANDS 26

Page 311: Manual Exsys

In a WHILE loop,

SET [I] 1WHILE ([I] < 100)

SS_RD(parts,E[[I]],[X],F[[I]], [Y])

RULES ALLREPORT SS.RPTCLEAR ALLSET [I] ([I]+1)

WEND

would initialize [I] to 1 then read the value of row E column [I] into[X] and row F column [I] into [Y]. Then the rules would beexecuted and a report written. [I] is then incremented until it isgreater than 100. In this example, [[ ]] are used to insert the value ofthe variable in the expression.

Lotus 123 Command Window

The window for building Lotus 123 Interface commands allows youto build commands that retrieve multiple data items with a single call.

Lotus 123 Data Acquisition

READ from spreadsheet WRITE to spreadsheet

Spreadsheet Filename

Spreadsheet CELL ID:

EXSYS Address to put data in:

O K Prev. Field Next Field Cancel

To build a Lotus 123 data acquisition command, select READ orWRITE and enter the spreadsheet filename. Cell IDs (row, column)and EXSYS variable names are used in pairs. Each Cell ID musthave a corresponding EXSYS variable. In a READ, the value of thecell is put in the EXSYS variable. In a WRITE, the value of theEXSYS variable is put in the cell.

G - INTERNAL COMMANDS 27

Page 312: Manual Exsys

Enter the first pair of cell and variable name. To enter a second pairin the same command, click on Next Field . The Cell ID and EXSYSAddress edit boxes will clear and you can enter another pair. Thiscan be done repeatedly. To examine a cell or variable pair alreadyentered, click on Prev Field . This will display the previous pair.

When all cell or variable pairs have been entered, click on the OKbutton.

G - INTERNAL COMMANDS 28

Page 313: Manual Exsys

Internal CommandTHEN/ELSE

Command File

Run a Report Specification File

REPORT <filename>REPORT [string variable name]

filename: the name of the report command file to use.

string variable name : a string variable whose value is thename of the report command file to use.

The REPORT( ) command allows the report generator to be calledfrom any EXSYS rule or from the command file.

The report specification file contains the report generator commandsto be used in creating a report. The first form allows the report fileto be specified explicitly, while in the second form the value of thestring variable is used as the name of the file to use for the reportspecification. In this way, the knowledge base itself can set the nameof the report specification file to be used by assigning a value to thestring variable.

The REPORT( ) command is also useful when a large amount of datamust be passed to an external program.

Here is an example:

IF..

THENREPORT(RPTFILE.1)RUN(PROG1)

The report specification RPTFILE.1 could contain commands towrite a large amount of data into a file that would then be read byPROG1 when it is called.

G - INTERNAL COMMANDS 29

Page 314: Manual Exsys

Alternatively, a number of report specifications can be used to eachadd data to an overall conclusion report. The knowledge base rulescan control what report specifications are invoked and used. Each ofthe report command files could append data to an overall report.

The details of the Report Generator language are in Chapter F.

Report Command Window

The window to build a report command only asks for the name ofthe Report Command file or EXSYS string variable containing thecommand file name.

Report Generator File to Use:O K

Cancel

G - INTERNAL COMMANDS 30

Page 315: Manual Exsys

Internal CommandQualifier / Variable

THEN/ELSECommand File

Report GeneratorCustom Screen

Run an External Program

RUN(filename parameters)

The internal command RUN( ) is used to call external programs, passdata to the programs and receive data back from the programs.

See Chapter H for the details on calling external programs with theRUN command.

G - INTERNAL COMMANDS 31

Page 316: Manual Exsys

Internal CommandTHEN/ELSE

Command File

Stop Program Execution

STOP

The STOP command will terminate execution of rules and go directlyto the report generator (if one is present) and then display theconclusions. This is quite useful in situations where, once a particularanswer is known, there is no need to continue asking questions.

The STOP command can only appear in the THEN or ELSE part ofa rule or in the command file. The execution of the rules willimmediately stop if a rule with a STOP command fires.

Here is an example:

IF The color is green

THEN Choice 1: Probability=10/10

and STOP

If this rule fires, Choice 1 will be given a value of 10 and the runningof the rules will be stopped, despite any other rules that are availableon other choices.

STOP can be used with the FORWARD and NOBACKWARDoptions.

G - INTERNAL COMMANDS 32

Page 317: Manual Exsys

Internal CommandQualifier / Variable

THEN/ELSECommand File

Report Generator

Table Interface

TABLE(parameters)

Table files can be used to store data needed by EXSYS in a simpleASCII format.

See Section L1 for a full discussion of table files and commandsyntax.

G - INTERNAL COMMANDS 33

Page 318: Manual Exsys

Chapter H

External Program Calls

EXSYS has many ways to access data from other programs. Thisallows easy integration with other applications. There are built-incommands to access data directly from some programs such asdBase, Lotus 123 and LINDO. However, for other programsexternal programs calls are used. Calling external programs is themost general way to access data from other programs and allows anyprogram that can be run on the computer to be accessed by EXSYS.

External programs are called with an EXSYS internal command.Data can be passed to the external program and also can be passedback into EXSYS for analysis. The use of external programs providesa powerful capability that enables EXSYS to handle a wide range ofproblems and provides almost limitless ways to extend the EXSYSpackage.

There are several ways to call external programs from the expertsystem.

1. Programs called at the start of a run.2. Programs associated with a qualifier or variable.3. Programs called in the THEN/ELSE rules.4. Programs called from the report generator.5. Programs called from the command language.6. Programs called from the screen language

Each way of running external programs uses basically the samesyntax and command options.

The external program can be any program which can be run fromthe operating system. The program can be written in any languageor it can be an application. This ability to run any program providesthe great flexibility.

When EXSYS calls an external program, EXSYSP.EXE (orEDITXSP.EXE) remains in memory. Thus, there must be enoughmemory available for both EXSYS and the external program to run.If there is not enough memory, you will get an error message. Inmost GUI environments, memory is not a problem.

H - EXTERNAL PROGRAM CALLS 1

Page 319: Manual Exsys

H1: SyntaxAll versions of the RUN command have the same basic form:

RUN(filename <data1> <data2> .... <options>)

filename: The name of the program to run. This can beany program that can be run from the operatingsystem. Instead of an actual filename, the firstparameter can be a string variable whose value isthe name of the program to run. If a stringvariable is used, the first parameter is the name ofthe variable in [ ]. Here's an example of anexternal program call.

RUN([P] 1 [X])

In this case, the program would derive or ask theuser for the value of the string variable P, whichwould be used as the name of the externalprogram called.

The program name can be a batch file in DOS ifthe /B option is used. Data can be returned toEXSYS through a file. Any program which canwrite an ASCII file can pass data back to EXSYS.

data#: The call to an external program can pass anumber of pieces of data. The list of parameterscan include either text or variables. If text is used,it is just listed. If variables are used, the name ofthe variable must be placed in [ ]. The variablewill be replaced with its value in the call to theprogram. For example, RUN(DEMO ABC [X]1.2) would call the program DEMO and pass thestring ABC, the value of [X] expressed as a stringand the string 1.2. It is up to the program calledto correctly accept and use these items of data.

If an item is in quotes, it will be passed withoutchange. This allows passing the strings such as,"[X]" or "/C" to a called program.

H - EXTERNAL PROGRAM CALLS 2

Page 320: Manual Exsys

Options: There are a variety of options that effect the external program call.

/B Batch Mode / DOS programsEXSYS supports calls to batch files; or DOScommands; by adding a /B to a RUN( )command.

It is also possible to call a batch file by callingCOMMAND.COM and passing the batch filename as a parameter. There may be a problemwith this approach: depending upon the end user'scomputer configuration, it may not be easy to tellwhere COMMAND.COM is. With the /B option,EXSYS will determine where COMMAND.COMis and use it to call the batch file or DOScommand.

If the MS Windows version of EXSYS is beingused, and a NON-Windows (DOS) program isbeing called, use /B.

For example:

RUN(XXX.BAT /B)

will execute the batch file XXX.BAT.

RUN(DIR C:*.C /B)

will display a directory of the .C files on drive C.In this case, the program will not pause afterdisplaying the directory. However, you could use2 commands such as,

RUN(DIR C:*.C >C:LIST /B)DISPLAY(C:LIST)

The first command uses the ability of DOS toredirect the directory output to a file C:LIST, andthe second command, displays the file created.(For information on redirection, see your DOSmanual.)

H - EXTERNAL PROGRAM CALLS 3

Page 321: Manual Exsys

/C and /# Passing Arguments on the Command LineThis determines if the data arguments will bepassed to the external program on the commandline; or in a file.

Data is passed to an external program by twomethods:

Passing data in a filePassing data on the command line

The default method is to pass data in the filePASS.DAT. This is an ASCII file. Data parametersare written to this file and the file is closed beforethe external program is called. It is theresponsibility of the external program to read thedata from PASS.DAT. (The name of the file thatthe data is passed to can be changed with the optionPASS=in the command line or configure file.)

Passing data by using a file, is very general, buthas some disadvantages. - It requires opening,writing/reading and closing a file twice which maybe slow. Also, if a call is made to a program likeBASIC, the name of the basic program must bespecified (e.g. RUN(BASIC BASPROG) - wewant the name of the basic program, BASPROG,passed to BASIC, not written to a file.)

To avoid these problems, EXSYS can also passthe parameters on the command line when theexternal program is called. This is just likeentering the parameters on the command linewhen a program is called from the operatingsystem.

Passing data on the command line is much fastersince the data does not have to be written to a fileand then read from a file. Instead, the data isimmediately available to the called program.Unfortunately, not all programs can accept dataas a command line argument. If it is desired topass arguments on the command line, the /Coption MUST be used or all arguments will bepassed in PASS.DAT.

The /C and /# options tell EXSYS to pass thearguments on the command line rather than inPASS.DAT. If you want to pass more than theprogram name as a command line argument, butstill pass others in PASS.DAT, use /# - where # isthe number of the argument to pass on thecommand line.

H - EXTERNAL PROGRAM CALLS 4

Page 322: Manual Exsys

For example, BASIC will not usually acceptcommand line arguments for data. Suppose wewant to call a basic program TEST and pass it thevalue of [X] and [Y] in PASS.DAT. If we use

RUN(BASIC TEST [X] [Y])

the program name TEST will not be passed as acommand line argument. Instead, it will bewritten to PASS.DAT. The file PASS.DAT willcontain the ASCII string TEST and the values ofthe variables [X] and [Y].

If we use

RUN(BASIC TEST [X] [Y] /C)

all of the parameters will be passed on thecommand line and the file PASS.DAT will not becreated. Basic will not be able to use the valuesof [X] and [Y] passed this way.

We could pass the values of [X] and [Y] using theREPORT( ) command, however, it is easier to use

RUN(BASIC TEST [X] [Y] /2)

This causes the first 2 arguments, BASIC andTEST, to be passed as command line arguments.PASS.DAT will be created with the values of [X]and [Y]. [X] and [Y] will be passed inPASS.DAT.

When programs can accept data on a commandline, this method is very fast. When programsmake many calls, it is also much more efficient.

NOTE: In DOS, data passed on the command lineis limited to 127 characters in length. Sincenumeric variables are stored as floating points,each can use 10 characters and it is possible to fillup the command line. If this happens EXSYSwill tell you and you must use the PASS.DATmethod instead.

H - EXTERNAL PROGRAM CALLS 5

Page 323: Manual Exsys

/R RestartThis option causes EXSYS to RESTART; at thebeginning of the run, after calling the externalprogram. This is very useful for expert systemsthat are monitoring a process. For example, anexpert system could have a rule that fires to callan external program to do something and thenrestart the process again. If new data indicatedsome action was necessary, a different rule couldcall another external program (or the sameprogram with different parameters passed) to alertsomeone or to correct the process.Do not use the /R option unless you want torestart the run after the external program iscalled.

/M Returning Multiple ValuesNormally, a RUN( ) command associated with aparticular qualifier or variable will only returndata for that qualifier or variable. The /M optiontells the program that multiple data items will bereturned. If /M is not added, EXSYS will defaultto accepting only one item of data when anexternal program call is associated with a specificqualifier or variable. If data will be returned, the/M option must be used when calling externalprograms from the THEN/ELSE portion of a ruleor a command file.

/Z Add Ctrl-ZAdding the /Z option to the run command, causesa CTRL-Z to be added to the end of thePASS.DAT file. This is necessary forcompatibility with some external programs.

H - EXTERNAL PROGRAM CALLS 6

Page 324: Manual Exsys

H2: RUN Command WindowTo build a RUN command from the command window:

Program Name:

Data:

Pass all parameters on the command line

Pass first N parameters on command line N=

Pass parameters in PASS.DAT

Return Mutliple data items

Batch file or NON-WINDOWS program

Restart after call

Add Ctrl-Z to PASS.DAT

O K

Cancel

Enter the program name and any data to pass to the program. Thedata may contain EXSYS variables, text strings or quoted strings.Select how the parameters should be passed to the program and clickon the appropriate radio button. If only some parameters are to bepassed in PASS.DAT, enter the number of parameters to pass.

If the program will return multiple data items, or if the call is notassociated with a qualifier or variable, click on the Multiple dataitems box. If the program is running in MS Windows, and the calledprogram is a Non-Windows (DOS) program, click on the Non-Windows button. If a restart or Ctrl-Z is required, click on theappropriate button. Once all of the parameters are set, click on theOK button.

H - EXTERNAL PROGRAM CALLS 7

Page 325: Manual Exsys

H3: Microsoft Windows Program Calls

The way the external program must signal that it is complete differsamong the supported GUI operating systems. In the non-GUIversions of EXSYS, the external program need only terminate. Insome windowed environments, it is more complicated becausemultiple programs may be running simultaneously and anothertechnique must be used to indicate that a program is finished and thedata are ready to be returned.

In Microsoft Windows, both Windows and non-Windows (DOS)programs can be called. The best technique for calling externalprograms is to set up Dynamic Data Exchange (DDE) and passsignals to indicate the end of a process. To set this up would requiresignificant modification to user developed external programs andwould not be possible for non-Windows (DOS) applications. In orderto keep the interface to user developed external programs as simpleas possible, another technique has been developed which works forboth Windows and non-Windows programs. (DDE links to externalprograms can be established using the Linkable Object version ofEXSYS for MS Windows.)

The technique is to create a flag file just before the external programterminates. EXSYS looks for this flag file and waits until it is createdto read data back into the expert system. This technique works forboth Windows and non-Windows applications, and requires onlyminimal modification to user developed external programs. Also, abatch file approach allows applications developed for DOS to runwithout modification.

The default name of the flag file is EXSYS_EP.FIN. You can changethe default name with the configure option:

EP_FLAG_FILE=filename

Since EXSYS frequently checks for the external program, werecommend that you rename it to a file in RAM disk. Do not namethe flag file with the same name as the return data file. EXSYS willcheck for the existence of the file every 2 seconds. This time intervalcan be lengthened or shortened with the following configure option:

EP_TIME_INC=number

H - EXTERNAL PROGRAM CALLS 8

Page 326: Manual Exsys

The sequence that should be used in the external program is:

1. Call the external program from EXSYS. If it is a non-Windows (DOS) program, be sure to set the /B option in theRUN( ) command.

2. Have the external program perform its operations.

3. If data is to be returned, have the external program openthe return data file (usually RETURN.DAT), write the data andclose the return file.

4. When the external program is finished, have it open the flagfile for writing, immediately close the flag file and exit. Forexample:

f = fopen("EXSYS_EP.FIN", "w");fclose(f);exit(0);

It is not necessary to write anything to the file. Its creation,even with 0 bytes length is adequate. It is very important toexit as soon as possible since EXSYS is checking for theexistence of the file and will retake control as soon as it finds it.EXSYS is designed to allow a short time after it finds the fileto allow your program to terminate, but the time is limited.

If you already have a non-Windows program which you wish to call,you can also use a batch method.

1. Create a 1 byte file named xxx (or whatever you like).

2. Instead of directly calling your program, call the followingbatch file:

copy xxx exsys_ep.xxxcall your program hererename exsys_ep.xxx exsys_ep.fin

The first line makes a dummy file. The second runs your programwhich should create the return data file, but NOT the flag file. Thethird line creates the flag file through a "rename" which is the fastestpossible way to create it. Parameters can be passed into yourprogram through batch file replaceable parameters. (See your DOSmanual for information on replaceable parameters in a batch file.)

H - EXTERNAL PROGRAM CALLS 9

Page 327: Manual Exsys

H4: Macintosh Program Calls

The way the external program must signal that it is complete differsamong the supported GUI operating systems. In the non-GUIversions of EXSYS, the external program need only terminate. Insome windowed environments, it is more complicated becausemultiple programs may be running simultaneously and anothertechnique must be used to indicate that a program is finished and thedata are ready to be returned.

For the Macintosh, the technique is to create a flag file just before theexternal program terminates. EXSYS looks for this flag file andwaits until it is created to read data back into the expert system. Thistechnique works for both Macintosh System 6 and System 7.

The default name of the flag file is EXSYS_EP.FIN. You can changethe default name with the configure option:

EP_FLAG_FILE=filename

Since EXSYS frequently checks for the external program, werecommend that you rename it to a file in RAM disk. Do not namethe flag file with the same name as the return data file. EXSYS willcheck for the existence of the file every 2 seconds. This time intervalcan be lengthened or shortened with the following configure option:

EP_TIME_INC=number

The sequence that should be used in the external program is:

1. Call the external program from EXSYS, passing allarguments to the program using the pass.dat file.

2. Have the external program perform its operations.

3. If data is to be returned, have the external program openthe return data file (usually RETURN.DAT), write the data andclose the return file.

4. When the external program is finished, have it open the flagfile for writing, immediately close the flag file and exit.For example:

f = fopen("EXSYS_EP.FIN", "w");fclose(f);exit(0);

It is not necessary to write anything to the file. Its creation,even with 0 bytes length is adequate. It is important to exit assoon as possible since EXSYS is checking for the existence ofthe file and will retake control as soon as it finds it. EXSYS isdesigned to allow a short time after it finds the file to allowyour program to terminate, but the time is limited.

H - EXTERNAL PROGRAM CALLS 10

Page 328: Manual Exsys

H5: UNIX and VMS Program Calls

No special flag files or other operations are required in UNIX orVMS. EXSYS will wait for the called program to terminate and willthen read the RETURN.DAT file.

H6: Returning Data to EXSYSThere are two reasons for calling an external program:

1. Getting data from another program2. Calling a program to display some information to the user

The first is much more common and it requires that there be amethod for the data to be passed back to EXSYS. In order to havethe most generic technique possible, EXSYS expects the data to bereturned in an ASCII file. In this way, the only constraint on thecalled program is that it be able to write an ASCII file.

There is a slight speed penalty in passing data in files, but it is verysmall. Other techniques of passing data are much more complicatedto implement and severely limit the number of programs that couldbe called.

Data is returned to EXSYS by having the external program write itto a file which is automatically read by EXSYS after the externalprogram is finished. The default file name that is used to pass databack is RETURN.DAT. This is an ASCII file created by the calledprogram.

The name of the file used to return data to EXSYS can be changedby the RETURN= configure option. It is the responsibility of theexternal program which was called to write data to the appropriatereturn file in a form which EXSYS can read.

If multiple items of data are being passed back, it is necessary to tellEXSYS what qualifier, variable or choice the data is used for and thevalue to be assigned to it. If the external program call is associatedwith a particular qualifier or variable, only the value need be returned.

Data passed back to EXSYS must be in an ASCII file with only onedata item per line. The format of each line must be:

For qualifiers: Q <qual #> <value(s)>or

Q "name" <value(s)>

H - EXTERNAL PROGRAM CALLS 11

Page 329: Manual Exsys

For variables: V <var #> <value>or

[var name] <value>

For choices: C <choice #> <value>or

C "text" <value >

<qual #>, <var #> or <choice #> -The number of the qualifier, variable or choice for which the data is being passed back

"name" The name associated with the qualifier.

"text" A unique text sub-string in the choice.

<value> The data to assign, in the correct format.For numeric variables, a numeric value.For string variable, a text string.For qualifiers a string listing the numbers of thevalues to set. If more than one value is set, theymust be separated by spaces or a comma.For choices, a value appropriate to the confidencesystem being used.

For example:

1. V3 2.1 means assign a value of 2.1 to variable 3

2. [X] 2.1 means assign a value of 2.1 to variable [X]

3. If qualifier #7 has four values:

Qualifier #7THE COLOR IS

1. RED2. BLUE3. GREEN4. ORANGE

and we have a line in RETURN.DAT, Q7 1,2 this means for qualifier7, set values 1 and 2 as true, or "The color is red or blue". If morethan one value is passed back, the values must be separated by aspace or comma.

If this qualifier has the associated name "COLOR", we could use

Q "COLOR" 1,2

H - EXTERNAL PROGRAM CALLS 12

Page 330: Manual Exsys

4. You can pass data back for as many variables, qualifiers or choicesas you wish. For example, if RETURN.DAT contained:

V2 1.7[X] 6.3V12 ABCDQ7 1,2Q "TIME" 3C "Part ABC" 8

EXSYS would assign a value of 1.7 to variable number 2; assign 6.3to variable [X]; assign the string "ABCD" to string variable 12;select the first two values of qualifier 7; select the third value of thequalifier named "TIME" and assign a value of 8 to the choicecontaining the text "Part ABC'.

5. The multi-variable approach is useful if the external program canset several items of data at once. Suppose we want to have the userenter a list of variables and pass the number of data points and theaverage back to EXSYS, which stores the data in variables 1 and 6.We could use the following program written in BASIC.

10 COUNT = 020 SUM = 030 INPUT "DATA TO BE AVERAGED OR <ENTER> TOEND", X40 IF X <> 0 THEN COUNT=COUNT+1: SUM=SUM+X:GOTO 3050 OPEN "RETURN.DAT" FOR OUTPUT AS #160 PRINT #1, "V1 ";SUM/COUNT70 PRINT #1, "V6 ";COUNT80 CLOSE #190 SYSTEM

The program writes "V1 " and the average value on one line and "V6" with the number of data points on the next line in the fileRETURN.DAT.

Note: The file compression utility SHRINKPremoves unused formulas and variables. Thiscan cause the number of a variable to changeif there were unused variables preceding it.Be sure to check the numbers of yourvariables after running SHRINKP and makethe appropriate corrections in your externalprograms. Likewise, deleting a qualifier canchange the qualifier numbers. It is a goodidea to pass data by name or text wheneverpossible.

H - EXTERNAL PROGRAM CALLS 13

Page 331: Manual Exsys

When data is passed back for a choice, the value will be incorporatedwith any other values assigned to the choice by other rules. Thevalue will NOT overwrite existing data; it will be combined with it asif it were assigned in a rule.

H6.1: RAM Disks

If speed is critical in a particular application, we recommended that, inthose operating systems that support it, the data be passed on a RAMdisk file. To pass data on a RAM disk file, redefine the name of thefile in which the data will be returned with the RETURN= commandin the configure file. For example, if drive D is a RAM disk, and weuse RETURN=D:RETURN.DAT, data will be passed on the RAMdisk. This is substantially faster than passing it on a the hard disk.

H6.2: Erasing RETURN.DAT

After EXSYS reads the returned data, the file which returned thedata is erased. This is done to prevent inadvertently reading the fileagain after a subsequent external program call that did not returndata. If your application requires that the file which returns the datanot be deleted, use the configure option NODELETE.

H - EXTERNAL PROGRAM CALLS 14

Page 332: Manual Exsys

H6.3: Passing Back a Command from an External ProgramIn addition to returning data, an external program can return acommand to EXSYS. If the RETURN.DAT file has a line whichstarts with an "!", the remainder of the line will be used as acommand rather than treated as data. This enables external programto ask for questions that would normally be asked from theQuestions menu.

If a command is returned, EXSYS will call the external program afterexecuting the command, so that data can be obtained. This allows acomplete customization of the interface, yet retains the ability to askquestions of the system.

The commands which are supported are:

!WHY Displays the current rules being tested!? or !HELP Displays the custom help file associated

with the qualifier or variable.!KNOWN Displays the known data!EXIT Exits the program

For example, if RETURN.DAT contained

!WHY

EXSYS would display the rules that caused the question to be asked.

H6.4: Returning Hypertext Words from External ProgramsIn addition to returning data, an external program can return a call todisplay a EXSYS hypertext keyword. If the RETURN.DAT file has aline which starts with an "?", the remainder of the line will be usedas hypertext keyword.

When hypertext words are returned, EXSYS displays the screen(s)associated with the hypertext words then, calls the external programagain so that you can obtain data. This allows external programs toaccess the hypertext system, and still be able to obtain the needed data.

The syntax is:?keyword

For example, if RETURN.DAT contained

?Part 23

EXSYS would display the hypertext screen associated with thekeyword "Part 23" and would then, recall the external program.

H - EXTERNAL PROGRAM CALLS 15

Page 333: Manual Exsys

H7: Calling Programs from THEN/ELSE

Calling external programs from the THEN/ELSE part of rules is theeasiest form of the RUN( ) command. A program is called using theinternal command RUN(). The form of the RUN( ) command is thesame as described in Section H1. Data and variables can be passedto the program by the RUN( ) command and the options for passingon the command line can be used. This is entered as an internalcommand by clicking on the Command button in the rule editingwindow, and selecting Run External Program. When the RUN( )command is encountered in a rule that fires, EXSYS will immediatelycall the specified external program . When the external program isdone, (and exits as if it were going to the operating system) controlwill, instead, return to EXSYS at the point in the rule where theprogram was called.

Data will usually not be returned from a RUN( ) in the THEN/ELSE.However, if it is desired to return data, the /M option will causeEXSYS to look for and read a RETURN.DAT file.

For example:

IF[X] > 0

THENRUN(TEST [X])

will cause the program TEST to be called if [X] is greater than 0.The value of [X] will be passed in a PASS.DAT file.

IF[X] > 0

THENRUN(TEST [X] /C /M)

will also run the program TEST if [X] is greater than 0, but the valueof [X] will be passed on the command line due to the /C and theprogram will expect data to be returned from the called program dueto the /M option.

Remember, in a backward chaining system, a rule will be tested andfired ONLY if there is some reason to do so. When externalprograms are used in the THEN part of rules, there MUST also besome mechanism to make them fire. EXSYS does not know whatvariable the external program will return data for, and does not knowwhen a external program is relevant. Some techniques to force anexternal program to fire are:

H - EXTERNAL PROGRAM CALLS 16

Page 334: Manual Exsys

1. Have a choice also in the THEN part of the rule. Thesystem will backward chain on the choice

IF[X] > 0

THENRUN(TEST [X])

and Choice 1: Conf=5

2. Have a variable in the THEN part of the rule if the systemwill backward chain on the variable.

IF[X] > 0

THENRUN(TEST [X])

and [X] is given the value 1

3. Force the rule to fire through the command language

RULES 5 /F

4. Use forward chaining. Since forward chaining is not goaldriven, it will test all of the rules.

H - EXTERNAL PROGRAM CALLS 17

Page 335: Manual Exsys

H8: Calling Programs from the Report Generator, Command File or

Custom Screen FileCalling external programs from the report generator or othercommand files, is the same as calling a program from theTHEN/ELSE part of a rule except, the command is put in the reportspecification file with an ASCII editor. It is not part of the EXSYSrules. Note, in the report generator, the command does not have tobe in ( ).

The ability to pass data and the options available are the same as inthe above RUN ( ) command from THEN/ELSE. Remember, youmust use the /C or /# option if the data is to be passed on thecommand line.

Using the /M option causes EXSYS to read returned data. Thisshould only be used for REPORT commands in rules. For example,the rule:

IF...

THENREPORT(XXX.RPT)

where the report specification file XXX.RPT contained:

FILE xxx.datVCLOSERUN TEST /M

would be a way to call an external program, TEST, and make all ofthe data on the variables available to it. This would be a usefultechnique if there were too many variables to pass on the commandline or list in the run call.

H - EXTERNAL PROGRAM CALLS 18

Page 336: Manual Exsys

H9: Calling an External Program at the Start of a RunMany expert systems that interface to other programs, get much oftheir data from a single external program. This may be a database,spread sheet or custom data acquisition program. The externalprogram is called at the start of the run. If the external programprovides all of the information needed by the expert system, the usermay not actually interact with EXSYS at all. This allows the creationof embedded systems which get all data from other programs anduse the report generator to output the results.

One of the options available on the knowledge base Parameterswindow, is the option to call an external program at the start of arun. This program will be called at the start of each run. To edit thename of the external program, select Parameters from the Optionsmenu, and click on the Ext Prog button. Enter the name of theprogram and any data to pass then, click on OK. Do not enter"RUN" or the ( ). These are not needed when you are calling anexternal program at the start of a run. Only the parameters thatwould normally appear in the ( ) are entered.

filename <data1> <data2> ... <Options>

Remember,this call is made at the start of a run, so there are noEXSYS variables know to pass to the external program. All datapassed should be text items.

H - EXTERNAL PROGRAM CALLS 19

Page 337: Manual Exsys

H10: Calling External Programs from Variables

In addition to external program calls associated with the expertsystem or a particular rule, external program calls can also beassociated with a specific variable. In such a case, the externalprogram will only be called when the value of the variable is neededand if a value cannot be derived from other rules.

Associating an external program call with a variable is done byentering the RUN( ) command at the start of the text you wouldnormally associate with the variable:

RUN(filename <data> ... <Options>) <var text>

The parts of the RUN command are the same as described previouslyand the <var text> is just the normal text you would associate withthe variable. Only the <var text> will be used when EXSYS displaysresults, prints the value from the report generator, etc. The RUN(...)part of the text is "invisible" to the user seeing the results of the run.Be sure to place a space between the closing ")" and the firstcharacter of the variable text. It is easiest to build the RUN( )command by using the Data Acquisition button on the VariableWindow.

For example, we might have a variable [PIPE DIAMETER] thatrepresents the diameter of a pipe. When we first use the variable[PIPE DIAMETER] in an expression, the program asks for text toassociate with the variable. If we want the user to be asked for thediameter, we enter:

The diameter of the pipe

Suppose however, that we want to call a program called PIPE andpass it the value of [PIPE TYPE] on the command line. Thisprogram will return the value of the pipe's diameter. In this case, wewould select the Data Acquisition option to build a RUN( )command. The text associated with the variable would then be:

RUN(PIPE [PIPE TYPE] /C) The diameter of the pipe

The variable which calls the external program can have limits, bedisplayed, etc. but do not initialize it or the program will never becalled. External programs associated with a variable are called onlyif the user would be asked for a value for the variable. If the variableis initialized, the user would not be asked for a value and the programwould not be run. When, EXSYS determines it needs the value of thevariable, and it can not derive a value from other rules, the externalprogram will be called.

H - EXTERNAL PROGRAM CALLS 20

Page 338: Manual Exsys

Since the program is being called to get a value for the variable,EXSYS expects data to be returned. The method of passing databack is in the file RETURN.DAT (unless changed to another filenamewith the RETURN= command). In this case, there are two optionsto the form in which the data is passed:

1. A single value passed back with no "address" information.It is assumed the value returned will be assigned to the variablethat caused the program to be called.

2. Multiple values passed back with "address" information oneach line. (The call to the external program must have used the/M option.)

The first form is the standard way to get data for programsassociated with a specific variable. In this case, just the value to bereturned is written by the external program in the fileRETURN.DAT. For example, if variable 7 called an externalprogram which returned the value 4.5 as the value, theRETURN.DAT file could contain just 4.5 rather than V7 4.5,although the second form would also be valid if the /M option wasused.

If the /M option is used, data can be passed back for many variables,qualifiers and choices. But be sure to pass data back for the variablethat caused the program to be called. The format of the data passedback with the /M option is the same as described in Section H6.

CAUTION: Passing back multiple itemsfrom an external program call associatedwith a variable can overwrite existing data.Passing data back for a variable or qualifierthat already has a value will OVERWRITEthe existing value with the new one. This canresult in changing the values input by theuser or derived by the system.

Note: Use care when passing databack to other than the callingqualifier or variable to preventoverwriting existing data.

H - EXTERNAL PROGRAM CALLS 21

Page 339: Manual Exsys

H11: Calling External Programs from Qualifiers

In addition to external program calls associated with the expertsystem or a particular rule, external program calls can also beassociated with a specific qualifier. In such a case, the externalprogram will only be called when the value of the qualifier is neededand a value cannot be derived from other rules.

The technique used is very similar to that used in associating anexternal program with a variable. Instead of the text associated withthe variable containing the RUN( ) command, the qualifier text isstarted with

RUN(filename <data> ... <Options>) <qual text>

The parts of the RUN command are the same as described above andthe <qual text> is just the normal qualifier text you would use. Onlythe <qual text> will be used when EXSYS displays conditions, printsfrom the report generator, etc. The call to the external program is"invisible" to the user seeing the results of the run.

For example, suppose we have a qualifier:

The color is1 red2 white3 blue4 green

When information on this qualifier is needed, the user is asked toselect a value. If instead, there is a program COLOR that candetermine the color, we could input the call to the external programin the qualifier text. This call can be easily built by using the DataAcquisition button on the qualifier editing window.

RUN(COLOR) The color is1 red2 white3 blue4 green

When the value of the qualifier is needed and can not be derivedfrom other rules, the external program COLOR would be run.

Since the purpose of running the external program is to get data, it isexpected that data will be returned in the file RETURN.DAT. As

H - EXTERNAL PROGRAM CALLS 22

Page 340: Manual Exsys

with external programs associated with a variable, data can bereturned in two forms:

1. A single value list passed back with no "address"information. It is assumed the value returned will be assignedto the qualifier that caused the program to be called.

2. Multiple values passed back with "address" information oneach line. (The call to the external program must have used the/M option.)

In the first case, the data is automatically assigned to the qualifier thatcalled the program. The data returned is the number or numbers ofthe values that are to be selected. For example, if after the call toCOLOR in the example above, RETURN.DAT contained:

1,3

the first and third values in the list would be set for the qualifier or:

The color is red and blue

If the /M option is used, data can be passed back for many variables,qualifiers and choices. Be sure to pass data back for the qualifier thatcaused the program to be called. The format of the data passed backwith the /M option is the same as described in Section H6.

Caution: As with variables, passing backmultiple items from an external program callthat is associated with a qualifier can causeproblems. It is possible to overwrite existingdata. Passing data back for a variable orqualifier that already has a value willOVERWRITE the existing value with thenew one. This can result in changing thevalues input by the user or derived by thesystem.

Note: Use care when passingdata back to other than thecalling qualifier to preventoverwriting existing data.

H - EXTERNAL PROGRAM CALLS 23

Page 341: Manual Exsys

H12: Problems Calling External Programs

If you call an external program and the command is ignored or youget an error message about not being able to find the file, there areseveral likely causes. The first thing to do is to use the TRACE=configure command to get a listing of the run.

1. The trace listing does not show a call to the program.When the RUN( ) command is in the THEN or ELSE part of a rule,determine if the rule fired. In a backward chaining system, rules areonly used if they are relevant to the problem. If the rule contains nochoices or variables that are displayed at the end of the run, the rulewill not be used unless the program is run in the FORWARD orFINALPASS mode. (See the Chapter E on forward chaining formore information on these commands.)

If the RUN( ) is associated with a qualifier or variable, decide if thedata was needed by the system. RUN( ) commands associated witha qualifier or variable will only be used if needed. If the qualifier orvariable received a value in the trace listing, decide where it camefrom. If a variable or qualifier has an initial value, or if a value can bederived from the rules, the associated run command will not be used.

2. The trace listing shows an attempt to call the externalprogram.There may be a system resource problem. Some systems have alimit on the number of files or processes simultaneously open orrunning.

Another possible resource problem may be lack of memory. BothEXSYS and the called program must reside in the available memory.Usually a lack of memory will result in an error message. If youhave memory problems running an external program from theeditor, try it with the runtime program. The Runtime program ismuch smaller. If there is just not enough memory to run bothprograms, try creating a batch file that calls the external programfirst, creates a RETURN.DAT file with the external program, exitsthe external program, loads EXSYS and reads the RETURN.DATfile with the DATALIST command. This approach will often allowrunning a program too large to be co-resident with EXSYS.

If there does not seem to be a resource problem, but EXSYS can notfind the called program or cannot execute it, it may be looking on thewrong drive. If you are calling a program that is not on the defaultdrive, be sure to specify the FULL drive and path specifications.This sometimes seems to be necessary even if the program is on thedefault drive. It is especially important when calling BASICprograms, since both the path to BASIC and the path to the basic

H - EXTERNAL PROGRAM CALLS 24

Page 342: Manual Exsys

program must be specified. For example, suppose BASIC.COM ison disk C in sub-directory BAS and your basic program TEST.BASis also in the same sub-directory. To run this program you wouldenter:

RUN(C:\BAS\BASIC C:\BAS\TEST /C)

Also remember, the file called by the RUN( ) command as anexternal program MUST be an executable file. In DOS that is onethat ends in .EXE or .COM, not a batch file. In UNIX or VMS,make sure the program can be run and that the access privilegesallow running. If a batch file is used, the /B option must be used.

H - EXTERNAL PROGRAM CALLS 25

Page 343: Manual Exsys

H13: Calling External Programs - Summary

Single Variable Approach

1. Called by adding RUN(filename...) at the start of the text associatedwith a specific variable or qualifier. Do not use the /M option unlessit is desired to return multiple data items.

2. Data is returned in the file RETURN.DAT and passed out in thefile PASS.DAT.

3. Only a single value need be returned which is assigned to thevariable or qualifier that called the external program. Returningmultiple values is permitted if /M is used and "address" information isincluded in the RETURN.DAT file.

4. Form of data returned:

Numeric variable - single floating point number expressed asan ASCII string

String variable - text string, without " "

Qualifier - list of the numbers of the values in the list to set totrue. Numbers should be separated by a space or comma.

5. External program called only when the value for the variable orqualifier is needed.

Multi-variable Approach

1. Called by indicating that an external program should be called atthe start of EXSYS or by using the /M option with an externalprogram call from a qualifier or variable. Returned data must include"address" information on what qualifier, variable or choice to assignthe data to.

2. Data is returned in the file RETURN.DAT. Data is passed out inPASS.DAT or on the command line.

3. Allows data to be passed back for any number of variables,qualifiers or choices.

H - EXTERNAL PROGRAM CALLS 26

Page 344: Manual Exsys

4. The return file has data in the form:

For qualifiers: Q <qual #> <value(s)>or

Q "name" <value(s)>

For variables: V <var #> <value>or

[var name] <value>

For choices: C <choice #> <value>or

C "text" <value >

H - EXTERNAL PROGRAM CALLS 27

Page 345: Manual Exsys

H14: DATALIST: Analyzing a Multiple Record Data Report

EXSYS has a very powerful capability to analyze, using expertsystem rules, a report containing multiple records of data;. Typically,such a report would come from a database manager or some otherexternal program. This is done through the use of the reportgenerator and the DATALIST command line option. The externalsource of the data must provide a report in the normal form of datapassed to EXSYS from an external program called at the start of arun (e.g. V2 4.7 means assign the value 4.7 to variable 2, or [X] 1.5means assign the value 1.5 to variable [X]). The individual sets ofdata to be analyzed must be separated by the command END. Forexample:

V 2 4.7[X] 2.3Q 1 2ENDV 2 5.3[X] 1.6Q 1 1END . . .

EXSYS MUST be started using the command line optionDATALIST, telling the program that there is data to be read (eventhough no external program was called) and that individual sets ofdata are separated by the END command. In the above example,EXSYS would read the first 3 lines, assign values to the designatedvariables and qualifiers and start applying the rules.

There should be a report specification file (the .OUT file) associatedwith the knowledge base that defines the order in which the resultsare to be sent to a disk file. This report specification should start with

FILE filename /A

The /A is important since you will want to append data to the outputreport for each set of data. The report specification MUST end withthe RESTART command to tell EXSYS to start its analysis again.Since we used the DATALIST command, EXSYS will automaticallyget the next set of data. EXSYS will automatically stop when it runsout of data.

H - EXTERNAL PROGRAM CALLS 28

Page 346: Manual Exsys

This allows batch analysis of database records without userintervention and, with this technique, an expert system can be createdto analyze raw data from an external source and produce a report ofthe analysis.

For example, the report file might contain:

FILE ACCTDUE.RPT /AFIRST "Accounts Overdue"C1 =10 /V2RESTART

This report will print the title "Accounts Overdue" and a list ofaccount numbers (or names) contained in variable 2. Choice 1 wouldbe set to indicate if the account was overdue. Only when choice 1was set to a value of 10 would the value of variable 2 be printed tothe file. The RESTART command tells EXSYS to immediately readthe next set of data.

The data passed in would include name or account number alongwith other data to determine the status of the account.

H - EXTERNAL PROGRAM CALLS 29

Page 347: Manual Exsys

H15: DATAREAD: Reading a File of Data

A DATAREAD command is similar to a DATALIST option, butDATAREAD is an internal command while DATALIST is aconfiguration option. Inputting the DATAREAD command isdescribed in Section H15. The data in the file read by aDATAREAD command is the same as in a RETURN.DAT filereturning with a /M option. The END command used in DATALISTfiles should not be used.

H - EXTERNAL PROGRAM CALLS 30

Page 348: Manual Exsys

Chapter I

Customizing the User InterfaceWhen an expert system is created with EXSYS, there is a defaultformat for asking questions. This provides the normal EXSYS userinterface. For most systems, this interface is appropriate. However,in some cases, it is desirable to change the look of EXSYS. Thereare a variety of ways to do this.

The customization techniques covered in this section include:

1. Custom help screensThese allow a user to select the Explain Question menu item on theQuestions menu to get more detailed information on what theexpert systems' question means. These help screens are generated bythe author of the expert system.

2. Custom question screensThese allow the developer to redefine the screens used to askquestions of the user. The screen definition language provides easycommands for defining screens.

3. HypertextProviding multilevel custom help for key words in rules, qualifiers,notes, etc. Hypertext keywords are highlighted in blue and clickingon a hypertext word brings up an explanation of the word. Theexplanation screens are designed using the custom screen language.

4. Qualifiers with values inserted in the middleNormally EXSYS qualifier conditions are made by having thequalifier text followed by one or more value text strings. It ispossible to have the text of the values inserted in the middle of thequalifier text. This allows some questions to be phrased more easily .

5. Adding special characters by ASCII codeCharacters that can not be directly entered in EXSYS text can beincluded by adding their ASCII code.

6. Embedding data in textData on the value of a qualifier or variable can be embedded in thetext of another choice, qualifier, note, reference or custom screen.This allows the easy creation of text that contains the actual datawhich being used in the run.

The first 3 items all use the EXSYS GUI Custom Screen DefinitionLanguage to define the custom screens or help screens. The samesyntax is used for all three.

I - USER INTERFACE 1

Page 349: Manual Exsys

I1: GUI Custom Screen Definition Language

EXSYS allows you to create custom screens to ask questions of theuser, provide custom help or hypertext help screens.

The use of custom screens allows you to customize the user interface.Custom screens are created with a word processor, text editor or canbe edited using the Screen menu item on the KB Files menu..

The screen definition language file consists of ASCII text. All linesare either commands or text to be echoed to the screen. Linesstarting with a ~ are commands. Many screens are stored in a singlefile and are separated by special commands that indicate the start of anew screen.

All of the ~ commands must be the only text on the line andthe ~ must be the first character on the line.

EXSYS enables you to design your own custom screens using GUIelements. These screens are used to ask for data in place of thedefault EXSYS screens. The screen designed with the ScreenDefinition Language are portable across the supported GUIenvironments (MS Windows, Macintosh, Open Look, Motif andPresentation Manager).

I - USER INTERFACE 2

Page 350: Manual Exsys

I2: Screen FilesThere are several different files that can contain the custom screendefinitions:

<knowledge base name>.SCRContains custom screens to ask questions and screens for hypertextkeywords.

<knowledge base name>.HLPContains custom screens to provide custom help for questions.These screens are accessed by the Explain Question item of theQuestions menu.

Any file nameA file of custom screen commands can be called with theDISPLAY(file /C) command.

I - USER INTERFACE 3

Page 351: Manual Exsys

I3: Screen File StructureCustom screen files usually contain many separate screens in a singlefile. For example, each of the qualifiers and variables in an expertsystem might have its own screen. The screens are separated by aspecial command that indicates the start of a screen for a particulardata item. All commands following the identifier apply to that screenuntil either:

1. The end of the file is reached

2. A ~ identifier command indicates the start of the screen fora new qualifier, variable or hypertext keyword.

The syntax is:

~ Qualifier or Variable ID~~ Hypertext keyword

I3.1: Indicating the Qualifier or VariableThe definition of each custom screen designed to ask a question orprovide custom help is indicated by a ~ followed by an identifier forthe qualifier or variable. The identification can be by name or bynumber. There should be no other text on the line.

~Q # Following screen is for qualifier #~Q "name" Following screen is for qualifier "name"~V # Following screen is for variable #~ [var name] Following screen is for variable [var name]

For example:

~Q 1 indicates the start of the custom screen forqualifier 1

~Q "DAY" indicates the start of the custom screen forthe qualifier named "DAY"

~V 4 indicates the start of the custom screen forvariable 4

~[X] indicates the start of the custom screen forvariable [X]

I - USER INTERFACE 4

Page 352: Manual Exsys

I3.2: Hypertext Keywords

For hypertext screens, the start of the screen for a keyword isindicated by ~~. The ~ is doubled to allow screen definitioncommands to be used as hypertext keywords.

For example:

~~length indicates the start of the hypertext screen for the keyword length

I3.3: Custom Screens for Confidence Variables

In confidence mode 5, the user can be asked for confidence valuesfor the input provided. These questions can make use of the customscreen option. A custom screen for a confidence variable is definedin the same way as for a regular variable or qualifier, but a % mustfollow the ~. For example, the custom screen for variable [X] wouldstart with:

~[X] or ~V #

The custom screen for the confidence associated with [X] would startwith:

~%[X] or ~%V #

Likewise the confidence associated with a qualifier would start with:

~%Q "name" or ~%Q #

I4: Returned DataSeveral of the screen elements can return information — buttons,mouse regions, scroll bars. The syntax of the returned data shouldbe the same as data returned from an external program. (SeeSection H6 for details of the syntax.)

Each item selected may return one line of data. A single screen canreturn multiple items of data. In most cases, a particular button mayindicate that the screen should terminate and return data. Sometimesclicking on any button will return data, in other cases multiple dataitems are set and then an OK button returns all of the data that wasset.

I - USER INTERFACE 5

Page 353: Manual Exsys

In many cases, the returned information needs to contain a quote, ",character to designate a qualifier name or choice text string. Sincethe screen commands use " " to designate strings, a " character in thestring will be incorrectly handled. To avoid this problem, withinquoted strings a single quote character ' can be used. This will beconverted to a " when the string is returned. For example, if wewant to set value 1 of the qualifier named color, the normal returnstring is

Q "COLOR" 1

but in a button command use:

~BUTTON("RED", "Q 'COLOR' 1", 200, 300, 60, 30 - I)

notice that the word color is marked with ' rather than ". When thestring is returned, the ' will be converted to " to return Q "COLOR"1.

I4.1: Returning Commands

In addition to returning information, buttons, mouse regions andscroll bars can return commands. The commands are the same asthose which can be returned from an external program.

!WHY Displays the current rules being tested!? or !HELP Displays the custom help file associated

with the qualifier or variable!KNOWN Displays the known data!EXIT Exits the program!END Terminates a hypertext stack - returns to

the starting screen even if there are several levels of hypertext screens

For example, if a button was defined as:

~BUTTON("Why?", "!WHY", 200, 300, 60, 30 - I)

clicking on the button would display the rules that caused thequestion to be asked.

I - USER INTERFACE 6

Page 354: Manual Exsys

I4.2: Passing Back a Hypertext Call

In addition to returning information, button, mouse regions and scrollbars can return a call to display a EXSYS hypertext keyword. If thereturn data starts with an "?", the remainder of the string will beused as hypertext keyword.

If a hypertext word is returned, EXSYS will display the customscreen after displaying the screen(s) associated with the hypertextword, so that data can be obtained. This allows custom screens toaccess the hypertext system, but still be able to obtain the neededdata.Note in a custom screen the ^^word^^ is not used. Custom screensecho text to the screen exactly as it is defined. It is the responsibilityof the developer to add hypertext buttons, or mouse regions andcontrol the highlighting of the screen.

The syntax is:?keyword

For example, if a mouse region was defined:

~MOUSE("?Part 23", 200, 300, 60, 30 -I)

If a mouse click was made in the specified regions , EXSYS woulddisplay the hypertext screen associated with the keyword "Part 23".Passing back !END will terminate a hypertext stack and return to thestarting screen, even if there are several levels of hypertext screens.

I5: Syntax for a RCTThe following commands frequently require specifying a rectangle onthe screen. In the commands this is abbreviated RCT. The syntaxfor an RCT is:

left side, top, horizontal size, vertical size

For example 10,10, 100, 50 means a rectangle 100 pixelshorizontally, and 50 pixels vertically with the upper left corner at thecoordinates 10,10.

I - USER INTERFACE 7

Page 355: Manual Exsys

I6: Setting the Window SizeThe window size is set by the ~SET_WIN rct command. It mustbe the first line in the screen definition for each screen. For example:

~SET_WIN 50,50, 400, 300

will make the overall window 400 pixels wide and 300 pixels highwith the upper left corner at 50,50.

If there is no SET_WIN command, the default window size is set to:

100,100,350, 250

It is the responsibility of the developer to make sure that all text,buttons, etc. are within the window size specified.

The window created will start at the size specified, but can be resizedand moved by the end user. If you do not want the end user to beable to move or resize the window, repeat the SET_WIN commandtwice at the start of the file. This will force the window to remain thesame size. For example:

~SET_WIN 50,50, 400, 300~SET_WIN 50,50, 400, 300

will prevent the window from being moved or resized.

I7: Embedded VariablesText may be embedded in the commands in a custom screen fileusing [[ ]]. However, all embedded variables must have a valueprior to being used. Double square bracket expressions in a customscreen will not invoke backward chaining or other actions to derive avalue. The value must be already known. See Section I16 for thedetails of double square bracket replacement.

I - USER INTERFACE 8

Page 356: Manual Exsys

I8: GUI Custom Screen Commands

~ARROW x, y direction

Draw an arrow from current point to x,y. End "arrow" sets newstarting point for the next line. The point of the arrow is controlledby the direction parameter.

direction:START - arrow points to startEND (default) - arrow points to endBOTH - arrow has points on both ends

~BACKGROUND color

Sets the background and foreground color. To set entire screen to acolor, set background and then do ~CLS. For lines and rectangles,see ~LINE_COLOR and ~FILL_COLOR.

color:REDGREENBLUECYANMAGENTAYELLOWBLACKDKGRAYGRAYLTGRAYWHITE#, #, # red, green, bluevalues for custom colors

~BEEP

Causes a beep to sound.

~BUTTON "label", "return string", rct

Options: -I -C -R -S -E -A -P -X -D

I - USER INTERFACE 9

Page 357: Manual Exsys

Define a button. The button can be a push-button, check box orradio button.

label label for the button, in " "

return the string to return if the button is pressed,in

string " ". If the button is pressed, this is the stringthat will be returned to EXSYS. Thesyntax of the string should be the same asthat used for returning data from anexternal program into EXSYS.

If the return string is "~command",pressing the button causes the specifiedcommand to execute immediately.Command can be any EXSYS GUI screendefinition command (However ~PAUSE isNOT recommended, and should not benecessary). This is especially useful with~GOTO commands. When the ~commandform is used, normally the -X option willalso be used. If more than one commandis to be executed, separate commands with"|||" (Three vertical line characters).

Note: If double quotes, " , areneeded in the return prefix for dataelement identification, or to define acommand string, replace " with ' .The ' will automatically be convertedto " when the string is used.

rct left side, top, horizontal size, vertical size

Options:-I return immediately if this button is pressed.

(option - default=NO)-C make button a check box

(option - default=normal button)-R make button a radio box

(option - default=normal button)-S for radio buttons only: Indicates START of the

set of radio buttons. Only one item in this set canbe selected at a given time.(default=include in current set)

I - USER INTERFACE 10

Page 358: Manual Exsys

-E for radio buttons only: Indicates END of the setof radio buttons. Only one item in this set can beselected at a given time.(default=include in current set)

-A Make active at start - make the button the default.-P Break a ~PAUSE. Write current data and

continue with the next command after thePAUSE.

-X No output in return file - use for command orinformation buttons.

-D Delete command after executing it.Note: If the return string = ~commandform is used, in some cases the commandshould only be executed once - even if thebutton is pressed multiple times.

The -D option will prevent multiple calls to thesame command. The command is again availablefor use after a reset, such as a ~PAUSE followedby a ~GOTO.

Note: Radio buttons must be defined as aset with sequential BUTTON commands.If more than one set is defined, the -S and-E flags should be used to designate theindividual sets. If there is only one set, the-S and -E commands flags are notnecessary, but the BUTTON commandsmust be sequential.

Examples:

~BUTTON "RED" "Q1 2" 100, 100, 60, 30 -I

will create a button labeled RED at pixel coordinates 100, 100 with ahorizontal size of 60 pixels and a vertical size of 30 pixels. If thebutton is pressed, the string Q1 2 will immediately be returned toEXSYS to set qualifier 1 value 2.

~BUTTON "YELLOW" "Q1 1" 100, 100, 60, 30 -R -S-A~BUTTON "RED" "Q1 2" 150, 100, 60, 30 -R~BUTTON "GREEN" "Q1 3" 200, 100, 60, 30 -R -E

will create a set of radio buttons button labeled YELOW, RED andGREEN. The starting active button will be the one labeledYELLOW. Since these are defined as a set, only one of the radiobuttons can be selected at a given time. Clicking on one will resetthe others. When the screen returns (due to some other button) thestring associated with the last button pressed will be returned to setthe qualifier.

I - USER INTERFACE 11

Page 359: Manual Exsys

~CANCEL

Cancel all information already written to return file and empty file.After the ~CANCEL command, new information can be written tothe return file. A ~CANCEL command is normally used as abutton command or controlled by a GOTO command. Toguarantee an empty return file, follow the ~CANCEL by a ~EXIT.

For example:

~BUTTON "Cancel" "~CANCEL|||~EXIT" 100, 100, 50, 50-I

~CLR_BUTTON

Delete all active buttons from the screen. Data on the buttons thatwere pressed prior to the execution of the ~CLR_BUTTONcommand, are written to the file before they are deleted.

~CLR_EDIT

Delete all active Edit regions from the screen. Information on theedit regions is written to the file before they are deleted.

~CLR_MOUSE

Delete all active Mouse regions from the screen. Information on themouse regions that were selected is written to the file before they aredeleted.

~CLR_SCROLL

Delete all active Scroll regions from the screen. Information on thescroll bars is written to the file before they are deleted.

I - USER INTERFACE 12

Page 360: Manual Exsys

~CLS

Clear window to current pattern and background color. Does notclear buttons, scrolls, edit windows or mouse regions. See CLR_ .

~CURSET x, y

Sets x,y coordinates for next echoed text and sets starting point for a~LINE or ~ARROW command.

x,y - x and y coordinates in pixels.

~EDIT "return prefix", rct

Options: -B -W -1 -H -V -S:x -L -R -F:filename -M:# -X

Add a text edit window to the screen. This can be used to ask fordata or present results and explanations.

Return Prefixprefix to write before value in return file. If the stringincludes ##, the ## will be replaced by the number ofthe line being returned. (e.g. "[addr ##]" would returna series of EXSYS variables [addr1], [addr2], etc. Thisshould usually be used with the -M option.).

Note: If double quotes, " , are needed in the returnprefix for data element identification, replace " with ' .The ' will automatically be converted to a " when thestring is used.

rct left side, top, horizontal size, vertical size

Options:-B Do not draw a border around box-W Do not Wrap text in the box-1 Allow only a single paragraph-H Disable automatic horizontal scroll-V Disable automatic vertical scroll-R Make text read only - no editing allowed-L Add all following screen command lines to

the edit window up to a ~LISTEND command

I - USER INTERFACE 13

Page 361: Manual Exsys

-F:filenameAdd the contents of file "filename" to the edit window

-S:x Set text size. X =B - use big fontS - Use small fontF - Use fixed space font

(Default is to use normal font)

-M:# maximum number of lines to return. This is not the maximum that is accepted in the edit window. If more than # lines are entered, they will be ignored. This preventscreating undefined EXSYS variables with ## in the return prefix.

-X Do not return data for this edit box. Information only. Even read only boxes will return data unless the -X option is used.read only box can be a convenient way to force a file of data into the return data file.

Examples:

~EDIT "", 20,20, 300, 200 -F:stuff.txt -R -X

will make an edit region at 20,20 with horizontal size of300 pixels and vertical size of 200 pixels. The text offile STUFF.TXT will be put in the edit region as a readonly file the will not return any data.

~EDIT "[S]", 20,20, 300, 30 -V -1

will make a edit region that will accept one line of textwithout vertical scrolling. The string entered will bereturned, preceded by [S] to indicate that the value is tobe assigned to the EXSYS variable [S].

~EDIT _FILL filename

Edit regions can have default values assigned to them with the -Land -F options. However, it may be inconvenient to add text toseveral edit regions at once. The EDIT_FILL command will add textto multiple edit regions from a single file.

I - USER INTERFACE 14

Page 362: Manual Exsys

First create the edit regions with ~EDIT commands, then call~EDIT_FILL filename. The file specified should contain the valuesto put in the edit regions. The file should be have one value per line.The value on the first line will be put in the first EDIT regionsdefined in the screen commands, the second line will be put in thesecond region defined, etc. To skip an edit region, leave a blank linein the file. If there are more lines than in the screen file, the extralines will be ignored.

~EXIT

EXIT immediately without writing any additional information to thereturn file. A CANCEL command is normally used as a buttoncommand, or controlled by a GOTO command. Data alreadywritten to the return file, will not be deleted. To guarantee anempty return file, follow the ~CANCEL by a ~EXIT.

~FILL_COLOR color

Sets color to use to fill shapes (rectangles and ovals).

color:REDGREENBLUECYANMAGENTAYELLOWBLACKDKGRAYGRAYLTGRAYWHITE#, #, # red, green, blue

values for custom colors

I - USER INTERFACE 15

Page 363: Manual Exsys

~FOREGROUND color

Sets the foreground color. Foreground applies to text echoed to thescreen. For lines and rectangles, see ~LINE_COLOR and~FILL_COLOR.

color:REDGREENBLUECYANMAGENTAYELLOWBLACKDKGRAYGRAYLTGRAYWHITE#, #, # red, green, blue

values for custom colors

~GOTO:label

GOTO to line ~:label. The GOTO point must be in the originallyspecified screen, defined by the ~word. It is not possible to GOTOa section of the screen file for another ~word.

GOTO should be used to go to a label point further DOWN in thefile. This is always safe. GOTO can be used to go back in the file,however the action is not exactly the same. When going furtherdown in the file, all current data is saved. When going UP in thefile, GOTO resets the starting point for window updates to that newline. Consequently, when going up in the file, it may be necessaryto restate some parameters such as color to make sure they are notlost in updates.

All buttons, scrolls and edit windows active when a GOTO is called,will stay active. This is to allow screens which can ask additionalinformation only when particular buttons are pressed. Moving upin the file makes it possible to make two copies of a button, scroll,or edit window. This can be a problem because each copy willwrite data back to the return file. In some cases, it is desirable torecreate buttons which have been cleared, but the screen designermust consider which buttons are active and which are inactivewhen moving UP the file. Use CLR_BUTTON, etc. and thenredefine the button if necessary.

I - USER INTERFACE 16

Page 364: Manual Exsys

~:label

GOTO branch point. Used from GOTO as a command or in returnstring from a button.

~LINE x, y

Draw a line from current point to x,y. End point sets new startingpoint for the next line.

x,y - x and y coordinates in pixels.

~LINE_COLOR color

Sets the color to be used for drawing for lines and borders of shapes.

color:REDGREENBLUECYANMAGENTAYELLOWBLACKDKGRAYGRAYLTGRAYWHITE#, #, # red, green, blue

values for custom colors

~LINE_WIDTH width

Set width, in pixels, for lines, arrows and the borders of shapes.

I - USER INTERFACE 17

Page 365: Manual Exsys

~MOUSE "return string", rct

Options: -I -2 -P -X -D

Define a mouse region. A mouse region is a region of the screenwhere a mouse click will cause some action to take place, or somereturn string to be flagged.

return string the string to return if the mouse isclicked in the rct. If the mouse is clickedin the region, this string will be returned toEXSYS. The syntax of the string shouldbe the same as that used for returning datafrom an external program into EXSYS.

If the return string is "~command",pressing the mouse will cause the specifiedcommand to be executed immediately.Command can be any EXSYS GUI screendefinition command (However ~PAUSE isNOT recommended, and should not benecessary). This is especially useful with~GOTO commands. When the ~commandform is used, normally the -X option willalso be used. If more than one commandis to be executed, separate commands with"|||" (Three vertical line characters)

Note: If double quotes, " , are neededin the return prefix for data elementidentification, or to define a commandstring, replace " with ' . The ' willautomatically be converted to a "when the string is used.

rct left side, top, horizontal size, vertical size of the mouse region

Options:

-I return immediately if the mouse is clicked in theregion. (option - default=NO)

-2 Return immediately only if a Double Click is donein the region

-P Break a ~PAUSE. Write current data andcontinue with the next command after the~PAUSE.

I - USER INTERFACE 18

Page 366: Manual Exsys

-X No output in return file - use for command orinformation regions

-D Delete command after executing it. If the returnstring = ~command form is used, in some casesthe command should only be executed once -even if the mouse is pressed multiple times in theregion. The -D option will prevent multiple callsto the same command. The command is againavailable for use after a reset, such as a ~PAUSEfollowed by a ~GOTO.

~OVAL rct

Draws an oval or circle with current line color and type. Fill iscurrent pattern and fill color. The RCT defines the maximum size ofthe oval.

rct left side, top, horizontal size, vertical size

~PATTERN pattern

Defines the pattern to be used for filling solids, rectangles and ovals.

pattern:NONE no patternHOLLOW emptySOLID solidHORZ horizontal linesVERT vertical linesFDIAG forward diagonalsBDIAG backward diagonalsCROSS CrosshatchDIAGCROSS Diagonal Crosshatch

~PAUSE

Pause the screen and wait for input. The ~PAUSE is broken by abutton with a -I or -P option or the EXIT line from the menu. Alldata elements selected will be written to file after the pause is broken.PAUSE can be used to create multiple part screens that write outsome data, clear and ask additional data.

I - USER INTERFACE 19

Page 367: Manual Exsys

~ROUND_RECT rct

Draws an rounded corner rectangle with current line color and type.Fill is current pattern and fill color.

rct left side, top, horizontal size, vertical size

~RECT rct

Draws an rectangle with current line color and type. Fill is currentpattern and fill color.

rct left side, top, horizontal size, vertical size

~SAMEAS word

Often there are two or more keywords that should call the samehypertext screens. Sometimes this is due to grammar (plurals forexample) or sometimes the words are just synonyms. When thereare different keywords calling the same screen, you could just repeatthe screen with the new keyword. However, that would waste spaceand be more difficult to maintain. The ~SAMEAS command allowsone keyword to be defined as another.

The word referenced must exactly match the ~~keyword line in the.SCR file.

The ~SAMEAS command must be the first (and only) line in the setof screen commands for a keyword being referenced to another.

Note: This command is ONLY used forhypertext screens.

For example, to define WORD1 to use the same screen as WORD2:

~~WORD1~SAMEAS WORD2

would cause the WORD1 hypertext screens to be called if WORD2was selected. Note: Be careful about loops!! In the above example,if we also had:

~~WORD2~SAMEAS WORD1

there would be a loop and the system would hang.

I - USER INTERFACE 20

Page 368: Manual Exsys

~SCROLL "return prefix", start_val,end_val, rct

Options: -V -H -A:value -D:x,y -X

Add a scroll bar to the screen. This can be used to graphically askfor numerical data or present results.

Return prefix to write before value in return file. ThisPrefix should usually be an identifier for what EXSYS

variable will receive the data.

Note: If double quotes, " , are needed inthe return prefix for data elementidentification, replace " with ' . The ' willautomatically be converted to a " when thestring is used.

start_val low range of slider valueend_val high range of slider valuerct left side, top, horizontal size, vertical size

Options:

-V Make slider vertical-H Make slider horizontal-A:value Initial value for the scroll thumb-D:x,y Display current value of scroll thumb at

coordinate x,y in current font and color. Set the font and colors before calling ~SCROLL.

-X No return value. Use to display info only.

~SET_WIN rct

Set window size and position - must be the first command.

rct left side, top, horizontal size, vertical size

text

A text string with no starting ~ is echoed to the screen in the currenttext size and color. A screen position can be set with CURSET, andthen sequential lines echoed to the screen. Line spacing will be setappropriately for the font size. All lines will have the left marginsaligned at the point set by the CURSET column position.

I - USER INTERFACE 21

Page 369: Manual Exsys

~TEXTSIZE size

Set the size of the text echoed to the screen, or displayed with a~SCROLL -D option.

Size:LARGENORMALSMALL

~VERIFY expression

The ~verify command allows user input for a variable to be verifiedagainst a boolean expression. It is used only for screens created toask for user input for variables - not for custom help screens,hypertext or screens for qualifiers. The program will accept userinput and then test it using the expression. The expression must be aboolean expression that will evaluate to TRUE for valid data. Theexpression can contain any valid EXSYS expression.

The ~VERIFY command will be considered the last command in thescreen definition for the variable. If the input passes the specifiedtest, processing continues. However, if the input fails the test, thecommands following the ~verify will be displayed and the originalquestion asked again to get appropriate input. This allows a custommessage to be displayed if the data was not appropriate.

Data verification, beyond simple range checking, can be removedfrom the rules and put in the VERIFY statement. This is muchsimpler and easier to maintain.

For example, suppose we have a variable [X] and only want toaccept integer values between 0 and 10 and we wanted to display amessage if the value was out of range. We could use:

~[X]screen commands for [X]

~VERIFY (([X]>=0) && ([X]<=10) &&([X]==INT([X]))

~SET_WIN 100,100, 300,200~PATTERN SOLID~BACKGROUND RED~CLS~CURSET 20,20The input provided is invalid.The value must be between 0 and 10 and be an integer.You input [[X]] which does not meet the criteria.~BUTTON "OK", "" , 20, 165, 50, 25 -I~END

more custom screens

I - USER INTERFACE 22

Page 370: Manual Exsys

The value input would be checked against the verify expression. Ifthe VERIFY expression was true, the program would continue anduse the data. If the expression was false, the custom screenscommands following the ~VERIFY up to the start of the next screenwould be displayed. The custom screen for [X] would then be re-displayed and new data requested.

Note: the command lines following the VERIFYshould have an OK button with a -I option or somethingequivalent to end the window.

The VERIFY option can also be used for string variables. Supposevariable [S] can only have one of three acceptable names:

~VERIFY (([S]=="JOE") || ([S]=="SAM") || ([S]=="MIKE"))

If the value for [S] is one of the three names it will be accepted,otherwise it will be rejected.

VERIFY can also be used with the custom screens for confidencevariables.

I - USER INTERFACE 23

Page 371: Manual Exsys

I9: Custom Screen ExamplesExample 1:

This is a screen with simple YES / NO buttons and some buttons forasking for additional information.

~Q "LIGHT" /* screen for Qualifier namedLIGHT */

~SET_WIN 30, 50, 500, 400 /* set window size */~PATTERN SOLID~BACKGROUND BLACK~CLS /* clear screen to solid black*/~FILL_COLOR CYAN~LINE_COLOR WHITE~LINE_WIDTH 5 ~ROUND_RECT 20,20,460, 300 /* draw accent box */~LINE_WIDTH 2~ROUND_RECT 30,30,440, 280 /* draw 2nd accent box */~FILL_COLOR BLUE~LINE_COLOR WHITE~RECT 30, 340, 440, 55 /* draw main rectangle */ /* add buttons to askquestions */~BUTTON "WHY", "!WHY", 60, 350, 80, 35 -I~BUTTON "KNOWN", "!KNOWN", 160, 350, 80, 35 -I~BUTTON "EXIT", "!EXIT", 260, 350, 80, 35 -I~BUTTON "HELP", "!HELP", 360, 350, 80, 35 -I~FOREGROUND BLACK~TEXTSIZE LARGE~CURSET 50,120 /* position cursor for text */The WARNING light is ON: /* write text message */~BUTTON "YES", "Q 'light' 1", 100,175,100,50 -I~BUTTON "NO", "Q 'light' 2", 300,175,100,50 -I~END

I - USER INTERFACE 24

Page 372: Manual Exsys

The WARNING light is ON:

YES NO

WHY KNOWN EXIT HELP

Example 2:

This screen has several check boxes. Multiple boxes can be checkedand the screen will not return until the OK button is pressed.

~~Q "SOUND" /* screen for qualifier"SOUND" */

~SET_WIN 30, 50, 500, 400 /* set window size */~SET_WIN 30, 50, 500, 400 /* make non movable */~PATTERN SOLID~BACKGROUND BLACK~CLS /* fill with solid black*/~FILL_COLOR CYAN~LINE_COLOR WHITE~LINE_WIDTH 5 /* draw accent box */~ROUND_RECT 20,20,460, 300~LINE_WIDTH 2~FILL_COLOR WHITE~ROUND_RECT 30,30,440, 280~TEXTSIZE NORMAL~FOREGROUND BLACK~CURSET 50,60 /* set position for following

text */

Reconnecting CABLE A to the system, with the power onand a signal in the amplifier produces:

/* define check boxes */~BUTTON "No Sound", "Q 'sound' 1", 75,100,150,40 -C~BUTTON "Static", "Q 'sound' 2", 75,160,150,40 -C

I - USER INTERFACE 25

Page 373: Manual Exsys

~BUTTON "Intermittent Static","Q'sound' 3",75,220,150,40 -C~BUTTON "Clicks", "Q 'sound' 4", 275,100,150,40 -C~BUTTON "Loud POP", "Q 'sound' 5", 275,160,150,40 -C~BUTTON "Good Sound","Q 'sound' 6", 275,220,150,40 -C~BUTTON "OK", "", 225,270,50,30 -X -I~END

Reconnecting CABLE A to the system with the power onand a signal in the amplifier produces:

No signal

Static

Intermittent Static

Clicks

Loud POP

Good Sound

O K

Example 3:

This screen is almost identical to that in Example 2, but the checkboxes have been changed to radio buttons. In Example 2, multipleboxes could be checked, while here only a single radio button can beselected. The screen will not return until the OK button is pressed.

~~Q "SOUND" /* custom screen for qualifier "SOUND" */

~SET_WIN 30, 50, 500, 400 /* set window size */~SET_WIN 30, 50, 500, 400 /* make non movable */~PATTERN SOLID~BACKGROUND BLACK~CLS /* fill with solid black*/~FILL_COLOR CYAN~LINE_COLOR WHITE~LINE_WIDTH 5 /* draw accent box */~ROUND_RECT 20,20,460, 300~LINE_WIDTH 2~FILL_COLOR WHITE~ROUND_RECT 30,30,440, 280~TEXTSIZE NORMAL~FOREGROUND BLACK~CURSET 50,60 /* set position for following text */

I - USER INTERFACE 26

Page 374: Manual Exsys

Reconnecting CABLE A to the system, with the power onand a signal in the amplifier produces:

/* define check boxes */~BUTTON "No Sound","Q 'sound' 1", 75,100,150,40 -R -S~BUTTON "Static", "Q 'sound' 2", 75,160,150,40 -R~BUTTON "Intermittent Static","Q 'sound'3",75,220,150,40 -R~BUTTON "Clicks", "Q 'sound' 4", 275,100,150,40 -R~BUTTON "Loud POP", "Q 'sound' 5", 275,160,150,40 -R~BUTTON "Good Sound", "Q 'sound' 6", 275,220,150,40 -R-E~BUTTON "OK", "", 225,270,50,30 -X -I~END

Reconnecting CABLE A to the system with the power onand a signal in the amplifier produces:

No signal

Static

Intermittent Static

Clicks

Loud POP

Good Sound

O K

Example 4:

In this case the radio buttons from example 3 have been rearrangedand an edit filed has been added to provide explanation. The textinput into the edit field is read only and not returned as data.

~~Q "SOUND"~SET_WIN 30, 50, 500, 400 /* set window size */~PATTERN SOLID~BACKGROUND BLACK~CLS~FILL_COLOR CYAN~LINE_COLOR WHITE~LINE_WIDTH 5 /* draw accent box */~ROUND_RECT 20,20,460, 300~LINE_WIDTH 2~FILL_COLOR WHITE~ROUND_RECT 30,30,440, 280~TEXTSIZE NORMAL~FOREGROUND BLACK~CURSET 50,60 /* position for writing text */

I - USER INTERFACE 27

Page 375: Manual Exsys

Reconnecting CABLE A to the system, with the power onand a signal in the amplifier produces:

/* add radio buttons */~BUTTON "No Sound", "Q 'sound' 1", 65,100,150,20 -R -S~BUTTON "Static", "Q 'sound' 2", 65,130,150,20 -R~BUTTON "Intermittent Static","Q'sound'3",65,160,150,20 -R~BUTTON "Clicks", "Q 'sound' 4", 65,190,150,20 -R~BUTTON "Loud POP", "Q 'sound' 5", 65,220,150,20 -R~BUTTON "Good Sound", "Q 'sound' 6", 65,250,150,20 -R-E~BUTTON "OK", "", 225,275,50,25 -X -I

/* define edit region */~EDIT "", 275,100,180,170 -S:S -X -R -L /* echo text into the edit region */

Connecting the cable to the system should be done with care.First turn off all power to the system. Check that all lights are off.Make all connections and then turn power back on, starting with thepreamp.Turn the amplifier on last. If the system makes a loud noise,turn it off immediately and check the fuses.

~LISTEND /* end of edit region text */~END

Reconnecting CABLE A to the system with the power onand a signal in the amplifier produces:

No signalStaticIntermittent StaticClicksLoud POPGood Sound

O K

Connecting the cable to the system should be done with care.First turn off all power to the system. Check that all lights are off.Make all connections and then turn power back on, starting with the preamp.Turn the amplifier on last. If the system makes a loud noise, turn it off immediately and check the fuses

Example 5:

This screen shows a set of SCROLL controls that return values to aset of EXSYS variables simultaneously. The current value of thescroll is echoed beneath it.

I - USER INTERFACE 28

Page 376: Manual Exsys

~SET_WIN 30, 50, 450, 320 /* set window size */~PATTERN SOLID~BACKGROUND BLACK~CLS~LINE_COLOR BLUE~FILL_COLOR BLACK~RECT 10,10,430,300 /* draw a border */~TEXTSIZE NORMAL~FOREGROUND WHITE~CURSET 20,30Select the filter pattern to apply to the signal:~TEXTSIZE SMALL~FOREGROUND YELLOW~curset 25,6020-40~SCROLL "[F 20 40] ", 1, 100, 27,80,36,135 -D:27,235 -V~curset 65,6040-80~SCROLL "[F 40 80] ", 1, 100, 67,80,36,135 -D:67,235 -V~curset 105,6080-160~SCROLL "[F 80 160] ", 1, 100, 107,80,36,135 -D:107,235 -V~curset 145,60160-320~SCROLL "[F 160 320]", 1, 100, 147,80,36,135 -D:147,235 -V~curset 185,60320-640~SCROLL "[F 320 640] ", 1, 100, 187,80,36,135 -D:187,

235 -V~curset 225,60640-1K~SCROLL "[F 640 1K] ", 1, 100, 227,80,36,135 -D:227, 235 -V~curset 265,601K-2K~SCROLL "[F 1K 2K] ", 1, 100, 267,80,36,135 -D:267,235 -V~curset 305,602K-4K~SCROLL "[F 2K 4K] ", 1, 100, 307,80,36,135 -D:307,235 -V~curset 345,604K-8K~SCROLL "[F 4K 8K] ", 1, 100, 347,80,36,135 -D:347,235 -V

I - USER INTERFACE 29

Page 377: Manual Exsys

~curset 385,608K-16K~SCROLL "[F 8K 16K] ", 1, 100, 387,80,36,135 -D:387,235-V~BUTTON "OK", "", 180,260,90,40 -X -I~END

Select the filter pattern to apply to the signal:

20-40

40-80

1k-2k

80-160

2k-4k

640-1k

320-640

160-320

4k-8k

8k-16k

50.5 50.5 50.5 50.5 50.5 50.5 50.5 50.5 50.5 50.5

O K

Example 6:

This screen is a multiple text edit, radio button and check boxwindow that could be used to enter a variety of information on aperson. When all of the data is entered, clicking on the OK buttonwould return the data entered. The [NAME##] form is used in thename and address field. Each line of the address will be returned as aseparate EXSYS variable. The first line will be returned as [NAME1]the second as [NAME2] etc. The same is done for the commentfield. This allows long addresses to be entered and used in EXSYS.It is the responsibility of the developer to make sure there are enoughappropriately named EXSYS variables to accept the data.

~SET_WIN 30, 50, 500, 400 /* set window size */~PATTERN SOLID~BACKGROUND BLUE~CLS~BACKGROUND WHITE~TEXTSIZE NORMAL~FILL_COLOR BLUE~LINE_COLOR CYAN

I - USER INTERFACE 30

Page 378: Manual Exsys

~LINE_WIDTH 2 /* draw accent box */~RECT 10,10,480, 380~FOREGROUND WHITE~CURSET 25,30Name & Address~EDIT "[NAME##]", 25,35, 200, 150 -W~CURSET 25,205Phone~EDIT "[PHONE]", 25,215, 200, 30~CURSET 25,270Social Security #~EDIT "[SSN]", 25, 275, 200, 30~BUTTON "MALE", "Q 1 1", 130,320,75,30 -R~BUTTON "FEMALE", "Q 1 2", 130,345,75,30 -R~BUTTON "OK","",40,330,40,40 -I~FILL_COLOR WHITE~LINE_COLOR WHITE~RECT 240,20,240,250~FOREGROUND BLUE~CURSET 260,35Experience~BUTTON "Technical", "Q 2 1", 270,40,130,30 -C~BUTTON "Sales", "Q 2 2", 270,65,130,30 -C~BUTTON "Management", "Q 2 3", 270,90,130,30 -C~BUTTON "Clerical", "Q 2 4", 270,115,130,30 -C~BUTTON "Other", "Q 2 5", 270,140,130,30 -C~CURSET 260,195Highest College Degree~BUTTON "HS", "Q 3 1", 260,200,60,30 -R~BUTTON "BS", "Q 3 2", 260,225,60,30 -R~BUTTON "MS", "Q 3 3", 340,200,60,30 -R~BUTTON "PhD", "Q 3 4", 340,225,60,30 -R~FOREGROUND WHITE~EDIT "[COMNT##]", 240,275, 240, 100 -S:S -LCOMMENTS:~LISTEND~END

I - USER INTERFACE 31

Page 379: Manual Exsys

Name and Address

Phone

Social Security #

Experience Technical Sales Management Clerical Other

Highest College Degree HS BS

Comments

O K MaleFemale

MSPhD

Example 7:

This example shows the use of the ~PAUSE command. Part of thescreen is displayed, and after pressing a button the rest of the screenis displayed. The "NOT within Spec" button will execute a GOTOcommand to display the rest of the screen and display the scroll bars.The "WITHIN spec" button will immediately return.

~SET_WIN 30, 50, 500, 400 /* set window size */~PATTERN SOLID~BACKGROUND BLACK~CLS~FILL_COLOR CYAN~LINE_COLOR WHITE~LINE_WIDTH 5 /* draw accent box */~ROUND_RECT 20,20,460, 300~LINE_WIDTH 2~ROUND_RECT 30,30,440, 280~TEXTSIZE NORMAL~FOREGROUND BLACK~CURSET 50,70The process temperature and pressuremeasurements are:~BUTTON "WITHIN Specs", "Q 'spec' 1", 50,120,140,30 -I~BUTTON "NOT within Specs", "~GOTO:spec",50,180,140,30 -X -D~PAUSE /* pause at this point */~:spec~LINE_COLOR RED /* highlight box */~LINE_WIDTH 4~RECT 46,176,148,38

I - USER INTERFACE 32

Page 380: Manual Exsys

~LINE_COLOR WHITE /* draw vertical line */~CURSET 210, 100~LINE 210,290

/* temperature scroll */~FOREGROUND WHITE~SCROLL"[TEMP]",170, 220, 220,120,215,10 -H -A:212-D:350,110~CURSET 220,110~FOREGROUND BLUETEMPERATURE /* add label */~CURSET 235,152~TEXTSIZE SMALL170 180 190 200 210 220

/* pressure scroll*/~TEXTSIZE NORMAL~FOREGROUND WHITE~SCROLL"[PRESSURE]",2.0,4.1,220,200,215,

10 -H -A:2.8-D:325,190~CURSET 220,190~FOREGROUND BLUEPRESSURE /* add label */~CURSET 235,232~TEXTSIZE SMALL2.0 2.5 3.0 3.5 4.0~TEXTSIZE NORMAL /* delete or move down */~FOREGROUND WHITE /* delete or move down */~BUTTON "OK", "", 235,245,80,50 -X -I~END

When the screen is first displayed it uses only the commands up tothe ~PAUSE:

I - USER INTERFACE 33

Page 381: Manual Exsys

The process temperature and pressuremeasurements are

WITHIN Specs

NOT within Specs

If the NOT within Specs button is press, the rest of the screen isdisplayed:

The process temperature and pressuremeasurements are

WITHIN Specs

NOT within Specs

170 180 190 200 210 220

TEMPERATURE 212.0

PRESSURE 2.8

2.0 2.5 3.0 3.5 4.0

O K

I - USER INTERFACE 34

Page 382: Manual Exsys

I10: EXSYS_CS Custom Screen Preview

You can test the custom screens that you develop without runningthe full expert system by using the program EXSYS_CS.

Use this syntax for calling EXSYS_CS:

EXSYS_CS filename ~word-R:ret_filename

filename file containing the screens

~word word to search for. Screen starts after ~~word in file

-R:ret_filename Filename to use as the return data file.Default = return.dat.

EXSYS_CS will display the custom screen specified in the commandline. If the program is called with no command line, it will ask for thename of the file and ~word to display.

If EXSYS_CS is called with only a file name, it will display all of thescreens in the file.

I - USER INTERFACE 35

Page 383: Manual Exsys

I11: Custom Screens to Ask Questions

EXSYS allows you to create custom screens to ask questions of theuser. These screens replace the standard format of the questionsasked by the program.

The use of custom screens allows you to customize the user interface.The screen definition language allows easy customization of thequestion screens, without having to write external program calls.

Custom screens can also be used to validate data before it goes to therules with the VALIDATE command. This can save many rules incomplex systems. In addition, explanation screens can be displayed ifthe data does not pass the validation test, and the user willautomatically be asked for new input.

Custom screens to ask questions are kept in a file named:

<expert system name>. SCR

This file must be in the same directory/path as the other knowledgebase files. If we had a knowledge base named TEST, the customscreen file would be TEST.SCR.

If a qualifier or variable has a custom screen, it will automatically beused in place of the normal EXSYS questions about the item. Thecustom screen is displayed and the program will then wait for theuser to supply an answer by clicking on a button or some otheraction.

Custom screens are created with a word processor or text editor.Lines starting with ~ are used to indicate the start of a custom screenor a screen definition command. See Chapter I for the details ofcreating a custom screen file.

If a qualifier or variable has an associated command, such as a RUNor dBase command, the command will be executed rather than thecustom screen.

Note: It is not necessary to have a custom screen for eachqualifier or variable. EXSYS will automatically use the defaultscreen if there is no custom screen.

I - USER INTERFACE 36

Page 384: Manual Exsys

To make a custom screen file, start a file named <knowledge basename>.SCR. Use the screen commands described in Chapter I tobuild the custom screen. You can check the screens quickly with theEXSYS_CS utility. It may take some experimentation to get thescreens the way you want them. The screens in this file will be calledautomatically when EXSYS needs information.

When Developing New Systems

The .SCR file makes it easy to have a custom interface for thequestions in your system, but remember, first make it work, thenmake it pretty.

When developing a new system, do not worry about custom screensuntil the logic of the system works. For development, just use thestandard EXSYS questions. When it is ready to be distributed tousers, then make custom screens to change the user interface if it isdesired.

I - USER INTERFACE 37

Page 385: Manual Exsys

I12: Context Sensitive Help Files

A user can create custom help files for their knowledge base. This isuseful where it may be necessary to explain in detail about a qualifieror variable. In general, it is best to keep the text of the qualifiers andvariables short, but sometimes a new user may require a long sectionof text to explain exactly what is needed for input. It would beconfusing to include all of the information in the text of the variableor qualifier, and it would not be desirable to print the information ineach rule. Also, once the user reads the full explanation once, theywill usually not need to do so again and will be able to answer theshort question on subsequent runs. The custom help files can providethe longer explanation, while still having short qualifiers.

The custom help file is very similar to the custom screen file to askquestions. To create a user help file, create an ASCII file with a texteditor, named:

<knowledge base name>.HLP

This file must be in the same directory/path as the other knowledgebase files. If we had a knowledge base named TEST, the help filewould be TEST.HLP.

The help file is defined using the custom screen commands describedin Chapter I. The order of the qualifiers or variables is unimportantand not all qualifiers or variables in a knowledge base need have acustom help screen in the file.

If a qualifier or variable does have a screen defined, the ExplainQuestion menu item under the Questions menu will be active.Selecting this menu item will display the custom help screen. Thecustom help screen can also be displayed by returning !HELP or !?from the custom screen used to ask a question, or from an externalprogram.

I - USER INTERFACE 38

Page 386: Manual Exsys

I13: Hypertext

EXSYS supports a hypertext help system. This system allows aseries of explanatory screens to be created that can be called asneeded by the user. The screens are indexed by keyword and can becalled from most of the EXSYS screens.

Hypertext is different from the custom help screens or the WHYcommand. The WHY command displays the logic of the rules thatlead to an item of information being requested. The custom helpscreen displays detailed information on the question being asked andwhat the user is expected to do. Hypertext is not associated with aspecific qualifier or variable, but with words. These words canappear in qualifiers, rules, choices, notes, etc. Whenever a hypertextkeyword is displayed on the screen, it will be highlighted in blue andthe user can ask for more information on what that word means bydouble clicking on it. It does not matter if the word is displayed aspart of a question, part of a rule or in the conclusions. If the userdoes not understand the word, he can get help by double clicking.

Most importantly, these hypertext keywords can appear in otherhypertext screens. This allows one hypertext screen to call otherhypertext screens to explain its keywords. This provides a multi-levelhelp system that can be very complex.

Hypertext screens can contain embedded EXSYS variables, so theexplanation can be specific to the data input. (NOTE: If embeddedvariables are used, make sure that they have a value (DATALIST,rules, etc.) before the hypertext screen is called.

I - USER INTERFACE 39

Page 387: Manual Exsys

I13.1: Defining Screens

The individual screens for each hypertext keyword are created andstored in the .SCR file for the knowledge base. This is the same fileas used for custom screens to ask questions. The hypertext screensare created using the screen definition commands described inChapter I. A screen is indicated to be a hypertext screen by puttingdouble ~ "~~" before the key word. So if the key word wasEXSYS, the entry in the .SCR file would be:

~~EXSYS screen definition

If the keyword "EXSYS" is flagged anywhere in the program andselected, this screen is displayed. The screen created can also containother keywords activated by buttons or mouse clicks.

Make sure that there is a screen for every keyword flagged in thesystem. In many cases, the use of the ~SAMEAS command willreduce the number of screens required.

I13.2: Flagging Keywords

To indicate that a word (or phrase) in an EXSYS system is ahypertext keyword, precede and follow it with ^^. The keyword orphrase can be up to 40 characters. It must be exactly the samespelling (including spaces) as the word in the .SCR file - but thematch is not case sensitive. Keywords can be flagged in the text ofqualifiers, variable prompts, choices, text only variables, notes, andreferences. Essentially any text that EXSYS puts on the screen canhave hypertext words flagged. For example, we might have aqualifier with an unusual word:

The ^^thermothrocal^^ temperature is ...

By putting thermothrocal in ^^, we have made it a hypertextkeyword. Whenever this qualifier is displayed on the screen,Thermothrocal will be highlighted in blue. This indicates that it is akeyword. The ^^ will not be displayed on the screen.

A screen can have up to 40 keywords simultaneously displayed.

The ~SAMEAS command can be used when there are twokeywords that call the same screens. This can often happen ifgrammar requires that the words not be quite identical. Forexample, you might have a sentence that has the wordthermothrocals. Selecting this as a keyword will not match on ascreen definition

I - USER INTERFACE 40

Page 388: Manual Exsys

starting with ~~thermothrocal (no ending S). Rather than repeat thescreen, just add an entry:

~~thermothrocals~SAMEAS thermothrocal

This will cause the thermothrocal screen to be called.

I13.3: Using Keywords

If a screen is displayed with hypertext keywords highlighted, and youwish to know about one of the words, double click the keyword.The screen defined for that word will be displayed. If this screen alsohas hypertext keywords, they can be selected to display a screen forthe new keyword. This can be repeated for many layers. As eachscreen is terminated (usually with an OK button), the previous(calling) screen will be displayed. If any of the screens return !ENDthe entire set of hypertext screens will be closed and the startingscreen will be displayed.

The !END command is usually returned from a Cancel button in thehypertext screens:

~BUTTON "CANCEL", "!END", 20, 300, 80, 30 -I

The inclusion of a Cancel button is an option for the systemdeveloper and is not required. However, if very deep multi-levelhypertext is expected, a Cancel button is a good idea.

I13.4: The .HYT File

There is a file created by EXSYS for indexing the hypertext - the.HYT file. This file is automatically created and should never bemodified by anyone. It contains offset information for the .SCR file.If a modification is made to the .SCR file, the .HYT file willautomatically be updated. This is done at runtime (either from theeditor or runtime program) and, for a large .SCR file may take a littletime. This is only done if the .SCR file has been modified. The .HYTfile allows much faster loading time and access to custom screens andhypertext screens. Remember to move the .HYT file with yourknowledge base if a copy is made. (However if you forget, EXSYSwill build a new one.)

I - USER INTERFACE 41

Page 389: Manual Exsys

I13.5: Example:

Suppose we have a qualifier:

The ^^thermothrocal^^ temperature is1 above ^^threshold^^2 at or below ^^threshold^^

We would enter this just as it is displayed here, with the ^^.

We might use this to build a rule:

IF:The ^^thermothrocal^^ temperature is ator below ^^threshold^^

THEN:......

When we run this system, any time the qualifier text is displayed,either to ask a question, display the rule, display the know data ordisplay the conclusions, the words "thermothrocal" and "threshold"will be highlighted and the ^^ will not be displayed. Any time thekeywords are displayed, the user could double click the highlightedword and select the hypertext screen for these words.

A .SCR file would contain the hypertext screens in it:

~~thermothrocalscreen commands...

~~thresholdscreen commands..

It is not necessary to have every screen call others, but the realpower of hypertext is its ability to create hierarchical help systemsthat provide the proper level of detail for any user.

I - USER INTERFACE 42

Page 390: Manual Exsys

I14: Inserting Value Text in the Middle of Qualifiers

EXSYS normally appends the text of the value(s) selected to the endof the qualifier text to create a condition. For example, if we havethe qualifier:

The color is1 red2 green3 blue

and we select 2, green will be added after the qualifier to make thecondition "The color is green". For most situations this is suitable,however, there are times when it is desirable to put the value text inthe middle of the sentence. EXSYS allows the value(s) to be putanywhere in a qualifier by inserting four underline characters, _ _ _ _, at the point where the values are to be inserted. For example youcould have:

The______is red1 house2 car3 boat

If you selected 2, the condition "The car is red" would be built.Users are asked the question with the four underline characters as afill-in-the-blank type question.

I - USER INTERFACE 43

Page 391: Manual Exsys

I15: ASCII Codes

ASCII control characters can be embedded in any text string byusing the notation @@### where # is the three digit ASCII code forthe character desired. There must be 3 digits following the @@even for codes less than 100. For example:

This @@013@@010 is

will replace @@013 with an ASCII 13 and replace @@010 with anASCII 10 and print a carriage return/line feed between "This" and"is".

The ASCII conversion is only performed during the run mode, soediting of the codes can be done in the edit mode.

WARNING: ASCII REPLACEMENT MUST BE USEDWITH CAUTION!!! Many operations in EXSYS aredesigned to stay within certain screen boundaries if standardalphanumeric text is used. Embedding ASCII codes cancause the text to go out of those boundaries with undesirableeffects. Embedded codes are best for simple formatting orprinter control in the report generator.

I - USER INTERFACE 44

Page 392: Manual Exsys

I16: Embedding Data in Text

EXSYS allows many text strings to be modified by havingembedded data in them to modify the text with the value of thevariable or qualifier.

I16.1: Variables

Data on a variable is embedded in text by entering its name indouble square brackets. The value of the variable will be used toreplace the [[var name]] in the text.

For example:

Hello, [[NAME]], please enter the value of X

would have [[NAME]] replaced by the value of the string variable[NAME]. If [NAME] had the value "John", the string would bedisplayed as:

Hello, John, please enter the value of X

EXSYS will usually backward chain during a run to derive the valuefor the variable in [[ ]] or will ask the user for a value. If WHY isused, or certain window operations are being performed, backwardchaining is turned off, and only known values will be used. In thiscase, rules may be displayed with [[ ]] expressions if there is no data.

The [[ ]] expressions can be used in:

QualifiersQualifier valuesChoicesNotesReferencesText associated with a variableCommand File lineReport generator commandsCustom screen commandCustom Help commands

One powerful use of double brackets is to have the [[ ]] expressionin a qualifier or variable text, contain a RUN ( ) command or otherinternal command.

I - USER INTERFACE 45

Page 393: Manual Exsys

For example, suppose we have a qualifier:

[[X]] The color is1. Red2. Green3. Blue

and we set the value of the string variable [X] toRUN(GETCOLOR). EXSYS will consider the text of the qualifier tobe

RUN(GETCOLOR) The color is

and will call the external program GETCOLOR for the value of thequalifier. We could easily assign a different external program to thequalifier by changing the value of [X].

Another application is to embed variables in the note or referencetext of a rule. This makes the note more precise to the data entered.For example, we might have an explanatory note:

Since the length is [[LENGTH]] and ......

The value of the variable [LENGTH] will be used in the note tomake a more precise statement explaining why the rule fired.

The embedded variables will be used in the display of results or intext printed from the report generator.

I16.2: Formulas

In EXSYS, replacement of [[ ]] is also supported in formulas,allowing the rules to self-modify the formulas being tested. Aformula is parsed for [[ ]] expressions before being evaluated.

For example, the formula 3[[X]]2 could have [X] be replaced with"+" for a value of 5 or "-" for a value of 1 or "7" for a value of 372.

I16.3: Qualifiers

The text of a qualifier and its values can also be used as an embeddedvariable. The syntax is:

[[*Q <qualifier number>]][[*Q "<qualifier name>"]]

I - USER INTERFACE 46

Page 394: Manual Exsys

Note: The * is required as the first character to indicatethe name is not a variable name.

The text of the qualifier/value will be placed in the string in place ofthe [[ ]] expression.

For example, suppose qualifier 3 is "The color is" and values "RED"and "BLUE" are set. If we had text:

The values set so far are: [[*Q 3]]

it would be displayed as:

The values set so far are: The color is RED and BLUE

I16.4: Embedding Qualifier Values

The full text of a qualifiers and its value can be embedded by using:

[[*Q #]] or [[*Q "name"]]

However this embeds the text of both the qualifier and all of thevalues that have been set. There are times when it is desirable toembed only the value(s) or the number(s) of the value(s) which areset. To do this use:

[[*QV #]] or [[*QV "name"]]

[[*QN #]] or [[*QN "name"]]

The [[*QV...]] will be replaced by the text of only the values set forthe qualifier. The [[*QN ...]] will be replaced by only the number ofthe values set.

For example, suppose we have a qualifier 5:

The color is1 red2 white3 blue

and value 2 is set:

[[*Q 5]] would be replaced with THE COLOR IS WHITE[[*QV 5]] would be replaced with WHITE[[*QN 5]] would be replaced with 2

I - USER INTERFACE 47

Page 395: Manual Exsys

I16.5: Embedding Expressions

In addition to single qualifiers or variables, entire expressions can beembedded in text. The syntax for this is:

<? expression ?>

The expression can be any EXSYS expression, involving numeric orstring variables. Any of the supported mathematical operators orfunctions can be used. The <? ?> syntax can be used to embed avalue in any EXSYS text, including qualifiers, notes, references,choices, report generator commands, command files, etc. Any placethat a [[ ]] can be used, a <? ?> can be used.

This eliminates the need to create temporary variables to embed indata. For example, we could have a note:

The sin of [[X]] is <? sin([X]) ?>

This would replace [[X]] with the value of [X] and then replace the<? ?> expression with the sin([X]).

String variables can also be used:

The part number is <? [str 1] + "-" + [str 2] ?>

The strings will be concatenated and then displayed.

Functions can also be embedded:

The largest is <? MAX([X], [Y], [Z]) ?>

I16.6: Recursive Brackets

A [[ ]] expression may be within another [[ ]] expression or withinthe <? ?> expression. This allows very complex expressions to begenerated:

For example, suppose string variable [FCT] is the name of afunction:

X was given the value <? [[FCT]]([Y]) ?>

If [FCT] had the value "TAN", the expression would become:

X was given the value <? TAN([Y]) ?>

which would then be evaluated.

I - USER INTERFACE 48

Page 396: Manual Exsys

I16.7: [[ ]] Replacement in the Report Generator and Command File

The [[ ]] replacement technique to insert the value of a variable in astring can also be used in the report generator and the commandlanguage commands. In the report generator, the variable must havea value already assigned. In the command language, if a variabledoes not have a value, backward chaining will be used to get a valueor the user will be asked for the value.

For example, the report generator command:

C >[[X]]

would replace the [[X]] with the value of variable X. Only choiceswith a value greater than X would be output.

I - USER INTERFACE 49

Page 397: Manual Exsys

Chapter J

Command Language

EXSYS Professional provides a command language to control theexecution of a knowledge base. The command language providescontrol mechanisms for the input of data, execution of rules, displayof results, looping, branching, etc. The command language can beused in conjunction with the report generator specifications for evengreater control. The command language is similar to DOS batchlanguage in many respects. Most of the individual commands arequite simple; however, the combination of commands allows greatpower and flexibility. External programs, report specifications andnamed subsets of the rules can be accessed by single commands.

The default command file for an expert system is in the following file:

<expert system name>.CMD

For example, if the name of the knowledge base file is TEST, thecommand file would be TEST.CMD. The command file must be inthe same subdirectory as the .RUL and .TXT portion of theknowledge base.

The command file is simply an ASCII file and can be created withany ASCII editor or word processor in ASCII mode. Note: Manyword processors add special formatting characters that will notproduce files that can be used as command files. If you are using aword processor, make sure it is in a mode that does not introducespecial characters. To check if the file has formatting characters,print the command file to the screen with TYPE <filename>. If thedisplay does not have unusual characters, it should work forcommand file editing.

The command file is optional. If a command file is not present,EXSYS will default to the standard mode of a backward chainingsystem using all rules and displaying results at the end of the session.If the command file is present, EXSYS will use it automatically.

J - COMMAND LANGUAGE 1

Page 398: Manual Exsys

J1: Changing the Name of the Command File

The name of the command file may be changed with the commandline or .CFG file option:

COMMAND=<file name>

The above redefines the name of the command file to be used.

J2: Expressions and VariablesWhile expressions can be evaluated in the command language, it isexpected that most of the evaluation of qualifiers, choices andvariables will be done in the rules. The command language allowsrunning named subsets of the rules to set values with conditionalbranching in the command language, depending upon the results.The use of rule subsets allows running only those rules that derive aparticular piece of information and then branch on the resultingvalue.

Note: All variables used in the command filemust be defined in the rule set.

J - COMMAND LANGUAGE 2

Page 399: Manual Exsys

Command Language

Request User Input for a Specific Item

ASK

The ASK command in the command file behaves exactly like theASK command in the .CFG file.

EXSYS will ask the user for the value of the qualifier(s) or variable(s)specified. If the qualifier or variable has an associated command suchas RUN( ) or DB_...( ), the appropriate action will be performed. Ifthere is no special operation to be performed, EXSYS will ask for theinformation using the standard request format or custom screen ifone has been created.

Syntax:

ASK Q # Ask qualifier number #.ASK Q "name" Ask the qualifier named or, if wild

cards are used in the name, ask all ofthe qualifiers that meet the name criteria.

ASK V # Ask variable #.ASK [var name] Ask variable named or, if wild cards

are used in the name, ask all of the variables that meet the name criteria.

Examples:

ASK Q "COLOR" will ask the qualifier named COLOR.ASK Q "A*" will ask all qualifiers whose names

start with A.ASK [TE*] will ask all variables whose names

start with TE.ASK [?D] will ask all variables whose names

are two letters ending in D.

J - COMMAND LANGUAGE 3

Page 400: Manual Exsys

Command Language

Make a Beep Noise to Alert User

BEEP

The BEEP command in the command file behaves exactly like theBEEP command in the .CFG file.

J - COMMAND LANGUAGE 4

Page 401: Manual Exsys

Command Language

Branch Point Label

Any line which has : as the first character will be used as a branchpoint label. Such lines will be ignored during normal execution andserve only as a branch point for a GOTO command. The labelshould not include spaces and can be up to 15 characters long.

For example,

commands....:LOOP commands....GOTO LOOP

would return to the line ":LOOP" when executing the GOTOcommand.

Note: The matching of label names is not case sensitive.That is, a label ":loop" will be foundby a "GOTO LOOP," even though one is in upper caseand the other in lower case.

J - COMMAND LANGUAGE 5

Page 402: Manual Exsys

Command Language

Causes a "Change and Rerun" Option

CHANGE <loop pt.>

The CHANGE command causes a change/rerun option. All datainput by the user is displayed for the user to change. When the userdecides to run the modified data, the program goes to the <loop pt>label in the command file. All data is cleared out before going to theloop point.

The following example,

:LOOPRULES ALLWHILE ([X]<100) CHANGE LOOPWENDRESULTS

would run the rules and keep asking for changed input until [X] wasgreater than 100.

J - COMMAND LANGUAGE 6

Page 403: Manual Exsys

Command Language

Allow Command Files to be Commented

Comments: /*

Anything on a line following /* is ignored. This allows comments tobe included in the command file.

Starting spaces are ignored.

The following example,

/* This is a comment

would be ignored by the program.

ASK [X] /* get the value of X

would perform the ASK command and ignore the comment startingwith /*

A note to C programmers: The /* does not carryover to other lines and does not require a */ to end thecomment.

J - COMMAND LANGUAGE 7

Page 404: Manual Exsys

Command Language

Erase Data or Reset Rules to Unused

CLEAR

The CLEAR command is the same as the internal CLEAR( )command, except it lacks the ( ). The CLEAR command is used toclear qualifiers, variables, choices or rules for re-use. The "ALL"and range options for CLEAR work from the command file, but notthe "THIS" option, which can only be used in the internal commandform from a rule.

Syntax:CLEAR Q # Clear qualifier number #.CLEAR Q "name" Clear named qualifier(s).CLEAR V # Clear variable number #.CLEAR [var name] Clear named variable.CLEAR C # Clear choice number #.CLEAR C "text" Clear choice containing "text."CLEAR R # Clear rule number #.CLEAR R "name" Clear named rule.CLEAR X a-b Clear all items between a

and b. The X can be Q, V, C or R for qualifier, variable, choice or rule.

CLEAR X ALL Clear ALL items. The X can be Q, V, C or R for qualifier, variable, choiceor rule.

CLEAR ALL Clear all qualifiers, variables and choices.

When a qualifier or variable is cleared, it is reset to an unknown stateand will be re-derived or re-asked if needed. If the confidence systemis custom formulas, the confidence variables associated with thequalifier or variable will also be cleared. When a choice is cleared, itis reset to its initial state. When a rule is cleared, it is reset to unusedand can be fired again.

J - COMMAND LANGUAGE 8

Page 405: Manual Exsys

Here are some examples:

CLEAR R 34-56 clears all rules from 34 through 56.

CLEAR Q 1-5 clears the first 5 qualifiers.

CLEAR R ALL clears all rules.

CLEAR V ALL clears all variables.

CLEAR Q"A*" clears all qualifiers whose NAME starts with A.

CLEAR R"XXX" clears the rule named XXX.

CLEAR C"ZZZ" clears all choices that have the string "ZZZ" in them.

CLEAR R"?XX" clears all rules with 3 character names ending in "XX."

J - COMMAND LANGUAGE 9

Page 406: Manual Exsys

Command Language

Call Another Command File

CMDFILE

The CMDFILE command allows calling and executing anothercommand file from within a command file. The called command filecan end with

EXIT, in which case the program will return to theoperating system

or

DONE, in which case the program will continue with the nextline in the calling command file.

Syntax:

CMDFILE <filename>

<Filename> is the name of the new command file to run.

The following example,

commands....IF [X] > 0 CMDFILE FILE1ELSE CMDFILE FILE2ENDIFcommands....

will check the value of [X]. If it is greater than 0, the commands incommand file FILE1 will be run; if not, the commands in FILE2 willbe run. Unless the called command file ends with an EXITcommand, the commands following the ENDIF will be run.

J - COMMAND LANGUAGE 10

Page 407: Manual Exsys

Command Language

Cause the Next Record of Data to beRead from a DATALIST File

DATALIST <loop pt.>

The DATALIST command causes the next set of data to be readfrom the DATALIST file. The DATALIST option must still bespecified as a command line option.

Note: The first set of data is read from the datalist filebefore the .cmd file is started.

The DATALIST command causes the next set of data to be read.After data is read, the program branches to the loop point specified.If there is no more data, the branch is not executed and the programfalls through to the next command in the .cmd file.

DATALIST does not clear any data. It should be preceded bywhatever CLEAR commands are needed for the particular system,usually CLEAR ALL.

The following example,

:LOOPRULES ALLREPORT XXXCLEAR ALLDATALIST LOOPBEEP

runs all rules and writes a report for each set of data. The CLEARALL prevents data from a previous run from being kept in the nextrun. The DATALIST command causes the next set of data to beread and then the program to branch to the line labeled :LOOP.When there is no more information, the DATALIST command doesnot go to LOOP, but ratherfalls through to the BEEP.

J - COMMAND LANGUAGE 11

Page 408: Manual Exsys

Command Language

dBase III Interface Commands

The DB_... commands are essentially the same as the DB_ ... internalcommands used in rules. These commands allow direct reading andwriting from dBase III files without the overhead of loading the entiredBase program.

Four commands allow the command language to read or writedirectly from dBase III files. dBase III files can be accessed fromrules, the report generator or the command files. The syntax of thecall is the same in each case.

Note: Underlined items can be repeated multiple times.

Get data from db file by key:DB_GK(<db file>, <index file>, <index value>,<field name>, <address>)

Put data in db file by key:DB_PK(<db file>, <index file>, <index value>,<field name>, <var name>)

Get data from db file by record number:DB_GN(<db file>, <rec #>,<field name>, <address>)

Put data in db file by record number:DB_PN(<db file>, <rec #>, <field name>, <var name>)

<db file> The full name of the dBase III file to be used.

<index file> The full name of the file that has the index of the <db file>.

<index value> The value to search for in the idex.<field name> The name of the field that

contains the data to be read from or the name of the field to be written to.<var name> The name of the EXSYS variable

in []. The value of the variablewill be read or written to the specified db field. The name always applies to the field name specified toits left.

J - COMMAND LANGUAGE 12

Page 409: Manual Exsys

<address> The item in which to store the data obtained. The item can be a variable,qualifier or choice. For a variable, use the name of the variable in [ ]. For a qualifier, use "Q" followed bythe number of the qualifier or the name of the qualifier in quotation marks. For a choice, use "C" followed by the number of the

choice or a unique text string inquotation marks. There must not beany spaces in the string between the C, Vor Q and the number or quotation mark.

<rec #> The number of the db record to use.

The database file name, index name and index variable can be avariable. <var name> must be an EXSYS variable.

Since the field name and associated variable can be repeated as manytimes as desired, multiple fields from the same record can be passedor returned on a single call.

The data returned for qualifiers or choices, should be in the sameform as if it were being returned for an external program call. Forexample, if the database call returned "1,2,3" to a qualifier, it wouldset the first three values of the qualifier to true.

The following example,

DB_PN(parts.dbf, 5, price, [X])

will WRITE the value of variable [X] into field "price" of record 5 ofdatabase "parts."

DB_GN(parts.dbf, 5, price, [X], number, Q1)

will READ the value of field "price" from record 5 of data base"parts" into variable [X] and the data in field "number" will be usedto set the value(s) in qualifier 1. If needed, there could be additionalfield and variable pairs in the expression to get more data from therecord.

DB_PK(parts.dbf, part.ndx, A567, price, [X])

will WRITE the value of variable [X] into field "price" of the recordin database "parts," indicated in the index file "part.ndx" by the value"A567."

DB_GK(parts.dbf, part.ndx, A567, price, [X])

will READ the value of field "price" into [X] from the record indatabase "parts," indicated in the index file "part.ndx" by the value"A567."

J - COMMAND LANGUAGE 13

Page 410: Manual Exsys

Top Record Function

There is also a function which has been added for working withdatabases. The function returns the number of records in a databasefile. This is particularly useful when running an expert system againstevery record in a file. To call the function, use

TOPREC(<filename>)

where <filename> is the name of the database file in quotes.The following example,

TOPREC("price.dbf")

would return the number of records in the database file "price.dbf."This function can be used like sin( ), cos( ) or any other EXSYSfunction. It can be used most effectively in the command language.Here is an example:

SET [I] 0WHILE ([I] < TOPREC("price.dbf") . . . RULES ALL REPORT DBRPT . . . SET [I] ([I]+1)WEND

The above would run the rules against each record in a database,producing a report with the report specification DBRPT. Theprogram could get data one record at a time with a DB_... call.

J - COMMAND LANGUAGE 14

Page 411: Manual Exsys

Command Language

Display the Contents of a File

DISPLAY

The DISPLAY command displays the contents of a file on thescreen. The user can go forward or backward in the file. This is thesame as the DISPLAY command in rules.

Syntax:

DISPLAY <filename> <options>DISPLAY [string variable name] <options>

filename - the name of the file to display.

string variable name - a string variable whose value is thename of the file to display.

Options/C - File to display uses GUI Custom Screen CommandsThe /C option causes the DISPLAY command to parsethe file for Custom Screen Commands. See Chapter Ifor a discussion of the GUI Custom Screen Language.

/N - No wait after screen is displayedThe /N option causes the DISPLAY command to displaythe requested file in a window and immediately continueprocessing. This can be useful for report files that arecreated and displayed. By using the /N option, you mayhave several report data windows simultaneously active.

/S - Small textThe /S option causes the DISPLAY command to displaya text file using a small font. The default is to use alarger font. This applies only to ASCII files.

/F - Fixed size fontThe /F option causes the DISPLAY command to displaya text file using a fixed size font. This is useful foraligning columns of data. The /S and default fonts areproportionally spaced and aligning data can be difficult.This applies only to ASCII files.

J - COMMAND LANGUAGE 15

Page 412: Manual Exsys

The following example,

DISPLAY INTRO.MSG

will display the contents of the file INTRO.MSG on the screen.

DISPLAY scr1.scr

will display the file scr1.scr on the screen using Custom ScreenLanguage commands.

J - COMMAND LANGUAGE 16

Page 413: Manual Exsys

Command Language

Exit a Command File Called by AnotherCommand File

DONE

The DONE command is used to exit a command file when it hasbeen called from another command file. This differs from the EXITcommand which immediately exits to the operating system. DONEreturns to the calling command file to execute any followingcommands. If there are no following commands, DONE behaveslike EXIT.

Syntax:

DONE

The following example,

commands....DONE

in a command file called from another command file using theCMDFILE command would return to the initial command file andallow subsequent commands to be executed. An EXIT command inthe same place would go to the operating system without returningto the initial command file.

J - COMMAND LANGUAGE 17

Page 414: Manual Exsys

Command Language

Exit to the Operating System

EXIT

The EXIT command terminates the run and returns to the operatingsystem.

Syntax:

EXIT

The following example,

commands....IF [X]>[Y] EXITENDIF

would exit to the operating system if the value of [X] is greaterthan [Y].

J - COMMAND LANGUAGE 18

Page 415: Manual Exsys

Command Language

Unconditional Branch

GOTO

The GOTO command causes an unconditional branch to another linein the command file.

Syntax:GOTO <label>

<Label> is the text of the branch point to go to. The branch pointmust be a single line starting with a : and containing the text of<label>. The reference to the label in the GOTO command does notuse the ":".

The following example,

:LOOP commands...GOTO LOOP

will cause the program to return to the line :LOOP when the "GOTOLOOP" command is found.

Use of GOTO with Nested IF or WHILE Structures

If there are nested IF or WHILE structures, the GOTO commandshould not be used to go to a deeper nesting level. It is legal to usethe GOTO to go to the same or higher nesting level. This is becausethe IF or WHILE are looking for the next ENDIF or WEND thatthey encounter. If they go to a deeper nesting level, they will findanother ENDIF or WEND and not know that it applies to that level.As long as the nesting level is the same or higher, the program candetermine where it is.

J - COMMAND LANGUAGE 19

Page 416: Manual Exsys

For example, the following are legal (In all cases IF/ENDIF can bereplaced with WHILE/WEND).

IF [X]>0--GOTO X

ENDIF:X

_________________

:XIF [X]>0

--GOTO X

ENDIF

_________________

IF [X]>0--

:X-GOTO X

ENDIF

_________________

IF [X]>0--GOTO X-_

:XENDIF

_________________

J - COMMAND LANGUAGE 20

Page 417: Manual Exsys

IF [X]>0-IF [Y] < 10

--GOTO X-

ENDIF-_

:XENDIF

_________________

IF [X]>0-IF [Y] < 10

--GOTO X-

ENDIF-_

ENDIF:X

The following is not legal because the GOTO jumps over an IF to adeeper nesting level. This will not be caught as an error, but maygive incorrect results.

IF [X]>0-GOTO :XIF [Y] < 10

--

:X-

ENDIF-_

ENDIF

J - COMMAND LANGUAGE 21

Page 418: Manual Exsys

Command Language

Allow Conditional Execution of Blocksof Rules

IF....ELSE....ENDIF

The IF command allows conditional execution of blocks ofcommands.

Syntax:IF <expression> commands....ELSE (optional) commands....ENDIF (not optional)

<expression> can be any mathematical expression that could beevaluated in the IF portion of a rule.

If the expression is true, the commands immediately following areexecuted until an ELSE or ENDIF is encountered. If the expressionis false and an ELSE is present, the commands following the ELSEwill be executed. In either case, execution will continue with the linefollowing the ENDIF.

IF commands can be nested. Each IF must have a matching ENDIF,though.

The following example,

IF [X]>0 CLEAR [X] RULES 1-10ELSE RULES 20-30ENDIF

will test if [X] is greater than 0. If it is, [X] will be cleared and rules1 through 10 will be run. If [X] is less than or equal to 0, rules 20-30 will be run.

J - COMMAND LANGUAGE 22

Page 419: Manual Exsys

IF [NUMBER FOUND] = 10 GOTO ENDENDIFcommands.....:ENDcommands....

will check if the variable [NUMBER FOUND] is equal to 10. If it is,the program will branch to the point :END.

J - COMMAND LANGUAGE 23

Page 420: Manual Exsys

Command Language

Pause Until a Key is Pressed

PAUSE

The PAUSE command in the command language will cause theprogram to display a dialog box and wait until the OK button ispressed. There is no message displayed. This is usually used fordebugging a command file.

J - COMMAND LANGUAGE 24

Page 421: Manual Exsys

Command Language

Recover Data Saved with a QUIT orSAVEDATA Command

RECOVER [filename]

The RECOVER command restores the state of the run from data ina file created by QUIT or SAVEDATA.

Syntax:

RECOVER [filename]

The optional filename is the name of the file to read the data from. Ifthe file name is not present, the program will prompt the user for thename of the file to use.

The following example,

RECOVER PART1.DATRULES 35-200

will recover the data in file PART1.DAT and then run rules 35-200.

J - COMMAND LANGUAGE 25

Page 422: Manual Exsys

Command Language

Run a Report Generator Specification

REPORT

The REPORT command calls and executes a report generatorspecification file. This is the same as the internal REPORT commandand the REPORT command in the report generator itself.

Syntax:

REPORT <filename>

The following example,

RULES 1-200REPORT FIRST.RPT

would run the first 200 rules and then run the report specification fileFIRST.RPT to produce a report to disk file or screen, depending onthe contents of the report specification.

J - COMMAND LANGUAGE 26

Page 423: Manual Exsys

Command Language

Display the Results of the Run

RESULTS

The RESULTS command displays the standard EXSYS resultsscreen with options for change and rerun, etc. The same format andoptions as the final results display is used.

Note: The results of a command file run will not bedisplayed unless the RESULTS command is used.

Syntax:

RESULTS <options>

Two options are available:

/C:<loop point>This is the point to loop to if a change/rerun is selected.Since the command file will have used one or moreRULES commands to run the knowledge base, thestarting point for a change and rerun must be specified.The new data input for the change and rerun will bedone by EXSYS; the user must supply only the startingpoint. The following example,

ASK [X]:LOOPRULES [Y] /F/NRULES 1-100RESULTS /C:LOOP

will run the rules using two RULES commands andthen display the results. If change and rerun is selected,the program will allow the user to modify the data andbranch back to :LOOP.

The /C should always be used unless the change andrerun option has been disabled.

J - COMMAND LANGUAGE 27

Page 424: Manual Exsys

Command Language

Run the Rules or a Subset of the Rules

RULES

The RULES command has many variations and is used to execute allor a subset of the rules in the knowledge base. Either forward orbackward chaining can be used. The backward chaining can belimited to the same subset of rules or can be allowed to use all of therules.

Syntax:

RULES ALL Run all rules.RULES # Run rule #.RULES #-# Run rules # through #.RULES "name" Run named rules (wild cards

allowed).RULES C Run rules relevant to all choices.RULES C # Run rules relevant to choice #.RULES C #-# Run rules relevant to choices # - #.RULES C "text" Run rules relevant to choices with

"text" in them.RULES Q Run rules relevant to all qualifiers.RULES Q # Run rules relevant to qualifier #.RULES Q #-# Run rules relevant to qualifiers # - #.RULES Q "name" Run rules relevant to qualifiers

specified by name (wild cardsallowed).

RULES V Run rules relevant to all variables.RULES V # Run rules relevant to variable #.RULES V #-# Run rules relevant to variables # -

#.[name].

The default mode is backward chaining using all rules for derivationof information.

Options:

/F causes forward chaining.

/N suppresses all backward chaining (like theNOBACKWARD option). This should only be usedwith /F.

J - COMMAND LANGUAGE 28

Page 425: Manual Exsys

/L forces all backward chaining to derive neededinformation to be limited to the same subset of rules.If /L is not present, backward chaining can invoke rulesoutside of the specified subset.

/C clears all data out before starting the run.This is equivalent to

CLEAR R ALLCLEAR C ALLCLEAR V ALLCLEAR Q ALLRULES .....

If /C is not used, existing data from SET, ASK orprevious runs will remain and be used.

Rules are "relevant" to a qualifier, variable or choice if the qualifier,variable or choice appears in the assignment portion of the THEN orELSE part of the rule. The rules relevant to qualifier 3 would be allrules with qualifier 3 in the THEN or ELSE portion. The rulesrelevant to [X] would be all rules with conditions that start [X] ISGIVEN THE VALUE ..., but not necessarily rules that have [X] aspart of an expression assigned to another variable.

For example, suppose there are 100 rules:

RULES ALL would run all rules in backward chaining mode.

RULES ALL /F would run all rules in forward chaining mode.

RULES ALL /F /C would CLEAR all existing data and then run all rules in forward chaining mode.

RULES 5 would run rule 5.

RULES 1-10 would run rules 1 through 10 in backward chaining mode, with all rules used for backward chaining to derive information needed.

RULES 1-10 /L would run rules 1 through 10 in backward chaining mode, with only rules 1-10 used for backward chaining to derive information needed.

J - COMMAND LANGUAGE 29

Page 426: Manual Exsys

RULES Q 1-3 /F /Nwould run those rules that have qualifiers1, 2 or 3 in their THEN or ELSE parts in

a forward, NOBACKWARD mode.

RULES Q "A*" would run all rules relevant to qualifiers whose names start with A in a forward chaining mode, with ALL rules used for derivation of information needed.

RULES Q "A*" /Lwould run all rules relevant to qualifiers whose names start with A in a forward chaining mode, with ONLY the samesub-set of rules used for derivation of information needed.

RULES [X] /F would run all rules that derive a value for [X] in a forward chaining mode.

RULES [X] /F /C would CLEAR all existing data and then run all rules that derive a value for [X] in a forward chaining mode.

RULES C 3 would run all rules relevant to choice 3.

RULES C "blue" would run all rules relevant to the choice with the word "blue" in it.

J - COMMAND LANGUAGE 30

Page 427: Manual Exsys

Command Language

Run an External Program

RUN

The RUN command allows running an external program from thecommand file. Data can be passed to the program and optionallyreturned in RETURN.DAT to set variables, qualifiers and choices.The RUN command is the same as the run command in rules, withthe addition of the /D option and lacking ( ).

Syntax:RUN filename <parameters> <options>

<parameters> -optional data or variables to pass out to the external program.

<options]>-/D - causes the program to look for and read a RETURN.DATfile and to assign any data found to the appropriate variable,qualifier or choice. For information on the format of theRETURN.DAT file, see Chapter H on the internal commandRUN() (This automatically invokes the equivalent of the internalcommand /M option). If the /D option is not used, the programwill not look for or use a RETURN.DAT file, even if one iscreated by the external program.

/C - passes parameters on the command line.

/B - allows calling batch files of DOS commands.

/# - passes # parameters on the command line and the rest inthe PASS.DAT file.

See Chapter H for more information on / options.

The following example,

RUN TEST [X] /C

will run the external program TEST and pass it the value of [X] onthe command line. No data will be returned.

RUN TEST [X] /C /R

will run the external program TEST and pass it the value of [X] onthe command line. The program will receive data back in the fileRETURN.DAT.

J - COMMAND LANGUAGE 31

Page 428: Manual Exsys

Command Language

Save the Current System Data

SAVEDATA

The SAVEDATA command saves the current state of the run in afile, just as if a QUIT command were executed.

Syntax:

SAVEDATA [filename]

The optional filename is the name of the file to store the data in. Ifthe file name is not present, the program will prompt the user for thename of a file.

The following example,

RULES 35-200SAVEDATA PART1.DAT

will run rules 35-200 and save the input provided in the filePART1.DAT.

J - COMMAND LANGUAGE 32

Page 429: Manual Exsys

Command Language

Assign a Value to a Variable, Qualifier orChoice

SET

The SET command is used to assign values to choices, variables andqualifiers at the start of or during a run. The SET command can beused anywhere in a command file, but it is usually used at the start toset starting values.

Syntax:SET [var name] expression

Assign the value of the expression to the named variable.

SET V # expressionAssign the value of the expression to the variablespecified by number.

SET Q # {list of values}Set the specified values of qualifier number #.

SET Q "name" {list of values}Set the specified values of the name qualifier.

SET C # expressionAssign the value of the expression to the named choice.

SET C "text" expressionAssign the value of the expression to the choice specified by a unique text sub-string.

Here are some examples:

SET [X] 5

will assign the value 5 to variable [X]

SET [X] ([Y]/2)

will assign the value of one half [Y] to variable [X].If the value of [Y] is not known, the program willinvoke backward chaining to determine [Y] or ask theuser. The variables in the expression must be validEXSYS variables in the knowledge base.

J - COMMAND LANGUAGE 33

Page 430: Manual Exsys

SET V 3 3.14159

will assign 3.14159 to variable number 3.

SET Q 5 1,2

will set values 1 and 2 of qualifier number 5.If qualifier 5 was

The color is1. red2. blue3. green

this SET command would set values 1 and 2 or "Thecolor is red and blue."

SET Q "COLOR" 1

will set value 1 of the qualifier named "COLOR." Usingthe same qualifier as above, the result would be setting"The color is red."

SET C 7 1+2+3

will set the value of choice 7 to the expression 1+2+3 or6.

SET C "large" [X]+3

will set the value of the choice containing the sub-string"large" to the expression [X]+ 3. If the value of [X]were not known, it would be derived or asked.

J - COMMAND LANGUAGE 34

Page 431: Manual Exsys

Command Language

Execute a Block of Rules While aCondition is True

WHILE.....WEND

The WHILE command allows repeated execution of a block ofcommands controlled by a test expression whose value usuallychanges during the execution of the block of commands.

Syntax:WHILE <expression> commands....WEND

<expression>can be any mathematical expression that can be tested, such asthose used in the IF part of a rule.

The WHILE command will continue until the first WEND commandis encountered, at which point it will reevaluate the test expression. Ifthe test expression is true, the block of commands will be executedagain. If it is false, the program will continue with the first commandafter the WEND command.

WHILE commands may be nested, but each will end on the firstWEND encountered and each must have a matching WEND.

Note: A WEND must be used for each WHILE.

The following example,

WHILE [X] > 0 RULES 1-100 CLEAR R 1-100WEND

will execute rules 1 through 100 until [X] is less than or equal to 0.A FOR command is not part of the EXSYS command language, butan equivalent structure can be created using the WHILE and SETcommands. The following example (using the syntax of BASIC),

FOR X=1 to 50 STEP 2could be expressed

SET [X] 1WHILE [X] <= 50 commands.... SET [X] ([X]+2)WEND

J - COMMAND LANGUAGE 35

Page 432: Manual Exsys

Chapter K

Rule Compiler

The EXSYS Rule Compiler allows a text representation of expertsystem rules to be compiled to the internal EXSYS knowledge baserepresentation. The files produced by the rule compiler can be runwith the EXSYS Professional Runtime or Rule Editor. There aremany very substantial advantages to using the EXSYS Rule Editorover a word processor for most expert system development;however there are certain cases where the word processor approachhas definite advantages. The rule compiler is designed to be usedwhen those cases arise. It is not intended to be a replacement for theEXSYS Rule Editor for most knowledge base development.

Due to the nature of a compiler, certain syntactical information mustbe specified. The program has to be able to tell a qualifier from aformula, choice, etc. This is a disadvantage found in all rulecompilers (The EXSYS Rule Editor "knows" the difference from themenu items selected). The extra syntactical notation has been kept toa minimum and the word processor representation of the rules looksas much like the standard representation as possible. The syntaxinformation required does not make the rules difficult to read.The program can determine most syntactical information withoutassistance; however a few extra characters are required for qualifiersand choices. In addition, in special cases where the program mightbecome confused, it is possible to specify exactly what an item is.

The EXSYS Professional Rule Editor has an option to print the ruleswith the extra syntactical information needed for the rule compilerincluded. Such a file can be directly read back into the rule compiler.This option on the Professional Rule Editor plus the EXSYS RuleCompiler allows easy incorporation of word processor editing in thedevelopment cycle.

K - RULE COMPILER 1

Page 433: Manual Exsys

K1: Getting Started

This section assumes that you are familiar with EXSYS terminologyand rule structure. If you are new to EXSYS, read the sections ofthe manual on the EXSYS rule structure and terminology before youread this section.

If you are new to EXSYS, you should not start by using the textinput form of rules with the rule compiler. Instead, use the EXSYSProfessional Rule Editor (EDITXSP.EXE). It will make learning touse EXSYS much easier and faster. The Rule Editor provides menuprompts for input and provides most of the internal structureautomatically.

The development of an expert system is much faster with the RuleEditor than with the rule compiler. The Rule Editor allowsimmediate testing of rules and rapid editing. The Rule Compilerrequires loading the compiler, compiling, loading the runtimeprogram, loading the rules, running the rules, determining whatchanges to make, loading a word processor, loading the text form ofthe rules, making the changes, saving the rules and then loading thecompiler again. This is very time consuming compared to the RuleEditor.

However, for some types of changes the word processor form issuperior, and in some cases it is the only way to make certain typesof modifications. The rule compiler is easiest to use with printoutsfrom EXSYS which have the syntactical information added. Suchsystems can be modified with a text editor to perform changes thatare difficult or impossible to do with the Rule Editor. For example:

1. Changing the order of qualifier valuesPrint out the rules using the EXSYS editor. In the Qualifier:command, find the qualifier that you wish to change the order ofvalues in. Change the order of the values in the list. Compile withEXSYSRC. The qualifier values will now be in the new order.

2. Changing the order of ChoicesPrint out the rules using the EXSYS editor. In the Choice:command, change the order of the choices in the list. Compile withEXSYSRC. The choice values will now be in the new order.

K - RULE COMPILER 2

Page 434: Manual Exsys

3. Changing the confidence systemThis is a little more complicated, but it is not possible by any othermeans. Print out the rules with the EXSYS Editor. Using your texteditor, search for "Probability" or "Confidence." In each place that aconfidence is assigned, change it to a value appropriate to the newconfidence system selected. Then change the PROBABILITYSYSTEM: command to the system desired and re-compile. If thereare any values out of range, you will get an error message.

4. Moving an expert system to EXSYS from another shellMake a printout of the rules in the other shell. Change the syntax tothat required by the EXSYS Rule Compiler. Depending on howsimilar the other shell's syntax is to EXSYS, this may be easy ordifficult.

5. Creating similar blocks of rulesIn some systems, there are nearly identical blocks of rules that arerepeated several times. By printing out the rules and using the texteditor to make copies of the block of rules, you can then edit thecopies as needed and re-compile. In some cases this may be fasterthan entering the rules with the Rule Editor.

6. Correcting a system that has been damagedIn rare cases, it is possible for an expert system to become damagedby some error. Because of the use of pointers in EXSYS, suchdamage sometimes can be difficult to correct. However, if the rulescan be printed out, you can check the printout for possible errors andre-compile to produce an undamaged version of the program.

7. Building systems using a text editorDespite the advantages in building systems using the Rule Editor,some people prefer to use a text editor. The Rule Compiler diskcontains a file RULEFORM. This is a blank skeleton of the syntax ofan expert system for the rule compiler. Make a copy ofRULEFORM and use it to start editing. You can fill in the blanks forthe lines with text appropriate to your system or delete theunnecessary lines. A summary of the syntax for most commands isin the file as comments. The file also contains a skeleton for a rule.Make copies of this as needed and fill in the conditions. WithRULEFORM to remind you of the syntax, it should be relativelyeasy to build a set of rules.

K - RULE COMPILER 3

Page 435: Manual Exsys

K2: Starting the Rule Compiler

In addition the developing rules in the Rule Editor, rules can bedeveloped with a text editor and compiled with the Rule Compiler.The syntax for the rules in a GUI environment is the same as in thenon-GUI environments.

To run the rule compiler

1. Click on the Rule Compiler icon.

2. Select Open from the File menu.

3. Select the file to compile. The filename is the name of thefile holding the text representation of the rules to be compiled.This file can have any extension except .RUL or .TXT. Thecompiler will produce the two EXSYS files with the samename but with .RUL and .TXT extensions. The files will bewritten to the same directory as <filename>.

4. Select the option for file output and error messages:

a. Output file: The name displayed will have .TXT and.RUL extensions added to it for the resulting knowledgebase. This name can be changed by editing the namefield.

b. If you wish to have the error messages written to afile, check the "Write errors to file" box. The defaultname for the file will be set to <knowledge basename>.CER. This name can be changed if you wish.

c. The LIST ONLY mode is set. This requires that all qualifiers, variables and choices be defined prior to beingused in the rules. If you wish to have the compiler generate the lists of qualifiers, etc. during the compile,set LIST ONLY off.

5. Click on COMPILE

6. A window will display the progress of the compile. If anerror is encountered, the error and the section of code inwhich the error occurred will be displayed.

K - RULE COMPILER 4

Page 436: Manual Exsys

K3: Editing the Text Files

Text representations of the expert system rules can be produced witha word processor or text editor. The word processor or text editorused must not add special control characters. This may requireworking in a "non-document" mode. To see if the word processoradds special characters, produce a file and display it on your monitorwith

TYPE <filename>

If there are no unusual or extra characters, the word processor ortext editor should work with the rule compiler.

K4: Producing Files That Can Be Compiled

The EXSYS Professional Rule Editor has an option that allows it toprint the knowledge base to disk with the syntactical informationneeded by the compiler included. If you have an existing expertsystem that you wish to edit with a word processor, select the Printmenu item from the File menu.

K - RULE COMPILER 5

Page 437: Manual Exsys

Print to PRINTER

Print to FILE

Standard Output Format

Rule Compiler Format

C Code Replacement for Rules

Rules

Qualifiers / Variables

Cross Reference List

Formulas

One Per Page

Continuous

O K

Cancel

filename

Select Rule Compiler format and enter a filename for the output file.The file can have any name, but do not use a file with a .RUL or.TXT extension.

The listing will include all of the qualifiers, variables, choices, etc. andwill use the LIST ONLY command. If you add new qualifiers,variables or choices, they must be added to the starting lists or theLIST ONLY command (found on the first line of the listing) must bedeleted. If the LIST ONLY command is deleted, the new item willautomatically be added to the lists.

If you print the rules to disk without specifying that they are forword processor editing, the syntactical information will not be addedand the rules will not be able to be directly read back in with the rulecompiler. To compile such a listing would require adding thesyntactical information by hand.

K - RULE COMPILER 6

Page 438: Manual Exsys

K5: Commands

The compiler has a number of reserved command words. Thesewords have special meaning to the compiler only if they appear atthe start of a line. In all cases, preceding spaces or tabs are ignored.These words should not be used in your rules since the compilercould misinterpret them. This should not be a problem since allreserved words

1. Must be the first text on the line;2. End in a ":" , "=" or carriage return.

For example, the word AUTHOR in your rules would not cause aproblem since only AUTHOR: is a reserved word. LikewiseAUTHOR: in the middle of a line would not be considered a reservedword.

The meaning of the reserved command words will be discussedindividually.

Reserved Command Words:

/*SUBJECT:AUTHOR:STARTING TEXT:ENDING TEXT:EXTERNAL PROGRAM:DISPLAY THRESHOLD:PROBABILITY SYSTEM:INITIAL CHOICE CONFIDENCE:DISPLAY RULES:DERIVATION:QUALIFIERS:VARIABLES:CHOICES:LIST ONLYRULE:IF:MAXIMUM QUALIFIER=MAXIMUM VARIABLE=MAXIMUM RULE=MAXIMUM CHOICE=MAXIMUM CONFIDENCE=MAXIMUM FORMULA=

K - RULE COMPILER 7

Page 439: Manual Exsys

In addition to the above reserved words, there are other commandwords that have meanings when they follow one of the reservedwords. These are discussed in the sections on the individual reservedcommand words.

Note: In all commands, the EXSYS Rule Compiler iscase insensitive and preceding spaces or tabs areignored. Text that is part of a qualifier, variable, etc. cango over several lines. There is no end of stringdelimiter. The program will recognize when a newcommand has been reached.

K - RULE COMPILER 8

Page 440: Manual Exsys

Rule Compiler Command

Allow Comments to be Added to a File

COMMENTS: /*

In any line, text following a /* is treated as a comment and ignored.

If the /* is part of a quoted string it will not be considered the start ofa comment.

Other text or commands on the line preceding the comment will beused.

Any line can start with indenting spaces or tabs.

For example:

/* this is a commentQUALIFIERS: /* this is another comment

A note to C programmers: Unlike C, it is notnecessary to have a closing */ and comments do notcarry over to the next line.

K - RULE COMPILER 9

Page 441: Manual Exsys

Rule Compiler Command

Define the Subject of the Expert System

SUBJECT: <text>

The text following the SUBJECT: command is used as the title forthe expert system. All expert systems must have a title.

The Title is limited to 200 characters; however the lines will bemerged together. The text can be over multiple lines. The text isconsidered ended when there is a blank line or a line which startsanother command.

If you wish to embed special characters in the text, you can use the@@### control code as part of the text., where the ### is replacedwith the THREE digit ASCII code of the character you wish to use.For example, @@013 will insert a carriage return. See Section I15on @@### replacement for more details.

For example:

SUBJECT: This is the title of the expert system

or

SUBJECT: This is a subject line that continues over three lines.

EXSYS will consider this all part of the subject.

K - RULE COMPILER 10

Page 442: Manual Exsys

Rule Compiler Command

Define the Author of the Expert System

AUTHOR: <text>

The text following the AUTHOR: command is the name of theauthor of the expert system. All expert systems must have anauthor.

The author text is limited to 100 characters. The text can be onmultiple lines; however the lines will be merged together. The text isconsidered ended when there is a blank line or a line which startsanother command.

If you wish to embed special characters in the text, you can use the@@### control code as part of the text, where the ### is replacedwith the THREE digit ASCII code of the character you wish to use.For example, @@013 will insert a carriage return. See Section I15on @@### replacement for more details.

For example:

AUTHOR: Your name

K - RULE COMPILER 11

Page 443: Manual Exsys

Rule Compiler Command

Define the Starting Text of the System

STARTING TEXT: <text>

The text following the STARTING TEXT: command is used as thetext to display at the start of the expert system. The starting text isoptional.

The text is limited to 1800 characters. The text can be on multiplelines; however the lines will be merged together. The text isconsidered ended when there is a blank line or a line which startsanother command.

If you wish to embed special characters in the text, you can use the@@### control code as part of the text, where the ### is replacedwith the THREE digit ASCII code of the character you wish to use.For example, @@013 will insert a carriage return. See Section I15on @@### replacement for more details.

For example:

STARTING TEXT: This is the text thatwill be displayed on the screen whenthe expert system is run.

K - RULE COMPILER 12

Page 444: Manual Exsys

Rule Compiler Command

Define the Ending Text of the System

ENDING TEXT: <text>

The text following the ENDING TEXT: command is used as the textto display at the end of the expert system. The ending text isoptional.

The text is limited to 1800 characters. The text can be on multiplelines; however the lines will be merged together. The text isconsidered ended when there is a blank line or a line which startsanother command.

If you wish to embed special characters in the text, you can use the@@### control code as part of the text, where the ### is replacedwith the THREE digit ASCII code of the character you wish to use.For example, @@013 will insert a carriage return. See Section I15on @@### replacement for more details.

For example:

ENDING TEXT: This is the text that willbe displayed on the screen at the endof the expert system run.

K - RULE COMPILER 13

Page 445: Manual Exsys

Rule Compiler Command

Define an External Program to Call at theStart of a Run

EXTERNAL PROGRAM: <text>

The text following the EXTERNAL PROGRAM: command is usedas the name of the external program to call at the start of an EXSYSrun. The external program is optional.

The text is limited to 100 characters. The text can be on multiplelines. The text is considered ended when there is a blank line or a linewhich starts another command. The name of the external programand any arguments passed out to it follow the standard EXSYSsyntax for external programs. A RUN( ) is not needed since this isthe external call at the start of the program.

The following example,

EXTERNAL PROGRAM: TEST [X] /C

will call the external program TEST and pass it the value of variable[X] on the command line.

K - RULE COMPILER 14

Page 446: Manual Exsys

Rule Compiler Command

Set the Threshold for Choice Display

DISPLAY THRESHOLD: <value>

The value following the DISPLAY THRESHOLD: command is usedas the threshold value for choice display at the end of the run. To bedisplayed, a choice must have a value greater than this value. Thecommand is optional; however if it is not used, a default value of 0will be used.

The following example,

DISPLAY THRESHOLD: 5

will cause only choices with a value greater than 5 to be displayedwith the results of the run.

K - RULE COMPILER 15

Page 447: Manual Exsys

Rule Compiler Command

Define the Confidence System to be Used

PROBABILITY SYSTEM: <value>

The value following the PROBABILITY SYSTEM: command is usedto set the probability confidence value system used in the expertsystem. The command is required and a confidence system must bespecified before the rules are entered.

The value must be an integer between 1 and 5. The valuescorrespond to the confidence modes in EXSYS:

1. Yes / no system2. 0-10 system (O and 10 lock the values)3. -100 to +100 system4. Increment/ decrement system5. Custom formulas

See Chapters B and C on confidence systems for more informationon the various confidence systems and their relative advantages.

For mode 3, the number can be followed by a letter indicating howto combine confidence factors:

A Average valuesI Combine as Independent probabilitiesD Combine as Dependent probabilities

Characters after the first letter are ignored. See Chapters B and C onconfidence systems for more information on the method ofcombining confidence factors.

If there is no letter following the "3," the default is to use "A" for theaverage mode.

K - RULE COMPILER 16

Page 448: Manual Exsys

The following example,

PROBABILITY SYSTEM: 2

will set the system in the 0-10 confidence mode.

PROBABILITY SYSTEM: 3 I

will use the -100 to +100 mode with probabilities combined asindependent probabilities.

K - RULE COMPILER 17

Page 449: Manual Exsys

Rule Compiler Command

Set the Initial Choice Confidence Value

INITIAL CHOICE CONFIDENCE: <value>

This option applies only to confidence mode 5, custom formulas. Inthat mode, choices have an initial confidence value. The default valueis 0; however in some cases, other values may be more desirable.The INITIAL CHOICE CONFIDENCE: command allows the defaultto be changed.

The following example,

INITIAL CHOICE CONFIDENCE: 100

will set the starting confidence of all choices at 100.

K - RULE COMPILER 18

Page 450: Manual Exsys

Rule Compiler Command

Set Option to Display Rules as aSystem Runs

DISPLAY RULES: <value>

The value following the DISPLAY RULES: command is used to setwhether or not rules will be displayed when the expert system is run.The command is optional; however if it is not used, a default value of"not displayed" will be used.

The acceptable values are Y or YES, N or NO.

The following example,

DISPLAY RULES: YES

will cause rules to be displayed during the run.

The option to lock rule display off cannot be accessed from the rulecompiler since the compiler does not provide for passwordencryption.

To lock rule display off–

Compile the rules;Read the rules with the EXSYS Professional Rule Editor;Select parameters from the Options pull down menu;Select "Lock Display OFF" in the Rule Display Mode radio buttons and click on "OK;Select SAVE from the FILE pull down menu and select Password Protection.

K - RULE COMPILER 19

Page 451: Manual Exsys

Rule Compiler Command

Set Option for How Many Rules to Use inDeriving Information

DERIVATION: <value>

The value following DERIVATION: is used to set how many rulesare used in the backward chaining to derive needed information. Thevalue is a letter

A all rulesF first rule onlyN non-redundant rules

If there is no DERIVATION: command, the default mode is "A," useall rules.

Characters after the first character are ignored.

The following example,

DERIVATION: FDERIVATION: First rule

are both accepted and both mean use only the first rule that fires inbackward chaining.

K - RULE COMPILER 20

Page 452: Manual Exsys

Rule Compiler Command

Define List of Qualifiers and Parameters

QUALIFIERS:

This command allows inputting of a list of qualifiers with values andsetting of parameters. The qualifiers and their values usually shouldbe defined prior to their being used in the rules. However, theQUALIFIER: statement is optional and the list does not have to becomplete. Unless the LIST ONLY command is used, the compilerwill build the qualifier list from the qualifiers and their values found inthe rules. If the LIST ONLY command is used, any qualifiers orvalues found in the rules that do not match ones in the list willproduce an error message. It is recommended that the LIST ONLYoption be used with a complete qualifier list whenever possible tocatch any typographical errors that can occur when using texteditors.

Each qualifier has a number of parameters that can be set. Theseparameters control actions such as if the qualifier is displayed withthe results, the number of values a user can input, how confidencefor the qualifier is handled, etc. All parameter commands apply tothe qualifier set by Q> previously. Most parameter commands haveshorter alternate commands that can be used. The shorter alternateshave the same function as the full command. They are just quickerto type. Most parameters have default values that are automaticallyset when the new qualifier is found. These defaults can be changedwith the various parameter commands. It is not necessary to add theparameter command if the default value is appropriate.

Multiple qualifiers can follow a single QUALIFIER command.

The QUALIFIER list is optional and all qualifiers can be determinedfrom the rules.

Commands:

Q> <text>Indicates the start of a new qualifier. The text that follows theQ> will be used for the qualifier. The text can continue overseveral lines. The text will be applied to the qualifier until ablank line or another command is encountered. Parametercommands following the Q> command apply to that qualifieruntil the next Q>. (NO DEFAULT - required)

K - RULE COMPILER 21

Page 453: Manual Exsys

V> <text>Indicates the start of a new value. The text that follows the V>will be used for the value. The text can continue over severallines. The text will be applied to the value until a blank line oranother command is encountered. Up to 30 values can beassigned to a particular qualifier. (NO DEFAULT- at least onevalue required)

ASK CONFIDENCEAlternate: ASK CONF

Sets parameter to have the user asked for a confidence valuefor his input when he is asked for data on the qualifier. Thisparameter command applies only to confidence mode system5. The command is meaningless in other confidence systems.

This parameter command has no associated value. If it ispresent, the user will be asked to supply a confidence valueand if it is not present, the user will not be asked forconfidence and the default confidence value will be used.(Default=not asked)

DEFAULT CONFIDENCE= <value>Alternate: DEF CONF

Sets the default confidence value to assign in place of askingfor a confidence value. This parameter command applies onlyto confidence mode system 5. The command is meaningless inother confidence systems.

If the ASK CONFIDENCE command is not used, the qualifierwill be assigned an initial confidence value. The default valueto use is 1. This parameter command allows the initial value tobe changed. (For example, DEFAULT CONFIDENCE = 0sets the initial confidence value to 0 for the qualifier.)(Default = 1)

MINIMUM CONFIDENCE = <value>Alternate: MIN CONF

Sets the minimum range of acceptable values of user input of aconfidence value for the qualifier. This parameter commandapplies only to confidence mode system 5. The command ismeaningless in other confidence systems.

Used only with ASK CONFIDENCE. (For example,MINIMUM CONFIDENCE = -10 sets the lower bound forthe user confidence value at -10.) (Default = 0)

K - RULE COMPILER 22

Page 454: Manual Exsys

MAXIMUM CONFIDENCE = <value>Alternate: MAX CONF

Sets the maximum for the range of acceptable values of userinput of a confidence value for the qualifier. This parametercommand applies only to confidence mode system 5. Thecommand is meaningless in other confidence systems.

Used only with ASK CONFIDENCE. (For example,MAXIMUM CONFIDENCE = 10 sets the upper bound foruser input of a confidence value at 10.) (Default = 100)

DISPLAY AT ENDAlternates: DISP END, DISPLAY, DISP

Sets the parameter for the qualifier to be displayed at the endwith the results.

This parameter command has no associated value. If it ispresent, the qualifier will be displayed and if it is not present,the qualifier will not be displayed. (Default = not displayed)

DEFAULT VALUE = <value>Alternate: DEF VAL

Sets the default value that would be used in place of asking theuser to select a value. The default value is used only if valuescannot be derived from other rules. If a value can be derived,it will take priority and the default will not be used. Thedefault value for a qualifier is different from the initial value fora variable, which is always used. The default value is veryuseful for qualifiers that should not be asked of the user, orsituations where a default is appropriate. Never use defaultvalues for qualifiers on which you want the user to provideinput.

The value is the number of the value to use as a default. If thiscommand is not used, no default value is assigned and the userwill be asked for input. (For example, DEFAULT VALUE =2 causes the second value in the list to be used in place ofasking the user. ) (Default = none - no default value used forthe qualifier)

MAXIMUM ACCEPTABLE = <value>Alternates: MAX ACCEPT, MAXIMUM, MAX

Sets the maximum number of list values that the end user canselect. This allows the developer to specify that only one value

K - RULE COMPILER 23

Page 455: Manual Exsys

can be selected from the list. This is particularly useful in listswhich have mutually exclusive values or Yes/No questions.

The value is the maximum number of values that the end usercan select. If this command is not used, the user can select allvalues.(For example, MAXIMUM ACCEPTABLE = 1 only allowsthe end user to select one value from the list). (Default = allowall values)

DISPLAY CONFIDENCEAlternate: DISP CONF

Sets a flag to have the confidence displayed with the qualifier.This parameter command applies only to confidence modesystem 5. The command is meaningless in other confidencesystems.

If this command is present, the final confidence for the qualifierwill be displayed with the qualifier in the final display screen.If the command is not present, the confidence will not bedisplayed. Usually, the qualifier will only have the confidencedisplayed if it is derived from other rules.(Default=not displayed)

NAME=<name>Sets the name that is assigned to the qualifier. This name isused to refer to the qualifier in other rules, the commandlanguage, etc. By being able to refer to a qualifier by name,rather than by number, you do not have to be concernedabout rearrangements of qualifiers that may change thenumbering. (For example, NAME=ABCD assigns the nameABCD to the qualifier. (Default=blank)

K - RULE COMPILER 24

Page 456: Manual Exsys

The following example,

QUALIFIERS: /* start of the qualifier list

Q> The color is /* qualifier 1V> redV> whiteV> blueNAME= colorDISPLAY AT ENDDEFAULT VALUE= 2

Q> The day is /* qualifier 2V> MondayV> TuesdayV> WednesdayV> ThursdayV> FridayV> SaturdayV> SundayNAME= Day of weekMAXIMUM= 1

sets up a qualifier "The color is" with values red, white andblue. The qualifier has an associated name COLOR, and is setto be displayed at the end. The DEFAULT VALUE is set toWHITE, so the end user will never be asked this question; itwould be assigned the value WHITE if it could not bederived.All other parameters for qualifier 1 will be set to theirdefault values. The second qualifier is "The day is" with a listof days for values. The associated name is DAY OF WEEKand the end user can select only 1 value from the list.

K - RULE COMPILER 25

Page 457: Manual Exsys

Rule Compiler Command

New Qualifiers or Values Found in the Rules

If during the compiling of the rules, the compiler finds a qualifier orqualifier value that is not in the list, there are several alternativesdepending on the LIST ONLY and QUALIFIER: commands.

Both LIST ONLY and QUALIFIER: CommandsUsedThe new qualifier or value will be considered an error. Anerror message will be displayed and the new qualifier or valueignored. This is the default for rule listings produced from theEXSYS Professional Rule Editor which lists all qualifiers andvalues and uses the LIST ONLY command. This combinationcatches any typographical errors that may have occurredduring editing with a text editor. It prevents the inadvertentcreation of new qualifiers or values. No .RUL or .TXT fileswill be created.

QUALIFIER: Command Used Without LIST ONLYThe new qualifier or value will be added to the list, but a notewill be displayed to the user saying an unrecognized qualifier orvalue was found and the text displayed. This allows the user todetermine if there is a typographical error causing the newqualifier. This is best when the rules have been changed with aword processor, but the list of qualifiers and values has notbeen modified accordingly.

QUALIFIER: Command Not Used (no qualifier list)The new qualifier or value will be added to the list and the userwill not be notified. If this option is used, be very carefulabout typographical errors. A single character difference willcause the program to consider two qualifiers as different andto add the new one to the list.

If rules are read without a qualifier list

1. Compile the rules with the rule compiler.2. Read the compiled rules with the Rule Editor3. Print a listing of the rules from the Rule Editor andexamine the qualifier lists for incorrect qualifiers orvalues produced by typographical errors.

NOTE: If a qualifier or value is found in the rulesand added to the list, the parameters for thequalifier will be the default values listed above. Tohave something other than a default value, thequalifier must be in a QUALIFIER: command.

K - RULE COMPILER 26

Page 458: Manual Exsys

Rule Compiler Command

Define List of Variables and Parameters

VARIABLES:

This command allows the inputting of a list of variables and thesetting of various parameters for those variables. The list of variablesshould be defined prior to being used in rules. Multiple variables canfollow a single VARIABLE: command.

Variables cannot be created from the rules because the prompt forthe variables must be specified. At least the variable name, enclosedin [ ], and the prompt text must be listed prior to using a variable.The only exception is creating text only variables; this is discussedbelow.

Each variable has a number of parameters that can be set. Theseparameters control actions such as if the variable is displayed with theresults, how confidence for the variable is handled, etc. Allparameter commands apply to the variable set previously. Mostparameter commands have shorter alternate commands that can beused. The shorter alternates have the same function as the fullcommand. They are just quicker to type. Most parameters havedefault values that are automatically set when the new variable isfound. These defaults can be changed with the various parametercommands. It is not necessary to add the parameter command if thedefault value is appropriate.

Commands:

[<var name>] <prompt text>Defines a new variable. The text that follows the [ ] will beused as the prompt for the variable. The text for the promptcan continue over several lines. The text will be applied to theprompt until a blank line or another command is encountered.All variables, except text only variables, must be defined in theVARIABLE: command prior to their being used in theformulas.

The associated prompt text can include RUN( ) commands orother EXSYS internal commands. Also, the text can be a."text only" that can be flagged for display at the end of a run.(NO DEFAULT - required)

K - RULE COMPILER 27

Page 459: Manual Exsys

ASK CONFIDENCEAlternate: ASK CONF

Sets parameter to have users asked for a confidence value fortheir input when they are asked for data on the variable. Thisparameter command applies only to confidence mode system5. The command is meaningless in other confidence systems.

This parameter command has no associated value. If it ispresent, users will be asked to supply a confidence value and ifit is not present, users will not be asked for confidence and thedefault confidence value will be used. (Default=not asked)

DEFAULT CONFIDENCE = <value>Alternate: DEF CONF

Sets the default confidence value to use in place of asking for aconfidence value. This parameter command applies only toconfidence mode system 5. The command is meaningless inother confidence systems.

If the ASK CONFIDENCE command is not used, the variablewill be assigned an initial confidence value. The default valueto use is 1. This parameter command allows the initial value tobe changed. (For example, DEFAULT CONFIDENCE = 0sets the initial confidence value to 0 for the variable.)(Default = 1)

MINIMUM CONFIDENCE = <value>Alternate: MINCONF

Sets the minimum for the range of acceptable values of userinput of a confidence value for the variable. This parametercommand applies only to confidence mode system 5. Thecommand is meaningless in other confidence systems.

Used only with ASK CONFIDENCE. (For example,MINIMUM CONFIDENCE = -10 sets the lower bound forthe user confidence value at -10.) (Default = 0)

K - RULE COMPILER 28

Page 460: Manual Exsys

MAXIMUM CONFIDENCE = <value>Alternate: MAX CONF

Sets the maximum for the range of acceptable values of userinput of a confidence value for the variable. This parametercommand applies only to confidence mode system 5. Thecommand is meaningless in other confidence systems.

Used only with ASK CONFIDENCE. (For example,MAXIMUM CONFIDENCE = 10 sets the upper bound forthe user confidence value at 10.) (Default = 100)

DISPLAY AT ENDAlternates: DISP END, DISPLAY, DISP

Sets the parameter for the variable to be displayed at the endwith the results.

This parameter command has no associated value. If it ispresent, the variable will be displayed and if it is not present,the variable will not be displayed. (Default = not displayed)

TYPE = <value>Sets the type of variable. The acceptable values are

N for numeric,S for string, orT for text only.

The default type for the variable is N (Numeric). Having thewrong type for a variable will produce an error message whenthe system is run. (For example, TYPE=S sets the variabletype as string.) (Default = N)

INITIALIZE = <value>Alternates: INIT

Sets the initial value for a variable. This option assigns a valueto the variable when the system starts. A variable that is givenan INITIALIZE value will never be asked of the user.Typically, this is only used for counters. The default is to nothave the variable initialized. (For example, INIT=0 sets thevariable to be initialized to 0 at the start of a run.) (Default =not initialized)

K - RULE COMPILER 29

Page 461: Manual Exsys

UPPER LIMIT = <value>Alternates: UPPER LIM, UPPER

Sets the upper limit for acceptable user input of a value for thevariable. If the user inputs a value above this limit, it will berejected and the question reasked. The default is to not haveany limits on user input. (For example, UPPER LIMIT=100sets the upper limit for end user input for the variable to 100.)(Default = no limits)

LOWER LIMIT = <value>Alternates: LOWER LIM, LOWER

Sets the lower limit for acceptable user input of a value for thevariable. If the user inputs a value below this limit, it will berejected and the question reasked. The default is to not haveany limits on user input. (For example, LOWER LIMIT=0sets the lower limit for end user input for the variable to 0.)(Default = no limits)

DISPLAY CONFIDENCEAlternate: DISP CONF

Sets a flag to have the confidence displayed with the variable.This parameter command applies only to confidence modesystem 5. The command is meaningless in other confidencesystems.

If this command is present, the final confidence for the variablewill be displayed with the variable in the final display screen. Ifthe command is not present, the confidence will not bedisplayed. Usually, the variable will only have the confidencedisplayed if it is derived from other rules. (Default=notdisplayed)

K - RULE COMPILER 30

Page 462: Manual Exsys

The following example,

VARIABLES: /* start of variable list

[LENGTH] The length of the beam asmeasured in feet from the base to thetopDISPLAYUPPER LIMIT = 1000LOWER LIMIT = 0

[ERROR MSG] WARNING The materials maybe unsuitable for the project plannedDISPLAYTYPE = T

[X] RUN(GETLTH) The length of .... /* nextvariable

sets up a variable [LENGTH] with associated prompt "Thelength of ... ." The variable is set to be displayed at the endand the end user can only input values between 0 and 1000.All other parameters will be set to their default values. Thesecond variable is a text note to the user. It is marked as a"text only" variable. The third variable is [X] with anassociated prompt that includes a RUN( ) command.

Rule Compiler Command

Text Only Variables Found in the Rules

In the RULE: section, it is possible to use a Text Only variablewithout having pre-defined it. If the condition in the rules sectionstarts with T>, the text following will be considered the textassociated with a text only variable. If a "text only" variable with thistext has been pre-defined, it will be used. However, if there is nomatching variable, a new variable will be created, namedTEXTVAR#, where # is a unique number, and the text will beassigned to it. The defaults set for the variable will be TYPE=T,DISPLAY AT END. If the identical text is used in subsequent rules,this same variable will also be used. The use of the T> command isdiscussed in greater detail in the RULES: command section.

K - RULE COMPILER 31

Page 463: Manual Exsys

Rule Compiler Command

Define List of Choices

CHOICES:

This command allows input of a list of choices the goals the systemwill try to derive values for. The choices usually should be definedprior to their being used in the rules. However, the CHOICES:statement is optional and the list does not have to be complete.Unless the LIST ONLY command is used, the compiler will build thechoice list from the choices found in the rules. If the LIST ONLYcommand is used, any choices found in the rules that do not matchones in the list will produce an error message. It is recommendedthat the LIST ONLY option be used with a complete choice listwhenever possible to catch any typographical error that can occurwhen using text editors. Multiple choices can follow a singleCHOICE: command.

The choice command is optional. The choices can be selected fromthe rules.

Commands:

C> <text>

indicates the start of a new choice. The text that follows theC> will be used for the qualifier. The text can continue overseveral lines. The text will be applied to the choice until ablank line, another C> or another command is encountered.

The following example,

CHOICES: /* start of choice list

C> Choice 1C> Choice 2C> This is the text for choice number3, it goes over two lines.C> Choice 4

sets up 4 choices with the text indicated.

K - RULE COMPILER 32

Page 464: Manual Exsys

Rule Compiler Command

Use Only Defined Qualifiers, Variables andChoices

LIST ONLY

This command causes the rule compiler to use ONLY the qualifiers,variables and choices from the list specified with the QUALIFIER:,VARIABLE: and CHOICE: commands. If a qualifier, variable orchoice is found in the rules that does not match one of the pre-defined values, an error message will be displayed.

Even if this command is not used, the program will display amessage notifying the user when a new qualifier, variable or choice iscreated if there was a starting list of acceptable items. LIST ONLYprevents the new item from being added to the list and causes theprogram to issue an error message.

K - RULE COMPILER 33

Page 465: Manual Exsys

Rule Compiler Command

Define a Rule

RULE:IF:

The RULE: command or the IF: command indicates the start of anew rule. There can be an optional name for the rule following theRULE: or IF:. The RULE: command is optional, but the IF:command must be used in each rule. The RULE: and IF: commandsindicate the start of a rule which has the following structure:

RULE: <optional name> /* this line is optional

IF: <optional name>if_condition 1

AND: if_condition 2AND: if_condition 3AND: .....

THEN:then_condition 1

AND: then_condition 2AND: then_condition 3AND: .....

ELSE:else_condition 1

AND: else_condition 2AND: else_condition 3AND: .....

NOTE: < note text>REFERENCE: <reference text>

The RULE:, NOTE: and REFERENCE: parts are optional. The IF:and at least either a THEN: or ELSE: part are required. It is notnecessary to specify a rule name or number.

Each condition in the rule, except the first condition in the IF, THENand ELSE parts, must start with AND: or and:. Spacing andindenting is optional and the compiler will ignore it. The text ofindividual conditions can carry over multiple lines.

K - RULE COMPILER 34

Page 466: Manual Exsys

The conditions that the program uses to build the IF, THEN andELSE parts are the same as those created in the EXSYS ProfessionalRule Editor, but in some cases extra syntactical information must beadded so that the compiler can tell if the condition is a qualifier,formula or choice. The conditions can wrap over several lines. Alllines not starting with AND: or other command word are taken aspart of the same condition.

There are syntactical notations required in conditions. These havebeen kept to a minimum to have the rules for the compiler look asmuch as possible like the rules displayed in EXSYS.

1. Qualifiers with one or more values, must have each valueenclosed in { }.2. A Choice condition must start with >.3. Text to be assigned to a text only variable must start withT> or ".4. An EXSYS internal command not assigned to a text onlyvariable (created with the <X> command in EXSYS) muststart with X>.

K - RULE COMPILER 35

Page 467: Manual Exsys

Rule Compiler Command

Qualifier Conditions in Rules

qualifier [NOT] {value} [or][and] [{value}][more qualifier text]

Items in [ ] are optional.Items underlined can be repeated multiple times.Items in bold face are the minimum required.

In a condition built by using a qualifier and one or more values,EACH of the values used must be in { }. Each time a value is used,it must be enclosed in { }. It is not necessary to mark the "NOT" ifthe qualifier has already been defined. The program will recognizethat the qualifier is one it knows with a "NOT" added and treat itaccordingly. If multiple values are used, an optional "OR" or "AND"can be put between values. The "OR" or "AND" is ignored by theprogram and is optional. In the IF parts, multiple values are ORedand in the THEN or ELSE part the values are ANDed.

For example, if we have a qualifier THE COLOR IS with valuesRED, WHITE and BLUE, we could create conditions such as:

THE COLOR IS{RED}THE COLOR IS NOT {BLUE}THE COLOR IS {RED} OR {BLUE}

If there is qualifier text following the last value in { }, it will beconsidered a qualifier using the form that inserts the value text in themiddle of the qualifier text. See Section I14 on using qualifiers withvalues replaced in the middle of the text.

For example, the condition

THE {HOUSE} IS RED

would produce a qualifier

THE ____ IS RED

with associated value HOUSE.

If, during the compiling of the rules, the compiler finds a qualifier orqualifier value that is not in the current qualifier list, there are severalalternatives depending on the LIST ONLY and QUALIFIER:commands.

K - RULE COMPILER 36

Page 468: Manual Exsys

Both LIST ONLY and QUALIFIER: Commands UsedThe new qualifier or value will be considered an error. Anerror message will be displayed and the new qualifier or valueignored. No .RUL or .TXT files will be created.

QUALIFIER: Command Used Without LIST ONLY:The new qualifier or value will be added to the list, but a notewill be displayed to the user saying an unrecognized qualifieror value was found and the text displayed. This allows theuser to determine if there is a typographical error causing thenew qualifier. This is best when the rules have been changedwith a word processor, but the list of qualifiers and values hasnot been modified accordingly.

QUALIFIER: Command Not Used(NO qualifier list):The new qualifier or value will be added to the list and the userwill not be notified. If this option is taken, be very carefulabout typographical errors. A single character difference willcause the program to consider two qualifiers or valuesdifferent and to add the new one to the list.

If rules are read without a qualifier list

1. Compile the rules with the rule compiler.2. Read the compiled rules with the Rule Editor.3. Print a listing of the rules from the Rule Editor and

examine the qualifier lists for incorrect qualifiers orvalues produced by typographical errors.

Note: If a qualifier or value is found in the rules andadded to the list, the parameters for the qualifier will bethe default values listed above. To have something otherthan a default value, the qualifier must be in aQUALIFIER: command.

K - RULE COMPILER 37

Page 469: Manual Exsys

Rule Compiler Command

Choice Conditions in Rules

Confidence system 1-4:

IF:> choice [:] [-] Probability <test> <value>

THEN/ELSE: > choice [:] [-] Probability [=] <value>

Confidence system 5, custom confidence formulas:

IF: > choice [:] [-] Probability <test><expression>

THEN/ELSE: > choice [:] [-] Probability [=] <expression>

Items in [ ] are optional.Items in bold face are the minimum required.

1. In conditions using choices, the statement of the choice must bepreceded with a >.

Note: The > is not part of the choice text. It is aflag to indicate that the text which follows is a choice.

2. There can be an optional : or - following the choice. These areadded only for cosmetic purposes and consistency with the formused in the Rule Editor.

3. The word PROBABILITY has alternate words that can be used:

CONFIDENCECONF.CONF:PROB.PROB:

There is no distinction made between "Probability" and "Confidence"and their alternative shorter forms.

4. In the THEN or ELSE part of a rule, an optional = can follow"Probability." This is added only for cosmetic purposes andconsistency with the form used in the EXSYS Rule Editor.

K - RULE COMPILER 38

Page 470: Manual Exsys

<test> : In the IF part of a rule, a conditional test must follow"Probability." The acceptable tests are:

> greater than< less than<= less than or equal>= greater than or equal= equal<> not equal>< not equal

The test is applied between the final derived value of the choice andthe value or expression that follows.

<value> : In confidence modes 1-4, the last item in the choicecondition is a value. The value must be within the appropriate rangefor the confidence system being used:

Conf. mode Type Acceptable values

1 yes/no 0 or 1 2 0-10 0 to 10 (integers) 3 -100 to 100 -100 to 100 (integers) 4 inc/dec IF part: -10,000 to

10,000 THEN/ELSE part: -100 to 100

<expression> : In confidence mode 5, expressions are used inplace of simple values. The expressions can contain variables,confidence variables, etc. See Section C40 on custom confidenceformulas for information on this confidence system.

For example:IF:

> Choice 2: Prob.< 4THEN:

> Choice 1: Probability = 7

The starting > indicates the condition is a choice. If the probability of"Choice 2" is less than 4, then "Choice 1" will be given the value 7.

In confidence mode 5, we could have

IF:> Choice 2: Prob.< [X]/5

THEN:> Choice 1: Probability = [%Q 1] + 10

If the program finds choices not in its choice list, the choice will beadded to the list. If the LIST ONLY option was selected, unrecognizedchoices will produce an error message. If the CHOICE: command wasused, unrecognized choices will produce a note to the user.

K - RULE COMPILER 39

Page 471: Manual Exsys

Rule Compiler Command

Formula Conditions in Rules

IF part:

<expression> <test> <expression>

THEN/ELSE part:

<variable> IS GIVEN THE VALUE <expression>

or

<variable> := <expression>

<expression> : An expression can be any combination of variables,constants or functions that can be evaluated to a single value. Asusual in EXSYS, variables are indicated by text in [ ]. Theexpression can also use string constants or variables combined withthe + operator for concatenation. Do not mix string and numericitems in an expression or you will get an error message when therules are run.

<test> : The test is a comparison of two values. The acceptable testsare

> greater than< less than<= less than or equal>= greater than or equal= equal<> not equal>< not equal

<variable> : An EXSYS variable name in [ ]. The variable musthave been defined in a VARIABLE: command prior to being used.

The phrase IS GIVEN THE VALUE is used to indicate assignmentof value in THEN or ELSE parts. It can be shortened to IS GIVENor := to indicate assignment of value.

K - RULE COMPILER 40

Page 472: Manual Exsys

Formulas Starting with "For normal expressions, there is no change from the standardEXSYS Rule Editor syntax. However, if a formula condition in theIF part involves string variables and starts with a ", the compiler willthink it is a "text only" string and will not recognize it as a formula.To force the condition to be taken as a formula, precede it with M>.This will take precedence over the normal syntactical checks forexpressions. The "M>" can be used with all formulas, but is onlynecessary with string expressions starting with ".

The following example,

IF:"abc"+[Y] <> [X]

would not be interpreted correctly, while

IF:M> "abc"+[Y] <> [X]

would be treated as a string formula and evaluated.

K - RULE COMPILER 41

Page 473: Manual Exsys

Rule Compiler Command

Text Conditions in RulesFor text only variables:

T> textor

"text"or

[text only variable name]

For commands:

X> command

There are two types of text conditions in rules.

The most general is the text associated with a text only variable. Thisis text which will be displayed at the end of a run if a rule with thetext in it fires during the run. Such text has an associated variablename. The EXSYS Rule Compiler can accept either the name of thetext variable, if it has been pre-defined, or just the text starting with aT> or ". If the compiler finds text starting with T> or ", it will checkto see if the text matches any existing text only variable. If there is amatch, that variable will be used. If there is no match, the compilerwill create a new variable named TEXTVAR#, where # will be anumber, and assign it the text. The variable will be of type "textonly" and set for display at the end of a run.

A second type of text applies only to EXSYS. It is used only for thetext of an EXSYS internal command. In EXSYS it is not necessaryto have an associated variable with a command. Such text isindicated by preceding it with X> and then the command. SeeChapters C and G on the <X> command for more information oninternal commands. The allowable EXSYS commands are

STOP end runRESTART start overDISPLAY(...) display fileREPORT(...) run a reportCLEAR(...) clear out data or rulesDB_...(...) interface to dBase III filesRUN(...) run an external program

The X> form does not create an associated EXSYS variable and it isnot downwardly compatible to standard EXSYS. If you use the X>form you will not be able to save data in the standard EXSYSformat. For compatibility with standard EXSYS, you can use the T>form for commands in place of the X> form. This will associate avariable with the text. Unless the variable is predefined, it will be setfor display at the end of the run.

K - RULE COMPILER 42

Page 474: Manual Exsys

Text only variables can only be used in the THEN or ELSE part of arule. To execute RUN( ) commands in the if part, include theRUN(..) as the first part of the qualifier or variable text without a T>or X>.

For example:IF:

RUN(GETCOLOR) The color is {red}THEN:

T> this is a note that the color selected was redX> RUN(TEST2 [Y] /C)

The IF condition has a RUN( ) command as part of the qualifier.This is not a text variable. The RUN( ) will cause the externalprogram GETCOLOR to be run if the qualifier is needed. Thereturned value from GETCOLOR will set the value of the qualifier.The first THEN condition is a text only string which will beassociated with a variable. It will cause the note to be displayed atthe end of the run if the rule fires. The second THEN condition, withthe X>, will cause the external program TEST2 to be run and passedthe value of [X]. This will not be associated with a text variable sinceit uses the X> form rather than the T> form.

K - RULE COMPILER 43

Page 475: Manual Exsys

Rule Compiler Command

NOTE and REFERENCE Text

NOTE: <text>REFERENCE: <text>

A rule can have an optional note or reference associated with it. Thisis text that will be displayed with the rule (NOTE) or if requested(REFERENCE).

The text can be up to 1000 characters and can go over several lines.The lines will be concatenated to make the final note or reference.

The Note and Reference are optional.

K - RULE COMPILER 44

Page 476: Manual Exsys

Rule Compiler Command

Special Cases

The EXSYS Rule Compiler can determine the type of almost allconditions by the following rules: (these rules are in order ofprecedence)

Qualifiers: Any condition with a { } in it is a qualifier andthe text in { } is a value.

Formulas: Any condition using variables in [ ], except [[ ]]replacement expressions (see Section I16 on [[ ]]replacement), is considered a formula for testing in the IF partor assignment in the THEN or ELSE part.

Choices: Any condition starting with > is considered achoice.

Text: Any condition that starts with " , T> or X> isconsidered a text string or an EXSYS internal command.

This system works correctly for almost all EXSYS expert systemrules, and adds the minimum of extra syntax.

For example:

RULE: color

IF:The color is {red} or {blue}

AND: > Choice 1: PROB.>5AND: [X] > 10

THEN:The item is {A} and {B}

AND: [Y] IS GIVEN THE VALUE [X]/2AND: > The item is identified:

PROBABILITY=9

Note: This is the note for the rule

Despite minimal syntax information, the EXSYS rule compiler willbe able to correctly parse the above rule.

K - RULE COMPILER 45

Page 477: Manual Exsys

However, in some cases it is possible to confuse the compiler. Aformula that did not use variables, a formula using string expressionsthat started with a " or a qualifier that started with '>' might bemisinterpreted. These are rare exceptions, but if a statement is beingmisinterpret—which should produce an error message - you canoverride the normal parsing strategy. Starting a condition with Q>or M> forces the program to consider it to be a qualifier orMath/formula respectively regardless of other syntactical indications.The following example,

M>"abc" <> [x] will be considered a formula even through it starts with a ".

Q> > The ... will be considered a qualifier even though the actual text starts with a

>, indicating a choice.

The Q> and M> should be very rarely needed. Their function is onlyto allow an override of the normal parsing in exceptional situations.

K - RULE COMPILER 46

Page 478: Manual Exsys

Rule Compiler Command

Set Space Allocated for Compile

MAXIMUM QUALIFIER = <value>MAXIMUM VARIABLE = <value>MAXIMUM RULE =<value>MAXIMUM CHOICE =<value>MAXIMUM CONFIDENCE =<value>MAXIMUM FORMULA =<value>

When the rule compiler reads in the rules, it allows a certain amountof space for the items being read in. Since EXSYS is very compactand efficient, the arrays that are created can handle almost allsystems.

If the program runs out of space, it will reconfigure the arrays and tryagain; however this takes additional time. There are two times when itis desirable to change the default setting for the arrays. The first is ifthe program is being run in a computer with very limited memory andthere is not enough room for the large arrays. The second is if theexpert system is very large and changing the defaults will speed thecompiling process since the program will not have to make two passes.

The default values are:

Maximum number of qualifiers: 500Maximum number of variables: 500Maximum number of choices: 250Maximum number of rules: 2000Maximum number of formulas: 1000Maximum number of confidence formulas: 1000

This is more than enough for most systems. To change the defaultsup or down, use the appropriate MAXIMUM command. Thesecommands must appear at the start of the text representation of therules—within the first 20 lines.

The MAXIMUM commands are optional and it is unlikely thatyou will need to use them.

Note: It is not necessary to have the exact count of the rules,qualifiers, etc. The number need only be larger than what isneeded. The program will tell you and attempt to correct itselfif the number is too small or if you run out of memory.

The following example,

MAXIMUM RULES = 1000MAXIMUM VARIABLES = 2000

will allow space for 1000 rules and 2000 variables.

K - RULE COMPILER 47

Page 479: Manual Exsys

K6: Error MessagesThe rule compiler can detect many error conditions and will produceerror messages stating what line number the error is in, explain whatthe error is and then display the line with the error. Since one errorcan result in the compiler misinterpreting following lines, a singleerror may result in many error messages. Always correct the firsterror in the list first.

When an error is detected, the program displays the line number ofthe error and the text. In some cases the error may not be at thatexact line, but should be close by. This is especially true with textthat wraps over multiple lines.

ERROR 1: The EXSYS files created would overwrite this fileThe filename specified ended in .RUL or .TXT. The Rule Compilerneeds to create files with these extensions. To prevent accidentallyoverwriting the text file, the program will not allow files with .RULor .TXT to be used, even with the OUT= option. Rename the textfile and try again.

ERROR 2: File not foundThe program could not find the specified text file.

ERROR 3: Incorrect placement of THENA THEN: command was found that was not preceded by an IF:.

ERROR 4: Incorrect placement of ELSEAn ELSE: command was found that was not preceded by an IF:.

ERROR 5: Incorrect placement of NOTEA NOTE: command was found that was not preceded by a rule.

ERROR 6: Incorrect placement of REFERENCEA REFERENCE: command was found that was not preceded by arule.

ERROR 7: Unrecognized textText was found in the rule that was not identifiable. Check syntax.

ERROR 8: No qualifier specifiedAn attempt was made to set a parameter for a qualifier before thequalifier had been specified. All qualifier parameters apply to thequalifier that immediately precedes them.

ERROR 9: No = signThe parameter specified requires an = followed by a value.

K - RULE COMPILER 48

Page 480: Manual Exsys

ERROR 10: Qualifier text too longA qualifier is limited to 1000 characters. Check for syntax errorssuch as no "AND: " causing subsequent conditions to bemisinterpreted as part of the same qualifier.

ERROR 11: Identical qualifier already existsTwo qualifiers in the QUALIFIER: list have identical text.

ERROR 12: No space for qualifiersThe space reserved for qualifiers has been used up. The compiler willattempt to correct for this, but if it is unsuccessful, use theMAXIMUM QUALIFIER command to increase space.

ERROR 13: Qualifier value text too longA qualifier value is limited to 500 characters. Check for syntaxerrors such as no "AND: " or no closing } causing subsequentconditions to be misinterpreted as part of the same value.

ERROR 14: Unknown parameterText was found that could not be identified.

ERROR 15: No variable specifiedAn attempt was made to set a parameter for a variable before thevariable had been specified. All variable parameters apply to thevariable that immediately precedes them.

ERROR 16: Not legal TYPEThe type command must be followed by an N, S or T.

ERROR 17: No space for variablesThe space preserved for variables has been used up. The compilerwill attempt to correct for this, but if it is unsuccessful, increase theMAXIMUM VARIABLES parameter.

ERROR 18: No closing ]The variable specified did not have a closing ].

ERROR 19: Identical variable already existsTwo variables in the VARIABLE: list have identical names.

ERROR 20: No prompt following variable nameThe prompt text for the variable must follow the name.

ERROR 21: Variable prompt text too longA variable prompt is limited to 500 characters. Check for syntaxerrors causing subsequent text to be misinterpreted as part of theprompt.

K - RULE COMPILER 49

Page 481: Manual Exsys

ERROR 22: No space for choicesThe space reserved for choices has been used up. The compiler willattempt to correct for this, but if it is unsuccessful, use theMAXIMUM CHOICES command to increase space.

ERROR 23: Choice text too longA choice is limited to 500 characters. Check for syntax errorscausing subsequent text to be misinterpreted as part of the choice.

ERROR 24: Subject text too longA subject is limited to 500 characters. Check for syntax errorscausing subsequent text to be misinterpreted as part of the subject.

ERROR 25: No subjectAn expert system must have a subject line.

ERROR 26: Author text too longA choice is limited to 100 characters. Check for syntax errorscausing subsequent text to be misinterpreted as part of the author.

ERROR 27: No authorAn expert system must have an author line.

ERROR 28: Starting text too longStarting text is limited to 1800 characters. Check for syntax errorscausing subsequent text to be misinterpreted as part of the text.

ERROR 29: Ending text too longEnding text is limited to 1800 characters. Check for syntax errorscausing subsequent text to be misinterpreted as part of the text.

ERROR 30: External program text too longThe initial external program call is limited to 100 characters. Checkfor syntax errors causing subsequent text to be misinterpreted as partof the text.

ERROR 31: Illegal probability modeThe probability mode value must be an integer between 1 and 5.

ERROR 32: Value not recognizedAllowable values are Y, YES, N or NO.

ERROR 33: Note text too longNote text is limited to 1000 characters. Check for syntax errorscausing subsequent text to be misinterpreted as part of the text.

ERROR 34: Reference text too longReference text is limited to 1000 characters. Check for syntax errorscausing subsequent text to be misinterpreted as part of the text.

K - RULE COMPILER 50

Page 482: Manual Exsys

ERROR 35: Unrecognized text in ruleText in the rule could not be identified. Check for typographicalerrors in AND:, THEN:, ELSE:, NOTE: or REFERENCE:commands.

ERROR 36: Not enough memoryThe program was not able to allocate enough memory. If there are"ram disks" or memory resident programs running, delete them. Ifthat does not correct the problem, try setting the MAXIMUMparameters to lower values (or if they are not set, use them to setvalues lower than the default values).

ERROR 37: Condition text too longAn individual condition is limited to 1000 characters. Check forsyntax errors causing subsequent text to be misinterpreted as part ofthe text.

ERROR 38: Unidentifiable condition in ruleThe text could not be identified as either a qualifier, formula, choiceor text condition. Check for syntax errors such as missing T> or no{ } in a qualifier condition.

ERROR 39: { not found with qualifierA condition was forced to be considered a qualifier with Q> but itdoes not contain any values in { }.

ERROR 40: No closing }A value in a condition has a { without a matching }.

ERROR 41: More than 127 conditionsA rule can have a maximum of 127 conditions in the IF, THEN orELSE part.

ERROR 42: Qualifier not in listThe LIST ONLY option was used with a QUALIFIER: list. Aqualifier was found that did not match any in the list. If the qualifieris correct, add it to the list or remove the LIST ONLY command inthe file.

ERROR 43: Qualifier value not in listThe LIST ONLY option was used with a QUALIFIER: list. Aqualifier value was found that did not match any in the list. If thequalifier value is correct, add it to the list or remove the LIST ONLYcommand in the file.

ERROR 44: Value list fullA qualifier can only have 30 values in its list. There was an attemptto add more than 30 values.

K - RULE COMPILER 51

Page 483: Manual Exsys

ERROR 45: No variable specified for assignmentA formula in the THEN or ELSE portion must start with a variableto assign a value to, such as [X] IS GIVEN THE VALUE 5.

ERROR 46: No closing ] in variable nameA variable in the formula had a [ without a matching ].

ERROR 47: Incorrect assignment statementA formula in the THEN or ELSE part must have an assignment of avalue such as "IS GIVEN THE VALUE", "IS GIVEN" or ":=".Check syntax.

ERROR 48: Syntax error in Choice conditionThere is a syntactical problem with the choice.

ERROR 49: Choice not in listThe LIST ONLY option was used with a CHOICE: list. A choicewas found that did not match any in the list. If the choice is correct,add it to the list or remove the LIST ONLY command in the file.

ERROR 50: No test condition in Choice conditionA Choice condition in the IF part of a rule must have a testcondition.

ERROR 51: Choice value out of rangeThe value specified for the choice is not in the range allowed for theconfidence system chosen.

ERROR 52: Confidence can only be used in probability mode 5A [%...] confidence variable was used in other than confidencemode 5.

ERROR 53: Illegal confidence variableA [%...] confidence variable had an incorrect name. Checkreferenced variable.

ERROR 54: Confidence variable not foundThe variable specified in [%...] could not be found.

ERROR 55: Variable not foundA variable was referenced in the rules that was not in the list. Thevariable cannot be automatically added to the rules since it does nothave an associated prompt text. Add the variable and its associatedprompt to the list of variables.

ERROR 56: Not an internal commandThe command specified in the X> command is not a recognizedEXSYS internal command.

K - RULE COMPILER 52

Page 484: Manual Exsys

ERROR 57: Text conditions cannot be used in the IF partText conditions can only be used in the THEN or ELSE part ofrules. To add RUN( ) commands in the IF part make them the firstpart of the text of a qualifier or variable text.

ERROR 58: Out of disk spaceThe program ran out of disk space trying to write out the rule files.

ERROR 59: Saving in standard EXSYS format impossibleFeatures unique to EXSYS Professional were used. Rules cannot besaved in standard EXSYS form.

ERROR 60: Saving in standard EXSYS format will result inloss of some dataFeatures unique to EXSYS were used. Rules can be saved instandard EXSYS form but some parameter data will be lost.

K - RULE COMPILER 53

Page 485: Manual Exsys

Chapter L

Frame and Table Interface

L1: TABLE and NTABLE

The functions TABLE and NTABLE perform a table look-up in atwo column ASCII file. Wild card search is allowed. The syntax ofthe two commands is identical. TABLE will return a string valuethat can be used in string expressions. NTABLE will return anumeric value that can be used in numeric expressions.

Syntax:

(N)TABLE("filename" "search string")(N)TABLE(string_exp string_exp)

In the second form, the string expressions will be evaluated. The firstexpression is the name of the file that has the tabular data and thesecond is the string to search for. The search string can contain '?'and '*' wild cards. A '?' matches any single character. A '*' matchesthe rest of the string, regardless of length. The match is not casesensitive.

L1.1: Data Table Syntax

The table of data must be an ASCII file with two columns. There canbe starting spaces or tabs and any number of spaces or tabs betweenthe columns. The first column is defined to end at the first space ortab after data. Headings can be used and will be ignored unless thesearch string matches the heading. For example, the following wouldbe legal lines in a table:

A56TR4 45.32Mary 555-55553 copper pipe

Note: It is legal to mix various types of data in a singletable, as long as the search string defines an individualitem. However, for speed of access and maintenance, itis usually better to maintain separate tables for each typeof data.

L - FRAME / TABLE 1

Page 486: Manual Exsys

The search string is compared to the first column entry. ForTABLE, a match will return the rest of the line, minus starting spacesor tabs. For NTABLE, a match will return a numeric value of therest of the line.

Note: For NTABLE, the second column must benumeric data.

In the examples above, assume the data is in a file "DATA.DAT":

Function: Returns:TABLE("DATA.DAT" "A56TR4") 45.32 as a stringNTABLE("DATA.DAT" "A56TR4") 45.32 as a numericTABLE("DATA.DAT" "MA*") 555-5555 as a stringNTABLE("DATA.DAT" "MA*") 555 as a numeric (rest lost)TABLE("DATA.DAT" "3") "copper pipe" as a string

It is possible to use tables as a type of array. A series of tables can beaccessed by their index to put parameters in a rule. For example:

IF[PRICE] > TABLE("price.dat" [S])

and: [AMOUNT] > TABLE("amount.dat" [S])

By simply changing the value of the string variable [S], the values inthe rule can be changed.

It is also possible to use a numeric variable as the index by using[[ ]] replacement. For example:

IF[PRICE] > TABLE("price.dat" "[[N]]")

and: [AMOUNT] > TABLE("amount.dat" "[[N]]")

The [[N]] will be replaced by the value of the numeric variable [N].The quotation marks around it are necessary to make it a string in theTABLE function. The table referenced would have the sequentialnumbers in the first column and the data in the second column, such as

1 123.452 65.323 96.29

By indexing the value of [N] (either in the rules or the commandlanguage), the TABLE value will be replaced by successive tableentries.

L - FRAME / TABLE 2

Page 487: Manual Exsys

L2: Frame

FRAME provides a way to handle more complex data than can behandled with TABLE. The TABLE commands are basically limitedto simple 2 column look-ups. FRAME allows multiple columns andmuch more complex search criteria with Boolean operators.FRAME also allows the data table to updated by the rules. Framealso provides inheritance which allows a hierarchical set of frames tobe created with data in "parent" frames available to lower levelframes.

Syntax: To read from a frame:

FRAME("filename", test_expression, slot_reference)

To write to a frame:

FRAME("filename", test_expr, slot_ref :=expression)

Filename: The name of the FRAME data file. The filename must be in " ".

Test_expr: The Boolean expression used to find the desired line in the frame.

Slot_ref: The desired column in the frame. FRAME looks in the file for a frame which matches the test expression and either writes or reads the slot referenced. This reference must be in $ or # to indicate if it to be handled as a string or numeric.

Expression: The data to be written into the slot_reference.

L2.1: What is a Frame

Frames are another way of storing data. Frames are bothsimilar and different from databases. The format of storing thedata is similar. The process of storing and retrieving the data isdifferent.

L - FRAME / TABLE 3

Page 488: Manual Exsys

L2.2: Specifying a Slot

A frame is a collection or grouping of simple data. The simple datacan be numbers and/or strings.

Name Address Telephone

Mike 100 Memory Lane (299) 458-9827

A frame is similar to a database record (or structure). A frame hasslots which hold the data. These are similar to fields. If you have agroup of frames with the same format, you can make one frame outof it.

Name Address Telephone Mike 100 Memory Lane (299) 458-9287 Dan 201 Penny Lane (298) 754-1489

Jill 832 Jack La Lane (299) 572-9578

Bill 831 Rocky Rd. (298) 194-2374

Joe High Rd 2 Scotland (298) 278-9278

Peg I-40 Freeway (299) 856-9274

The slots can have sub-slots. The sub-slots can have sub-sub-slotsand so on. However, if a slot contains a sub-slot, it must contain atleast 2 sub-slots. The slot or field definition part of the frame is calledthe header. This is everything up to the double lines. Everythingfollowing the double line is called the body. Each row of data in thebody is called a frame row.

L - FRAME / TABLE 4

Page 489: Manual Exsys

Example:

Item Price Diameter Length

Our Cost Sale Price Dia Units Len Units

Screw .01 1.90 1/4 inch 2 3/4 inch

Pipe 50.00 150.00 .5 feet 2 yards

HEADER

BODY

The names of the slots are the words used in the header. A sub-slothas both a name and a full name. The names are case insensitive, soif you have a slot "Inch," it will match with "inch" and "INCH."

A full name consists of the name of the slot which the sub-slot is in,followed by a period and the name of the slot, for example, Price.OurCost, Price.Sale Price, Diameter.Dia, Diameter.Units, Length.Len,Length.Units.

To reference a slot of a frame, you can use just its name. However, ifits name is not unique then you must use its full name. For example,in the table above, "Sale Price" is unique and it would not benecessary to use "Price.Sale Price." However, "Units" is not uniqueand it would be necessary to use "Length.Units" or "Diameter.Units."

The value in the slot can be evaluated as string value or as a number.To tell the program how you want the value handled, the slot name ispreceded and followed by a $ for a string or # for a number. Forexample, in the first row of the body, #Sale Price# would be anumeric value of 1.9. However, $Sale Price$ would be a string valueof "1.90." For strings, leading and trailing spaces are dropped.These values are handled differently in EXSYS Professionaloperations and value assignments.

Notice the 2 3/4 will be evaluated as 2.7500. FRAME will correctlyhandle fractional notation.

Remember in the table above, $units$ is ambiguous since there are 2slots with that name. You should, therefore, specify $diameter.units$or $length.units$.

You can also retrieve the value of slots which have sub headings.For example, $Length$ will have the value "2 3/4 inch" or "2yards", depending on which row we select. The value will include allof the sub-heading values.

L - FRAME / TABLE 5

Page 490: Manual Exsys

Notice that, in the frame, the separating lines are missing in the valueof $length$. The separating lines have no function in the frame rows.They are crucial in the header. Where the separating lines appear inthe header determines what columns hold the data for that slot.

Note: The characters $, #, and . have special meaning ina slot reference; they cannot be used in the slot names inthe header.

L2.3: Specifying the Frame Row

The frame row that will be used is the first one that passes a Booleantest. The test can be on a numeric or string value of one or moreslots. This test expression is the second parameter in the call toFRAME.

For example, using the frame above, we could have the followingtest:

$item$ = "screw"

This means find the first row in which the string value of the slot"item" has the value "screw." This will be the first row of the body.

The following test,

#sale price# - #our cost# > 10.00

combines the values of two slots as numeric values.

Sub-heading can also be used such as

$length.units$ = "yards "

Any legal EXSYS Professional test that does not include EXSYSvariables can be used. However, EXSYS variables can be embeddedin the expression by using [[ ]]. For example, you could use [[X]]== 2 if the value of [X] was "$length.len$."

All of the Boolean expressions supported by EXSYS can be used.See section C15.10 for more information.

Example:

(#sale price#-#our cost#>10.00) AND($length.units$= "yards")

L - FRAME / TABLE 6

Page 491: Manual Exsys

L2.4: How to Create a Frame

Frames are created with your word processor or text editor. If youuse a word processor, make sure it is in "non-document" or ASCIImode.

It is necessary to specify the various field widths of the frame slots bydrawing boxes around the text in the header. This is usually mosteasily done with the + - and | keys. However, if your text editorsupports ASCII characters over 128, you can draw the boxes usingthe ASCII characters for drawing lines.

First Line:The first line of a frame must be at least 3 characters long. It must beall +'s and -'s or a drawn line using extended graphics characters.The length of the space marked with + or - indicates the width of theframe. All other columns outside of the space marked will beignored. This makes the first line very important.

Header:The header lines must fit under the first line. Enter the names of theslots or sub-slots, with the field width indicated by the | character. Itis important to make sure that the width is adequate to hold any datathat may be entered. Continue entering lines with sub-slots until theheader is defined. End the header with a line of = characters. Theline using = must not have + or | characters in it.

Body:The data in the body of the frame should line up under the slotnames or sub-slot names. It is not necessary to mark the slot widthsin the body with |, but it does make the frame easier to read.

Last Line:The last line must be the same as the first line in the frame.

Comments:Any data outside of the space marked off by the first line is ignored.Comments can be placed outside of the marked space.

This syntax may seem unnecessarily complicated, but the resultingframe is easy to read and understand. The frame is maintained astabular data and can be created by many database managers orspreadsheet programs. By using the header to define field widths, itis easy to change the frame and quite complex structures can be keptas simple ASCII files without additional field width data.

L - FRAME / TABLE 7

Page 492: Manual Exsys

An example of a frame with comments is:

Customer information+------+-----------------+-----------------+| name | address | telephone |============================================| Mike | 100 Memory Lane | (021) 458-9287 || Dan | 201 Penny Lane | (043) 754-1489 || Jill | 832 Jack La Lane| (092) 572-9578 |+------+-----------------+-----------------+

Current as of 1/5/1989

Notice the comments outside of the frame are ignored, both beforeand after the first and last line and outside the frame width. You canput anything outside the frame as long as it is not confused for thefirst line of the frame.

1. The first line defines the width and is required.2. The vertical bars separating the slots are required.3. The double line separating the header from the body is required.4. The last line, which is the same as the first line, is required.

The following is an example of a frame with sub-slots:

--------------------------------------------------------- | item | price | diameter | length | | |our cost |sale price| dia |units | len |units | ========================================================= screw .01 1.90 1/4 inch 2 3/4 inch pipe 50.00 1500.00 .5 feet 2 yards ---------------------------------------------------------

Notice that only the minimum syntax was used. The use of +'s andextra lines in the header make it easier to read and maintain.

+-------+--------------------+------------+-------------+ | item | price | diameter | length | | +---------+----------+-----+------+------+------+ | |our cost |sale price| dia |units | len |units | ========================================================= | screw | .01 | 1.90 | 1/4 inch |2 3/4 inch | | pipe | 50.00 | 1500.00 | .5 feet | 2 yard | +-------+---------+----------+-----+------+------+------+

L2.5: Inheritance

Inheritance is a powerful capability of FRAME. It allows you tospecify a "parent" frame for any other frame. If a search on the testexpression fails in all lines of the specified frame, the search will berepeated in the parent frame. This allows data to be split over a setof frames. One frame may have general, or default information whilesub-frames have specific information. If a search of the specificinformation fails, the program will automatically return to the generalframe.

L - FRAME / TABLE 8

Page 493: Manual Exsys

Suppose you are storing information about animals in the frames.The vast amount of information demands a systematic method ofstoring that information. Much of the information is the same forgroups of animals. For example, almost all mammals are warmblooded, have hair and give live birth instead of eggs. It would benice if we didn't have to put every feature/attribute of the animal inthe frame of that animal. It would be nice if there were a link from adog frame to a mammal frame such that it could be determined thata dog is warm blooded and have that fact stored only in the mammalframe.

This is accomplished using inheritance. To specify the frame you willinherit from, after the frame put

~INHERIT FROM <filename>

Data not found in the current frame will be searched for in the filespecified. Be sure it appears on a line occurring after the last line ofthe frame. You can have one file inherit from another file whichinherits from yet another file etc.

To continue with the mammal example above, we could have aframe MAMMAL with very general characteristics:

+----------------+------------------+---------------+ | Warm Blooded | Body Covering | Live Birth | ===================================================== | YES | Hair | YES | +----------------+------------------+---------------+

~INHERIT FROM ANIMAL

We have defined it to inherit from an even more general frameANIMAL.

We could now have the DOG frame:

+----------------+--------------+ | Number of Legs | Carnivore | ================================= | 4 | YES | +----------------+--------------+

~INHERIT FROM MAMMAL

If we searched DOG for Number of Legs, we would get 4 directly,but if we searched for "Warm Blooded," there would be no such slotand the call would be repeated for the parent frame mammal. In thiscase, we have only one line in the body of each frame. But therecould be many. Also, we might have a frame for Platypus thatwould over-ride the slots in the parent frame, by having a specificentry:

L - FRAME / TABLE 9

Page 494: Manual Exsys

+----------------+--------------+-------------+| Number of Legs | Carnivore | Live Birth |===============================================| 4 | YES | NO |+----------------+--------------+------- -----+

~INHERIT FROM MAMMAL

If we asked about Live Birth in the Platypus frame, we would findthe slot and not inherit from the parent frame.

L - FRAME / TABLE 10

Page 495: Manual Exsys

L3: Reading from a Frame

FRAME( "filename", test_expression, slot_reference)

Filename: The name of the FRAME data file. The filename must be in " ".

Test_expr: The Boolean expression used to find the desired line in the frame.

Slot_ref: The desired column in the frame. FRAME looks in the file for a frame which matches the test expression and either writes or reads the slot referenced. This reference must be in $ or # to indicate if it to be handled as a string or numeric.

The value found will be returned to EXSYS.

L - FRAME / TABLE 11

Page 496: Manual Exsys

L4: Writing to a Frame

FRAME( "filename" , test_expr , slot_ref := expression)

Filename: The name of the FRAME data file. The filename must be in " ".

Test_expr: The Boolean expression used to find the desired line in the frame.

Slot_ref: The desired column in the frame. FRAME looks in the file for a frame which matches the test expression and either writes or reads the slot referenced. This reference must be in $ or # to indicate if it is to be handled as a string or numeric.

Expression: The data to be written into the slot_reference.

Writing to a frame is very similar to reading except for the lastparameter. Instead of just being a slot designator, there are both aslot designator and an expression to assign to that slot. Theassignment can include data from other slots in that row. Theassignment is indicated by :=.

L - FRAME / TABLE 12

Page 497: Manual Exsys

L5: Examples

Here are some examples:

Price Frame:

+-------+--------------------+------------+-------------+ | item | price | diameter | length | | +---------+----------+-----+------+------+------+ | |our cost |sale price| dia |units | len |units | ========================================================= | screw | .01 | 1.90 | 1/4 inch |2 3/4 inch | | pipe | 50.00 | 1500.00 | .5 feet | 2 yard | +-------+---------+----------+-----+------+------+------+

Reading from the Frame:

FRAME("PRICE", #Cost# > 40, $item$)

will return the value "pipe" as a string.

FRAME("PRICE", $item$ = "pipe", #length.len#)

will return the value 2 as a numeric.

Writing to the Frame:

FRAME("PRICE", $item$ = "pipe", #length.len# := 3)

will change the length.len value from 2 to 3.

FRAME("PRICE", $item$ = "pipe", $item$ := "pipe A")

will change the item name for "pipe" to "pipe A."

L - FRAME / TABLE 13

Page 498: Manual Exsys

L6: Including FRAME and TABLE in Your Expert System

Frame commands can be included into your expert system rules in avariety of ways.

1. Associated with a qualifier or variable.A FRAME( ) or TABLE() command can precede the text of aqualifier or variable just like a RUN( ) command. Assume, forexample, we have the following qualifier:

The color is1 red2 blue3 green

Suppose we wanted to store this data in a frame. We could thenaccess the data with a FRAME( ) command.

FRAME(...)The color is1 red2 blue3 green

Now if this data is needed, EXSYS will automatically get it from theframe.

The same thing can be done with a variable. If we have a variable[LENGTH A] with associated text "The length of pipe A," we couldstore the data in a table:

TABLE(...) The length of pipe A

The easiest way to add such data acquisition commands is just toenter the qualifier and value text normally, with no FRAME orTABLE command. Once that is done, you will first be asked for anoptional qualifier name. Then you will be asked if you wish toassociate a data acquisition command with the qualifier or variable.Press <Y> and you will have a menu of possible sources for the data.You can select the one you want with the cursor keys. SelectFRAME or TABLE and you will be prompted through the optionsfor the command. By using this approach, it is not necessary tomemorize the command syntax because EXSYS will build thecommand for you.

L - FRAME / TABLE 14

Page 499: Manual Exsys

2. Run as the result of a Rule FiringYou may wish to have a FRAME updated when a rule fires. This isdone by pressing the <X> key in the THEN or ELSE part. You willbe given a list of possible commands. You can select FRAME andyou will be prompted through the creation of the command. In theTHEN/ELSE part.

3. From the Command LanguageYou may include FRAME( ) commands anywhere in the commandfile. Since this file is created with a text editor, you will need to learnthe syntax of the commands to use this approach. If you havedifficulty writing the command, create a rule in the EXSYS Editor,go to the THEN part, press <X> to get the command menu. SelectFRAME and follow the prompts to build the command. Copy thiscommand into your command language file. This would normally bedone only to write to the frame.

4. From the Report GeneratorYou may include FRAME( ) commands anywhere in the reportgenerator file. Like the command file, this file is created with a texteditor, you will need to learn the syntax of the commands to use thisapproach.

L - FRAME / TABLE 15

Page 500: Manual Exsys

Chapter M

Blackboard Manager

M1: Introduction

The Generic Data Blackboard (hereafter referred to as "EXSYSBB")provides a flexible means for expert systems and other applications tostore and retrieve small volumes of data. Blackboard is an ArtificialIntelligence term that is often applied to databases used to shareinformation between or among expert systems and other programs ina knowledge based application.

M1.1: Recommended uses for EXSYSBB

Call EXSYSBB before running an expert system to make dataavailable to the application.

Associate an EXSYSBB call with a specific qualifier or variableto have that data element obtained from the blackboard.

Call EXSYSBB from the THEN or ELSE portion of an expertsystem rule to post new information to a blackboard.

Let EXSYSBB provide the data interface between severalexpert system modules or other programs which run in yourapplication.

M1.2: EXSYSBB Blackboards

EXSYSBB Blackboards are simple database tables consisting ofstrings of data in ASCII format. EXSYSBB Blackboards do not usea proprietary format and may be read and written by manyapplications. Physical data format considerations such as a prefixtoken, suffix token and delimiters need not be stored in theblackboard. These are supplied as runtime parameters whenEXSYSBB is invoked. Since formatting information is supplied atinvocation, EXSYSBB and its blackboards can be truly generic. Youneed not code and maintain "translate tables" to convert oneapplication format to another. The documentation of the specificformat requirements is in the code, so to speak, because it is part ofthe invocation call to EXSYSBB.

M - BLACKBOARD MANAGER 1

Page 501: Manual Exsys

M1.3: Communication Between EXSYSBB and Your Applications

EXSYSBB receives instructions from the application at runtime viaparameters passed on the command line. The expressions consist ofcommand switches and associated data. Please refer to theCommand Summary in this manual and the examples used in thedemonstration. Data is returned from EXSYSBB to yourapplications via simple ASCII files. The use of a file for interprocesscommunication was chosen because it is highly portable acrossdifferent computer operating systems and applications.

M2: Calling EXSYSBB

EXSYSBB is called with an EXSYS internal command.

When calling EXSYSBB from within EXSYS, there are threeinternal commands:

BB_RD(parameters) Read from blackboardBB_WR(parameters) Write to blackboardBB_DE(parameters) Delete data from blackboard

Note: The syntax of the parameters for each commandis described in the command sectionof this chapter.

When calling from the operating system, there is only a singlecommand used, but it requires one additional parameter. The otherparameters are the same as when calling from within EXSYS.

There is also a stand alone executable program calledEXSYSBB.EXE.

Note: EXSYSBB as a separate executable is notsupported in all operating systems. It can becalled like any other executable program fromthe operating system. However, for the threedifferent types of blackboard commands, anextra parameter must be added as the firstparameter passed. The other parameters are thesame in both calling methods.

BB_RD(parameters) EXSYSBB(-Q parameters)BB_WR(parameters) EXSYSBB(-U parameters)BB_DE(parameters) EXSYSBB(-D parameters)

M - BLACKBOARD MANAGER 2

Page 502: Manual Exsys

M3: Including EXSYSBB in Your Expert System

EXSYSBB commands can be included in your expert system rules ina variety of ways.

M3.1: Associated with a Qualifier or Variable

A EXSYSBB command can precede the text of a qualifier orvariable just like a RUN( ) command. For example, consider thefollowing qualifier:

The temperature is1 over threshold2 at threshold3 below threshold

Suppose we knew that a previous program or module had leftinformation in the blackboard about the temperature. We couldautomatically recover this information by preceding the qualifier textwith a blackboard read command (BB_RD):

BB_RD(...)The temperature is1 over threshold2 at threshold3 below threshold

Now if this data is needed, EXSYS will first check the blackboard. Ifthere is no data the user will be asked for input.

The same thing can be done with a variable. If we have a variable[PRESSURE] with associated text "The pressure of pipe A," we canget this from the blackboard by changing the text to

BB_RD(...) The pressure of pipe A

The easiest way to add such data acquisition commands is to justenter the qualifier and value text normally, with no blackboardcommand. Once that is done, you will first be asked for an optionalqualifier name. Then you will be asked if you wish to associate a dataacquisition command with the qualifier or variable. Press <Y> andyou will have a menu of possible sources for the data. You can selectthe one you want with the cursor keys. Select BLACKBOARD andyou will be prompted through the options for the command. Byusing this approach, it is not necessary to memorize the commandsyntax, because EXSYS will build the command for you.

M - BLACKBOARD MANAGER 3

Page 503: Manual Exsys

M3.2: Run as the Result of a Rule FiringYou may wish to have specific data added to the blackboard when arule fires. This is done by pressing the <X> key in the THEN orELSE part. You will be given a list of possible commands. You canselect BLACKBOARD and will be prompted through the creation ofthe command. In the THEN/ELSE part, you would usually use theBB_WR( ) or BB_DE( ) commands.

M3.3: From the Command LanguageYou may include BB_RD( ), BB_WR( ) or BB_DE( ) commandsanywhere in the command file. Since this file is created with a texteditor, you will need to learn the syntax of the commands to use thisapproach. If you have difficulty writing the command, create a rulein the EXSYS Editor, go to the THEN part then press <X> to getthe command menu. Select BLACKBOARD and follow theprompts to build the command. Copy this command into yourcommand language file.

M3.4: From the Report GeneratorYou may include BB_RD( ), BB_WR( ) or BB_DE( ) commandsanywhere in the command file. Like the command language, this fileis created with a text editor so you will need to learn the syntax ofthe commands to use this approach.

M3.5: From the Screen Definition Language

You may include BB_RD( ), BB_WR( ) or BB_DE( ) commandsanywhere in the screen definition commands. This allows you to runseveral different options. To get data in some cases, it may benecessary to run the EXSYSBB.EXE form with the RUN( )command. This allows data to be passed back to another targetqualifier or variable. Use in the screen definition language allows youto include blackboard calls in the custom help screens as well as thescreen used to ask questions.

M3.6: Called from the Operating SystemYou can call the blackboard manager from the operating systemusing the EXSYSBB.EXE form of the commands. This can allowyou to put data into the blackboard from a batch file.

M3.7: Called from Other programsAny program that has the ability to run .EXE programs can call theblackboard manager. You must use the EXSYSBB.EXE form of thecommand.

M - BLACKBOARD MANAGER 4

Page 504: Manual Exsys

M4: Blackboard Command Window

In cases 1 and 2 in the above list, the blackboard call can be builtusing the blackboard command window .

Operation: READ WRITE DELETE

Blackboard File

Attribute String

Value String

Optional Success String

Optional Failure String

Optional Prefix String

Optional Suffix String

Eliminate Other References

The meaning of the fields in this window is explained below.

M - BLACKBOARD MANAGER 5

Page 505: Manual Exsys

M5: Reading From a Blackboard

Commands:

Within EXSYS:

BB_RD( -A'attribute' optional_parameters)

From operating system:

EXSYSBB -Q -A'attribute' optional_parameters

Optional Parameters: -B, -F, -N, -P, -R, -S, -T, -V

See the parameter section for details.

The Blackboard file must already exist.

The default blackboard file GDB.DAT will be used unless the -Boption is used.

M - BLACKBOARD MANAGER 6

Page 506: Manual Exsys

M6: Writing to a Blackboard

Commands:

Within EXSYS:

BB_WR( -A'attribute' optional_parameters)

From operating system:

EXSYSBB -U -A'attribute' optional_parameters

Optional Parameters: -B, -M, -V

See the parameter section for details.

If the Blackboard file does not already exist, it will be created.

The default blackboard file GDB.DAT will be used unless the -Boption is used.

M - BLACKBOARD MANAGER 7

Page 507: Manual Exsys

M7: Deleting Data from a BlackboardCommands:

Within EXSYS:

BB_DE(-A'attribute' optional_parameters)

From operating system:

EXSYSBB -D -A'attribute' optional_parameters

Optional Parameters: -B, -V

See the parameter section for details.

The Blackboard file must already exist.

The default blackboard file GDB.DAT will be used unless the -Boption is used.

M - BLACKBOARD MANAGER 8

Page 508: Manual Exsys

M8: Attributes and ValuesThe blackboard file is made up of strings of data. These are moregeneral forms of EXSYS qualifier/value combinations or variables.This generalized structure of EXSYSBB makes it very flexible.

Data is written to the blackboard as text string. The data written canbe an attribute (indicated by -A) or an associated value (indicated by-V). If a value is used, it will be appended to the attribute string.

For example:

BB_WR(-A'Pressure')

will write the string "Pressure" to the blackboard.

BB_WR(-A'Pressure' -V'347')

will write the string "Pressure 347" to the blackboard.

We could just as easily write the full string with

BB_WR(-A'Pressure 347')

but this could cause multiple references to "Pressure." By using the-M option to eliminate multiple references, we can be sure there isonly a single reference to pressure.

Strings can also be written to the blackboard by any other programor just a text processor.

When data is read from the file, the same attribute or value notationis used, but usually the value will be the data returned.

For example, if we use the read command,

BB_RD(-A'Pressure')

it will return any value that was associated with the string "Pressure."This allows data to be left in the blackboard by a program or expertsystem module and picked up by another program.

M - BLACKBOARD MANAGER 9

Page 509: Manual Exsys

If values are used with the read commands, the match will be madeon both the attribute and value. For example, if there was ablackboard that contained the string "The color is red" and we used

BB_RD(-A'The color is')

then it would return "red." However, if we used

BB_RD(-A'The color is' -V'red')

the test would be true, but no data would be returned. In this case,you should use the -T and -F options to tell the program what toreturn if the test is true or false. In the following example,

BB_RD(-A'The color is' -V'red' -T'1' -F'0')

would return 1 if the attribute or value pair was found and 0 if it isnot. See the Parameters section for details on the various commandsparameters that can be used.

M - BLACKBOARD MANAGER 10

Page 510: Manual Exsys

M9: ParametersPost String

-A'string expression'

The -A switch allows you to specify a string in the blackboard youwant to post to the blackboard or to search for on the blackboard,such as "senior discount rate." You must always specify an attributestring when calling EXSYSBB.

For example:

BB_WR(-A'Process 1 complete')

will write the string "Process 1 complete" to the default blackboardGDB.DAT.

BB_RD(-Btest.bb -A'Process 1 complete')

will check the blackboard file test.bb for the string "Process 1complete." If it is found, any associated values will be returned in thefile GDB.RTN.

BB_DE(-Btest.bb -A'Process 1 complete')

will check the blackboard file test.bb for the string "Process 1complete." If the string is found, it will be deleted.

Specify File

-Bfilename

The -B switch allows you to specify the name and path of theblackboard file you wish to use. If not specified, EXSYSBB assumesthe default blackboard of "GDB.DAT."

For example:

BB_WR(-Bbbfile1.out -A'green')

will use the file bbfile1.out as the blackboard file instead of the defaultblackboard GDB.DAT.

M - BLACKBOARD MANAGER 11

Page 511: Manual Exsys

Delete

-D

The -D switch tells EXSYSBB to delete an attribute from ablackboard with value information supplied by you through the useof the other command line switches. This parameter is only neededwhen calling EXSYSBB from the operating system. When callingfrom within EXSYS, use the internal command BB_DE

Note: If a -V'(value)' is supplied only thespecific attributes found with that specificvalue are deleted.

For example:

EXSYSBB -D -A'Problem Found'

will delete the string "Problem Found" from the default blackboardfile.

Failure Return String

-F'string expression'

The -F switch allows you to specify a string to be returned to thereturn file if a query you submit to the blackboard fails to result in areturn value. It is optional. See also -T and -N. This allows you tobe certain that some value will be returned.

Example:BB_RD(-A'Pressure' -F'0.0')

will check the blackboard for the string pressure and return the valueassociated if there is one. If the string pressure is not found, the value0.0 is returned.

Eliminate Other References

-M

The -M switch during a write operation to the blackboard causesEXSYSBB to seek and eliminate any other references to theattribute involved in this update transaction. It is useful foreliminating multiple references to a blackboard attribute and shouldbe used whenever the value relevant to a particular attribute is to beconsidered unique.

M - BLACKBOARD MANAGER 12

Page 512: Manual Exsys

Note: -M is valid only if the blackboardalready exists and may not be specified whencreating a new blackboard.

For example, suppose we have a blackboard with the line

Pressure 555

We want to change the pressure value to 111. If we just use:

BB_WR(-A'Pressure' -V'111')

the blackboard file will contain

Pressure 555Pressure 111

There are some cases where such multiple reference information isuseful, but in this case we will want a unique value. To do this weeliminate multiple references to the attribute with

BB_WR(-A'Pressure' -V'111' -M)

This will eliminate the old reference and the blackboard will nowhave just

Pressure 111

Failure Leaves Empty File

-N

The -N switch during a query tells EXSYSBB to leave an emptyreturn file on your disk in the event of a failed query. If you do notuse the -N option, no file will be created in the event that your queryfails to result in a return value. See -F for another alternative.

Prefix String

-P'string expression'

The -P switch causes an item to be written with the string followingthis switch used as a prefix. This is needed to tell EXSYSBB whatsort of token your application would like associated with theinformation when it reads it out of the return file. See also -S.

M - BLACKBOARD MANAGER 13

Page 513: Manual Exsys

For example, suppose you wanted to read the value of the attribute"Pressure" into variable [P]. Normally, you would just associate theblackboard call with the variable [P], but you could alternatively callEXSYSBB as an external program and use

EXSYSBB -Q -A'Pressure' -P'[P] '

This if the blackboard contained the string "Pressure 546," this wouldreturn "[P] 546."

External Form Query

-Q

The -Q switch tells the program to query an existing blackboard andreturn the results according to your instructions as defined by use ofother switches. This is used only when calling EXSYSBB.EXEfrom the operating system. It is not needed when using the EXSYSinternal command BB_RD.

Return File Name-Rfilename

The -R switch tells EXSYSBB to use the associated string as a returnfile for query data. If not specified, EXSYSBB uses the name"GDB.RTN".

Note: If you are calling the commands fromwithin EXSYS, the reading of the return fileis handled automatically and the -R optionshould not be used.

For example,

EXSYSBB -Q -A"The color is" -Rtest.dat

will return the value associated with the attribute "The color is" in thefile test.dat, rather than the default file GDB.DAT.

Suffix String-S'string expression'

The -S switch causes an item to be written with the string followingthis switch as a suffix. This may be needed to tell EXSYSBB whatsort of delimiters such as commas, quotation marks, etc. are requiredby an application. See also the -P switch.

M - BLACKBOARD MANAGER 14

Page 514: Manual Exsys

For example, if you want to append the string "XXX" to a value,you could use

EXSYSBB -Q -A"The color is" -S'XXX'

This option is rarely needed, but allows compatibility with themaximum number of applications.

Successful Query Return String-T'string expression'

The -T switch during a query tells EXSYSBB to return the associatedstring instead of a blackboard value if the query is successful. See -F,which is the counterpart to -T.

In the following example,

BB_RD(-A'The color is' -V'red' -T'1' -F'0')

would return 1 if the attribute or value pair were found and 0 if itwere not found.

External Form Update-U

The -U switch tells EXSYSBB to update a blackboard with attributeand value information supplied by you through the use of the othercommand line switches. This is used only when callingEXSYSBB.EXE from the operating system. It is not needed whenusing the EXSYS internal command BB_WR.

Note: If the -M switch is invoked duringupdate, the blackboard file must alreadyexist. If -M is not used, EXSYSBB willcreate the blackboard file if it does notalready exist.

M - BLACKBOARD MANAGER 15

Page 515: Manual Exsys

Supplemental Switch-V'string expression'

The -V switch allows you to specify a supplemental switch to the -Aswitch. Its function depends on what operation is being performed:

Reading:If the -V switch is present in a read command (BB_RD),EXSYSBB searches for an exact match of attribute string(-A) and value string (-V).

In the following example,

BB_RD(-A'The color is' -V'red' -T'1' -F'0')

would return 1 only if the specific value "red" was found.

If the -V switch is absent during a query, EXSYSBB searchesand returns all values associated with the specified attribute.

Writing:If the -V switch is present during a write command (BB_WR),the value string is posted to the blackboard along with theattribute. For example,

BB_WR(-A'The color is' -V'red')

will write "The color is red" to the blackboard.

M - BLACKBOARD MANAGER 16

Page 516: Manual Exsys

M10: External Call Values (demons):

If, during the process of returning values during a read operation,EXSYSBB encounters a value expression which begins with anexclamation point (!), it will pass the value expression out to youroperating system's command processor for immediate executioninstead of returning it in the return file. Following execution,EXSYSBB continues the query operation.

Note: Processing an external call requires enough system memory torun the program.

For example, suppose we had a blackboard file with the line

Command !dir

If we read this line with BB_RD(-A'command'), instead of having thestring !dir returned, the DIR command will be executed as if it wastyped in from DOS. This can also be used to run executableprograms or batch files.

One technique is to have several executable commands added to theblackboard file without the -M option so there are multiplereferences. For example, if we have the commands

BB_WR(-A'RUN PROGRAM:' -V'!DIR')BB_WR(-A'RUN PROGRAM:' -V'!EXSYSP TEST')

and later we do a read with BB_RD(-A'RUN PROGRAM:'), theblackboard manager will first do a "DIR" command and then runEXSYSP with the knowledge base test.

This option allows one call to the blackboard manager to leave acommand that will not be executed until a later call. This allows verycomplex strategies with external programs to be utilized.

M - BLACKBOARD MANAGER 17

Page 517: Manual Exsys

M11: Operating Modes

Trace OperationYou can turn the EXSYSBB trace on during Normal operation bysetting the environment parameter GDBTRACE=Y before callingEXSYSBB. See your operating system manual if you are notfamiliar with the SET function.

Interactive OperationInvoke EXSYSBB without command line parameters and it will turnon a trace function, display a sign-on message and prompt you for acommand line.

M - BLACKBOARD MANAGER 18

Page 518: Manual Exsys

M12: Error Messages

GDB ERROR: No attribute was specified in command line.Either you did not include the -A parameter or EXSYSBB could notsee it because of errors in the single quotation mark delimiters.

GDB ERROR: Invalid switch character in command line. Youincluded a switch that is not supported by EXSYSBB.

GDB ERROR: Invalid character in command line. EXSYSBBfound an invalid character (such as a control character) in thecommand line.

GDB ERROR: Unable to open command file.EXSYSBB could not find your operating system's commandprocessor.

GDB ERROR: Unable to read command file.EXSYSBB encountered an error trying to access the operatingsystem's command processor.

GDB ERROR: Unable to open return file.EXSYSBB could not open GDB.RTN or the file name you specified.Check for sufficient disk space, and presence of a preexisting file thatis "read only."

GDB ERROR: Unable to open working file.EXSYSBB could not open a work file needed for blackboardprocessing. Check for sufficient disk space, and presence of apreexisting file that is "read only."

GDB ERROR: Unable to open blackboard file.EXSYSBB could not find GDB.DAT or the file name you specified.

GDB ERROR: Specify Update, Query or Delete. EXSYSBBfound more than one of the -U, -Q, -D switches set, or none set.

GDB ERROR: Missing single quotation mark delimiter fromcommand line.EXSYSBB could not find the leading quotation mark delimiter forthe switch named in the message.

M - BLACKBOARD MANAGER 19

Page 519: Manual Exsys

M13: Common Errors1. Error in the single quotation mark delimiters: One of the tworequired quotation marks has been left off; you are using quotationmarks with a switch that does not require them; you are using doublequotation marks (") by mistake.

2. You forget to specify the -Q, -U or -D switch when calling fromthe operating system.

3. You mixed case in attributes, values, and other strings. Somecalling programs may convert all command line arguments to uppercase. Use the interactive mode to check, if you suspect this is aproblem.

Other kinds of errors:EXSYSBB needs about 128K of free memory at runtime. If you donot have sufficient memory available, DOS may crash. The test forthis condition is that EXSYSBB runs fine stand alone but crasheseither consistently or intermittently when called from yourapplication. Before you suspect a memory problem, double checkthat you are calling EXSYSBB correctly.

If you do not have EXSYSBB in your application's path, yourapplication may crash or report an execution error. If you arekeeping EXSYSBB in a different path, it's always a good idea tospecify the full drive and path.

M - BLACKBOARD MANAGER 20

Page 520: Manual Exsys

Chapter N

LINDO Interface

N1: Introduction

The LINDO interface in EXSYS Professional is designed to allowincorporation of LINDO's powerful linear and integer programmingtechniques into an expert system. It is particularly well-suited forexpert systems developed for scheduling, resource optimization, orother problems where an optimal solution must be found. Theinterface is designed to be easy to implement and transparent to theend user. However, the developer must understand both EXSYSand LINDO to use the programs effectively. This manual assumesthat the user knows how to build LINDO models and run LINDO.For information on using LINDO, see the LINDO user manuals.

EXSYS uses a file similar to the report generator file to generate aLINDO model. This model is then run by LINDO automatically.The results of the LINDO run are read back into specified EXSYSvariables. With the command language, LINDO can be runrepetitively with some parameters varied by the expert system rules.This allows both non-numeric heuristics and linear optimization to beincorporated into the solution of the problem.

In addition to the expert system capabilities, EXSYS effectivelywraps the flexible user interface and report generator aroundLINDO. LINDO is extremely powerful. It may be difficult,however, for untrained users to understand the meaning of theoutput. Now, linear programming can combine with EXSYS's manyways of getting user input (including graphics), the flexible reportgenerator to format output and the inference engine to interpret themeaning of the results provided by LINDO. In this way, complexLINDO models can be created based on data input by the user, andcomplicated LINDO results can be interpreted with an expert systemto produce easy to understand reports.

N - LINDO INTERFACE 1

Page 521: Manual Exsys

N2: Calling the LINDO Specification FileEXSYS supports the internal command LINDO(...). This commandcan be used in any place where a RUN(...) command could be used:

1. Associated with a qualifier or variable2. In the THEN or ELSE part of a rule3. In the Command Language4. In the Report Generator

The following is the proper command syntax:

LINDO(filename options)

The "filename" is the name of the LINDO specification file. This filehas the commands to build the LINDO model and to read data backinto EXSYS variables. The model will be built and run automatically.The results will be read back into specified EXSYS variables.

The "options" allow overriding the automatic sequence of theLINDO command. The following list describes what the LINDOoptions are and what they do:

/I Causes LINDO to be run in an interactive mode. LINDO isnormally run with no user interaction. The modelautomatically generates an output file and LINDO terminates.In interactive mode, the command file will be created and canbe loaded and run, but all of the interactive LINDO commandswill be available for examining the model. This is useful toexamine results, make modifications in the model or test thesystem during development. Usually, once the development iscompleted, the /I would be removed.

/W Causes the LINDO command file to be written, but notexecuted. The option /W=filename causes the command fileto be created in the file "filename." The default file name isLINDOCMD.TMP. This option is useful for creating a model,using the model to run LINDO on another computer and thenreturning the results to the starting computer.

/R Causes the LINDO results file to be read, but without buildinga command file or executing LINDO. The option/R=filename causes the data to be read from the file"filename." The default file name is LINDORET.TMP. Thisoption is useful for reading data created if LINDO is run onanother computer.

UNIX Note: With UNIX computers, all / are replaced by -. For example, /I becomes -I.

N - LINDO INTERFACE 2

Page 522: Manual Exsys

N2.1: LINDO Specification FileThe LINDO specification file in EXSYS has two parts. The firstspecifies how to build a LINDO model and incorporate EXSYS datainto the model. The second part specifies what LINDO return datashould be read into specified EXSYS variables.

The ~RESULTS command indicates the start of the second section.All commands prior to ~RESULTS build a model which is executedwhen the ~RESULTS command is reached. All commands after the~RESULTS command tell EXSYS what data to take from LINDOand what EXSYS variables to assign it to.

Within the section building the model, a conditional test can be usedto customize the model based on the values of various parameters.

The LINDO specification file has the following syntax:

~TEMP=path Optional~LINDO=filename Optional

model commands~IF expressionmodel commands~ELSEmodel commands~ENDIFmodel commands

~RESULTS

data commands

~TEMP=path

EXSYS will create two temporary files during the LINDO run. Onecontains the LP model and the other the results of the LINDO run.The names of these files are LINDOCMD.TMP andLINDORET.TMP. These names cannot be changed, but thedirectory they are in can be changed. If there is no ~TEMPcommand, the files will be created in the default directory. If there isa ~TEMP command, the files will be created in the directoryspecified by the path. This is useful for creating the temporary fileson a RAM disk to improve performance. The ~TEMP command isoptional, but if it is used, it must appear before any model commands.

The following example ~TEMP=d:

would create the temporary files on drive D, which could be a RAM disk.

N - LINDO INTERFACE 3

Page 523: Manual Exsys

~LINDO=filename

EXSYS will call LINDO after the model is built. It expectsLINDO.EXE to be in the default directory. If LINDO is somewhereelse, or renamed, you must include a ~LINDO command to tellEXSYS where LINDO is. This is not a path, but a full filespecification.

The following applies, for example, if LINDO.EXE is in a directorycalled LINDO:

~LINDO=/LINDO/LINDO.EXE

N - LINDO INTERFACE 4

Page 524: Manual Exsys

N3: Model CommandsModel commands are lines in the file that will be used to build theLINDO model. They will be put in the file LINDOCMD.TMPexactly as they appear with two exceptions: embedded EXSYSvariables will be replaced by their values and embedded expressionswill be replaced by their values.

Embedded EXSYS variables are represented by the variable nameenclosed in either single or double [ ]. Embedded expressions areany legal EXSYS expression enclosed in <? ?> . The expression orvariable will be evaluated and inserted in the model at the pointspecified. Variables and expressions can be either string or numeric.This allows EXSYS data to be easily incorporated into the LP model.

The <? ?> notation for expressions can be used anywhere a [[ ]]expression for a variable can be used. The expression inside the <??> will be evaluated and the value calculated placed in the string.

Any text on a line following the characters /* will be considered acomment and not put in the model.

For example, suppose we have EXSYS variables [NUM] and[PRICE], with values 5 and 35 respectively.

The model commands

MAX 2X+[NUM]Y /* the goal to maximizeST3X + <? [PRICE]/[NUM] ?> Y < 100

would generate LP model commands

MAX 2X+5YST3X + 7Y < 100

String variables may also be used. We could have a string variable[S] whose value would be "MIN" or "MAX" depending on the rules.Then we might have

[S] 2X+5Y

which would be converted to

MAX 2X+5Y orMIN 2X+5Y

depending on the rules in the expert system.

N - LINDO INTERFACE 5

Page 525: Manual Exsys

N4: ~IF test expression, ~ELSE, ~ENDIF

When building the model, it may be desirable to include certainmodel commands only if some criterion is met in the expert system.This is easier than having many LINDO specification files.

If the ~IF command is used, it is followed by any legal EXSYSexpression. The expression can use numeric or string data, but mustreturn TRUE or FALSE. Qualifiers can be included with the QCHKfunction (QCHK returns TRUE or FALSE already). The followingare examples of legal expressions:

[X] > 0[S] != "abcd"sin([X]*[X]) < tan([Y])QCHK(15, 1)

If the test expression is true, the model commands immediatelyfollowing the ~IF will be used. If the test expression is false, andthere is an ~ELSE, the model lines following the ~ELSE will beused. If there is no ~ELSE, the lines after the ~ENDIF will be used.

Every ~IF command must have a matching ~ENDIF command. ~IFcommands can be nested, provided there is an ~ENDIF for each ~IF.

For example, suppose we again have the EXSYS variables [NUM]and [PRICE] with values 5 and 35 respectively.

The model commands,

MAX 2X+[NUM]YST~IF ([PRICE] < 30) 3X + 8Y < 100~ELSE ~IF ([NUM] < 7) 3X + 7Y < 18 ~ELSE 4X + 7Y < 20 ~ENDIF~ENDIF

for [NUM]=5 and [PRICE]=35, will generate the following:

MAX 2X+5YST3X + 7Y < 18

N - LINDO INTERFACE 6

Page 526: Manual Exsys

N5: ~ResultsThe ~RESULTS command tells EXSYS

1. That the model is complete2. To run LINDO on the model3. That the commands that follow are data commands

There must be a results command unless the /R option was used.

N6: Return Data CommandsData commands provide an easy way to get LINDO results back intoEXSYS variables. The syntax for the data command is

[EXSYS Variable name] = LINDO data ID

The EXSYS variable name is any numeric EXSYS variable, such as[X] or [NUM].

The LINDO data ID is an identifier of a particular item of datareturned by LINDO. EXSYS will find the item of data specified andassign the value to the EXSYS variable. There can be as many datacommands as needed.

N6.1: LINDO Data ID

There are many LINDO data IDs and all have abbreviated forms:

LP OPTIMUM FOUND AT STEP

Abbreviated forms: STEP, OPT FOUND STEP, OPTIMUMFOUND AT STEP

This ID returns the number of the step at which the optimumwas found.

For example: [N] = OPT FOUND STEP

N - LINDO INTERFACE 7

Page 527: Manual Exsys

OBJECTIVE FUNCTION VALUE # or name

Abbreviated forms: FCT VAL, FUNCTION VALUE

This ID returns the objective function value for the functionspecified by number or name.

This example, [F1] = OBJECTIVE FUNCTION VALUE 3

would return the value of objective function number 3.

VARIABLE VALUE LINDO var name

Abbreviated forms: VAR VAL, VAR VALUE

This ID returns the VALUE column for the specified LINDO variable.

For example: [N VAL] = VARIABLE VALUE N

VARIABLE REDUCED COST LINDO var name

Abbreviated forms: VAR RC, VAR REDUC COST

This ID returns the REDUCED COST column for thespecified LINDO variable.

For example: [N RC] = VAR RC N

VARIABLE CURRENT COEF LINDO var name

Abbreviated forms: VAR CUR COEF, VAR CURRENT COEF

This ID returns the CURRENT COEF column for the specifiedLINDO variable.

This example: [N CC] = VAR CURRENT COEF N

will return the CURRENT COEF for variable N.

N - LINDO INTERFACE 8

Page 528: Manual Exsys

VARIABLE ALLOWABLE INCREASE LINDO varname

Abbreviated forms: VAR ALL INC, VAR ALLOWABLE INC

This ID returns the ALLOWABLE INCREASE column forthe specified LINDO variable.

This example: [N AI] = VAR ALL INC N

will return the allowable increase column for variable N.

VARIABLE ALLOWABLE DECREASE LINDO varname

Abbreviated forms: VAR ALL DEC, VAR ALLOWABLE DEC

This ID returns the ALLOWABLE DECREASE column forthe specified LINDO variable.

This example: [N AD] = VAR ALL DEC N

will return the allowable decrease column for variable N.

ROW SLACK # or name

Abbreviated forms: ROW SL

This ID returns the SLACK OR SURPLUS column for thespecified ROW.

This example: [X] = ROW SLACK cost

would return the SLACK for the row labeled "cost."

ROW DUAL PRICE # or name

Abbreviated forms: ROW DP

This ID returns the DUAL PRICE column for the specified ROW.

This example: [X] = ROW DP cost

would return the DUAL PRICE for the row labeled "cost."

N - LINDO INTERFACE 9

Page 529: Manual Exsys

ROW CURRENT RHS # or name

Abbreviated forms: ROW RHS

This ID returns the CURRENT RHS column for the specified ROW.

This example: [X] = ROW CURRENT RHS cost

would return the CURRENT RHS for the row labeled "cost."

ROW ALLOWABLE INCREASE # or name

Abbreviated forms: ROW ALL INC, ROW ALLOWABLE INC

This ID returns the ALLOWABLE INCREASE column forthe specified ROW.

This example: [X] = ROW ALL INC cost

would return the ALLOWABLE INCREASE for the rowlabeled "cost."

ROW ALLOWABLE DECREASE # or name

Abbreviated forms: ROW ALL DEC, ROW ALLOWABLE DEC

This ID returns the ALLOWABLE DECREASE column forthe specified ROW.

This example: [X] = ROW ALL DEC cost

would return the ALLOWABLE DECREASE for the rowlabeled "cost."

ITERATIONS

Abbreviated forms: ITER

This ID returns the number of iterations.

For example: [I] = ITER

N - LINDO INTERFACE 10

Page 530: Manual Exsys

NO SOLUTION

This ID returns 1 if no solution was found or 0 if a solutionwas found.

This can be used as a check before displaying results.

For example: [OK] = NO SOLUTION

N - LINDO INTERFACE 11

Page 531: Manual Exsys

N7: Sample EXSYS / LINDO Interface

The following very simple problem demonstrates how an expertsystem can be used with LINDO. This demo assumes anunderstanding of LINDO models and results. For information onusing LINDO, see the LINDO Users Manual and reference books.

Suppose we have an EXSYS expert system with the variables[PROFIT X] and [PROFIT Y], which represent the profit gainedfrom product X and product Y. The expert system will calculatethese values based on market trends, supply, or other factors thatwould govern the profitability of the products.

What we want to do is select the number of X and Y to manufactureeach day to maximize the total profit, which is the sum of X timesthe profit from X plus Y times the profit of Y. In LINDO notation,with EXSYS variables included, this is

MAX [PROFIT X] X + [PROFIT Y] Y

There are various constraints on manufacturing the products due toproduction capability. It takes 4 units of production capacity tomanufacture an X product and 3 units of production capacity tomanufacture a Y product. We have only 10 units of productionavailable per day. In the LINDO model for the problem, this will berepresented as

4X + 3Y < 10

where X and Y represent the number of product X and product Ywe should manufacture per day under current market conditions.Also, because of supply limitations, we have another constraint onproduction of:

3X + 5Y < 12

To create an interface between EXSYS and LINDO

1. Write an expert system to derive the value of [PROFIT X] and[PROFIT Y] based on various factors.

2. Once the value is derived, call LINDO to find the optimum pointof operation. There are many ways this could be done. One simpleway is to use the command language to force executions of the rulesto derive the values of [PROFIT X] and [PROFIT Y] and then callLINDO.

N - LINDO INTERFACE 12

Page 532: Manual Exsys

The command file would look like

RULES [PROFIT X]RULES [PROFIT Y]LINDO(FIND_OPT.LIN)REPORT(FIND_OPT.RPT)

The first line invokes all rules that will derive a value for [PROFITX]. The second does the same for [PROFIT Y]. The third line callsLINDO using the LINDO specification file FIND_OPT.LIN (thiscould have any name). We then call the report generator to displaythe results.

3. Write the LINDO specification file, in this case FIND_OPT.LIN.This contains the model and instruction on what data to return toEXSYS variables. In this case, the specification file would read

MAX [PROFIT X] X + [PROFIT Y] YST4X + 3Y < 103X + 5Y < 12~RESULTS[X PER DAY] = VAR VALUE X[Y PER DAY] = VAR VALUE Y[TOTAL PROFIT] = FUNCTION VALUE 1

The first line says to maximize the profit of X times the number of Xproduced plus the profit of Y times the number of Y produced. TheEXSYS variables [PROFIT X] and [PROFIT Y] will be replacedautomatically by the values calculated by the expert system beforethe model is run. The ST in the second line is LINDO notation thatindicates the start of the constraints. Lines 3 and 4 are theconstraints on manufacturing X and Y in LINDO notation (Theselines could also contain EXSYS variables if desired). The~RESULTS indicates the end of the LINDO model commands andthe start of commands to return results to EXSYS. After the modelis run, these commands will be used to parse the LINDO results file.The 6th line will assign the EXSYS variable [X PER DAY] theoptimum number of X to be produced as calculated by LINDO,based on the model. This will be in the VARIABLE VALUE columnof the LINDO results in the row X. We also do the same for theEXSYS variable [Y PER DAY]. The final line assigns the EXSYSvariable [TOTAL PROFIT] the value calculated by LINDO for themaximum profit at the optimum point of operation. This is in theOBJECTIVE FUNCTION VALUE column of the LINDO results forformula 1.

N - LINDO INTERFACE 13

Page 533: Manual Exsys

4. Write a report specification to format and display the valuesreturned. A very simple one would be

FILE TEMP"OPTIMUM POINT OF OPERATION"" ""Current Profitability:"[PROFIT X][PROFIT Y]" ""Optimum Point of Production"[X PER DAY][Y PER DAY]" ""------------------------------------"[TOTAL PROFIT]CLOSEDISPLAY TEMP

This would output the profitability calculated by the expert system,the optimum number of X and Y to produce and the totalprofitability. It uses the technique of creating a file and thenimmediately displaying it.

5. Run the system. Suppose that the expert system calculates avalue of 2 for [PROFIT X] and 3 for [PROFIT Y]. When we buildthe LINDO model, these values will be put in it to produce

MAX 2X + 3YST4X + 3Y < 103X + 5Y < 12

LINDO will use this model to calculate the optimum values for X andY. This will be put in a temporary file, which EXSYS will parse forthe information request to be assigned to EXSYS variables. Thevalues 1.272727 and 1.636364 will be assigned to [X PER DAY] and[Y PER DAY], respectively. The [TOTAL PROFIT] variable will begiven a value of 7.4545.

N - LINDO INTERFACE 14

Page 534: Manual Exsys

Using the report generator to format these results, the end user willsee the following:

OPTIMUM POINT OF OPERATION

Current Profitability:Profit from product X = 2Profit from product Y = 3

Optimum Point of ProductionNumber of X to produce per day =1.272727Number of Y to produce per day =1.636364

------------------------------------Total profit per day = 7.4545

The user did not have to build an LP model or understand the resultsfile produced by LINDO. The user only had to answer the questionsin the expert system. The EXSYS/LINDO interface did the rest.

N - LINDO INTERFACE 15

Page 535: Manual Exsys

Chapter O

Utility Programs

O1: Compressing Edited Files

Note: The effects of SHRINKP areirreversible so always run SHRINKP on abackup copy of the knowledge base, neveron your only copy.

When you are developing an expert system knowledge base it isfrequently necessary to edit rules, correct typos, etc. This leads tosome wasted space in the .TXT file. The utility programSHRINKP.EXE compresses the .TXT file by eliminating no longerneeded text and then rearranging the file so that the order allows themost rapid access to the text. SHRINKP also eliminates all unusedvariables and formulas.

It is not necessary to run SHRINKP very often, but once aknowledge base has been fully developed it is a good idea to useSHRINKP to put the base in its best possible form.

To use SHRINKP, click on the SHRINKP icon and select the file toshrink.

SHRINKP needs extra space on the disk while it is rearranging thedata. The disk must have enough space on it for an extra copy of the.TXT and .RUL files you are shrinking.

SHRINKP will remove any unused formulas or variables and re-number the variables that remain. If your expert system calls anexternal program for multiple variables, be sure to check that thenumbers of the variables receiving data from the external programare still correct. You may have to modify the external program toreflect the new variable numbers or pass the data by variable namerather than number.

O - UTILITY PROGRAMS 1

Page 536: Manual Exsys

O2: Rule Organizer

Note: The effects of FASTERP areirreversible so always run FASTERP on abackup copy of the knowledge base, neveron your only copy.

The time it takes for a set of rules to execute in backward chaining ishighly dependent on the order and arrangement of the rules and theamount of backward chaining required for derivations. In mostknowledge bases, the rules are not arranged in such a way that theprogram runs as fast as possible. In small knowledge bases this is nota problem, since the rules will still execute very quickly. In verylarge knowledge bases, however, there can be a significant delay inrunning the rules if they are arranged poorly.

The utility program FASTERP will rearrange the rules in aBACKWARD CHAINING knowledge base to make it run faster.The difference can be very significant. In one test of a large set of rules,FASTERP was able to improve execution speed by a factor of 20.

Note: FASTERP will have no beneficial effect onforward chaining systems and may even create arule order inappropriate to forward chaining.

To run FASTERP, click on the FASTERP icon.

The rearranged rules will then be stored in a new file, written over theold version (Always run FASTERP on a backup copy, just in case).

Once the rules have been rearranged, your expert system may askyou questions in a different order than it did previously; however, theprogram should come to the same conclusions. If, after runningFASTERP, the program reaches different conclusions with the sameinput data, there is a logic error in the rules or an incomplete set ofrules. Examine how the conclusions were reached in each case to seewhere the difference occurred. The following are errors that cancause differences:

1. The "use only first rule" option was chosen and there arerules that allow the same input data to result in different valuesbeing assigned to a qualifier depending on which rule is foundfirst.

2. The rules allow the same input data to have valid rules thatgive a 0 and a 10 to the same choice. The first one found locksthe value.

3. Calculations with numeric variables can be dependent on theorder in which the calculations are executed.

O - UTILITY PROGRAMS 2

Page 537: Manual Exsys

It is possible to use FASTERP to find errors in the logic of the rules.If after running FASTERP, the same data produces different results,there is probably an error of logic that is in both the old and new rulearrangements. You may find FASTERP useful as a rule checkingutility. Experiment with it.

If speed is a major factor in your expert system, arrange the rules touse the FORWARD and NOBACKWARD options. This will beMUCH faster than any backward chaining arrangement, even if youoptimized with FASTERP.

O3: Moving Files Between Operating Systems

The EXSYS Professional programs running on MS-DOS, UNIX andVAX/VMS computers all use the same knowledge base structure. Itis therefore possible to move knowledge bases between operatingsystems without modification. Unfortunately, it is sometimes difficultto get an identical copy of the .RUL and .TXT files when they aremoved between machines. More importantly, the alignment ofelements of data structures is different on some machines.

In order to avoid these problems, the recommended approach is toprint the rule in rule compiler format. This produces a simple ASCIItext file. Move this file along with any .CMD, .SCR, .HLP, .CFG etc.files to the target machine. Re-compile on the target machine usingthe EXSYS Rule Compiler.

O - UTILITY PROGRAMS 3

Page 538: Manual Exsys

O4: Pager

Note: PAGER is not supported on alloperating systems

PAGER is used in the report generator when you want to print ordisplay a file with headers and page numbers and/or separated intopages. You would generate and close a file with the report generator.This file would contain the information used by PAGER. You wouldthen call the PAGER program from the report generator to generatethe file with the page breaks and headers.

The syntax is

PAGER input_file output_file left_marginbody_length [page_length]

PAGER reads the input file and generates the output file with pagebreaks and margins.

input_file File to read; generated with the report generator.

output_file File with page formatting.

left_margin Column number where the first character of the line starts. Use a value of 1 for no margin.

body_length Number of lines to be printed in the body of the page. Must be greater than 0.

page_length Total number of lines on a page. If set, this will write blank lines to fill the rest of the page instead of form feeds. The page length must be greater than the number of lines in the header or it will print pages with only a header. The page length should be greater than the body length + header length. This parameter is optional.

Commands can also be put in the input_file to change the parametersset during formatting. This allows sections of the report to beformatted in different ways. The page header and page numbercommands can only be set as commands in the input_file. Thesyntax for the commands in the input_file are

O - UTILITY PROGRAMS 4

Page 539: Manual Exsys

>>left_margin=# Change the left margin.>>body_length=# Change the body length.>>start_page_header Start the definition of a page

header.>>end_page_header End the definition of a page

header.>>page_number Print page number.

Note: All commands must start at thebeginning of a line except>>PAGE_NUMBER.

Right MarginThe right margin is not set by PAGER. It is up to you to make surethe lines are not too long. If you are using the report generator, youcan insure this by using the WIDTH command in EXSYS.

HeadersIf you do not define a header, PAGER will not insert any pagebreaks. You can define a header at any time. You can change it atany time. A header is defined when PAGER encounters text startingwith >>start_page_header. The text following this command, up to aline starting with >>end_page_header, will be used as the header foreach page. You can include the page number in the header by usingthe command >>page_number anywhere in the header text. The">>page_number" will be replaced by the actual page number in theformatting. For example:

>>start_page_header

Expert System ReportEXSYS Inc.PAGE: >>page_number____________________________________________

>>end_page_header

If you do not want a header printed but you do want page breaksthen define a header that has no text or blank lines.

Lines Per PageIf the number of lines printed on the page so far exceeds thebody_length, then PAGER will break the page. If you specified thepage_length, then it will fill the rest of the page with blank line;otherwise, it will print a form feed.

O - UTILITY PROGRAMS 5

Page 540: Manual Exsys

If you do not specify a page_length or a header and print more thana page of text, then the page numbers will not be accurate. This isbecause PAGER cannot tell if it has reached the end of a page. Itcannot go by body length because, without a header, there is nobody.

You can change the margins, header or body length at any time. Ifyou change the body length, it will not go into effect until the nexttop of page.

Page BreakYou can force a page break anywhere by putting a form feed in thefile. To do this from the report generator use "@@012" (include thequotation marks). Do not put a form feed in a header (it causes aninfinite printout). Do not put any text between a form feed and theend of that line (it will not be printed). You may put text before aform feed but if this file is viewed on the computer screen, it couldhave a line that runs off the screen. It will print correctly, however.

O - UTILITY PROGRAMS 6

Page 541: Manual Exsys

O5: EX_TIME

Note: EX_TIME is not supported on alloperating systems

The Utility EX_TIME is used when you want a formatted time ordate displayed. You can display the time as either a string or anumeric. You can control the format of the output time/date string bypassing EX_TIME a format string. The reserved command wordsoccurring in the format string will be substituted for the appropriatevalue. All the other characters in the format string will be unchanged.

The syntax of the call is

EX_TIME format_string [time_in_seconds]

EX_TIME writes to the file return.dat. The output is the time valueformatted by the format_string specified.

format_string The commands that specify how to format the output string.

time_in_seconds The time value to format in seconds. This parameter is optional. If it is not specified then the current time is used.

Format_strings are made up of command words and any other textwhich is not a command word. Command words are replaced bytheir value. All other text is repeated exactly as it appears and in thesame place in the string.

The following are command words recognized in the format string:

Month The full month name, capitalized.For example, August

month The full month name, not capitalized.For example, august

Mon The abbreviated month name, capitalized.For example, Aug

mon The abbreviated month name, not capitalized.For example, aug

Month# The number of the month, with leading 0's.For example, 08

month# The number of the month, without leading 0's.For example, 8

O - UTILITY PROGRAMS 7

Page 542: Manual Exsys

Weekday The full day name, capitalized.For example, Tuesday

weekday The full day name, not capitalized.For example, tuesday

Day The abbreviated day name, capitalized.For example, Tues

day The abbreviated day name, not capitalized.For example, tues

Day# The number of the day, with leading 0 if proper.For example, 05

day# The number of the day, without leading 0's.For example, 5

year The full numbers for the year. For example, 1989

year# The shortened number of the year. For example, 89

sec# The number of seconds past the last minute.For example, 05

seconds The number of seconds since 1970.For example, 113457705

min# The number of minutes past the last hour. For example, 35

hour# The number of hours. For example, 12

hour The number of hours military time. For example, 24

am_pm Either “am” or “pm.” not capitalized.For example, am

Am_pm Either “AM” or “PM” capitalized. For example, AM

For example, suppose the time is October 13, 1989 at 5:00pm.

EX_TIME "hour#:min# month#/day#/year#"

would return "5:00 10/13/89."

EX_TIME "Month day#, year at hour#:min#"

would return "October 13, 1989 at 5:00."

EX_TIME "Weekday the day#, hour# am_pm"

would return "Friday the 13, 5 pm."

O - UTILITY PROGRAMS 8

Page 543: Manual Exsys

To use EX_TIME from within EXSYS, call it like any other externalprogram. The formatted string will be returned in return.dat to avariable. For example, you could have a string variable [DATE]with an associated call to EX_TIME to get a formatted time string

RUN(EX_TIME ......)

This could be used from the report generator or anywhere theformatted string was needed. It could be embedded in other stringsusing the [[ ]] parameter replacement.

EX_TIME can also be used with the results of the EXSYS functionAGE which returns the number of seconds since a variable value wasset.

O - UTILITY PROGRAMS 9

Page 544: Manual Exsys

O6: Repeat

Note: REPEAT is not supported on alloperating systems.

The utility REPEAT will perform the command N times where youspecify the command and N.

The syntax of the call is:

REPEAT num_times_to_repeat command_to_repeat

REPEAT will execute the command as many times as specified bynum_times_to_repeat.

Here is an example:

REPEAT 3 "COPY REPORT.DOC PRN > NUL"

This copies the report to the printer 3 times and doesn't print the "1file(s) copied" message by redirecting it to NUL.

One problem you may encounter is that DOS sometimes modifiesparameters passed to programs. It will delete characters like ". It willchange characters like ; into a space. It will convert a parameter withspaces into many parameters. To pass a string containing a space, putthe entire parameter in quotes as shown above.

O - UTILITY PROGRAMS 10

Page 545: Manual Exsys

O7: EXSQ - Report File Squeezer

Note: EXSQ is not supported on all operatingsystems.

Introduction

The purpose of EXSQ is to reformat and squeeze down reportsgenerated by the EDITXSP expert system editor so that they aremore readable and require less paper. The results are also suitable forformal documentation needs, including Copyright applications.EXSQ requires as input a report generated with the EDITXS"PRINT" option, which was directed to a disk file rather than straightto the printer.

EXSQ supports Epson dot matrix printers, Hewlett-Packard laserjetprinters and IBM dot matrix printers.

How to use EXSQ

If you simply invoke EXSQ by typing its name at the DOS prompt,it will come up in an interactive mode, requesting the file name andyour type of printer. Alternatively, you can specify all neededinformation on the command line, as follows:

EXSQ filename options

"Filename" is the name of the EXSYS report you want to squeeze.The following are available options:

/E (for Epson dot matrix printers)/H (for Hewlett Packard laserjet printers)/I (for IBM dot matrix printers)

If your printer is not one of the above, place it in a compatibilitymode that matches one of the above.

Note about HP Laserjets: After printing a squeezed report file,your "form feed" light may stay on. This should not cause anyproblems. EXSQ leaves the laserjet set for courier font, 10characters per inch horizontal, 6 lines per inch vertical.

EXSQ will generate the file SQ.PRN, which contains the squeezedversion of the report with control characters for the printer.

O - UTILITY PROGRAMS 11

Page 546: Manual Exsys

Note: EXSQ never removes the SQ.PRNfile; if the file exists, it always appends theexisting file. Therefore, you can squeeze abunch of rule bases and print them out all atonce. It's up to you to delete the sq.prn filewhenever appropriate.

The SQ.PRN file can be copied to the printer. The format controlcodes for the printer are already embedded in the file. To print thefile, just enter

COPY SQ.PRN PRN

Demonstration

You may try out EXSQ on a sample rule base report by entering thefollowing command line at the DOS prompt (replace "/p" with /E, /H,or /I, as explained in "How to use EXSQ"):

EXSQ SAMPLE.PRN /p

When EXSQ finishes, you may print the results either with the DOSPRINT command or via the COPY statement as below (put yourprinter in EPSON mode):

COPY SQ.PRN PRN

O - UTILITY PROGRAMS 12

Page 547: Manual Exsys

Chapter PSQL Commands

IntroductionStandard Query Language (SQL) is a method of manipulating andviewing information stored in databases. SQL language wasdeveloped by IBM in the mid-1970s. This language is independent ofthe database system that resides on the user's computer.

EXSYS Professional has a SQL interface that allows the developer toissue SQL commands to a large number of commercial databaseproducts. The currently supported databases are:

ALLBASE INGRESBetrieve InterBaseClipper Microsoft SQL ServerDatabase Manager NetWare SQLDB2 OracleDB2/2 ParadoxDB2/6000 PROGRESSdBase II, III, IV,V SQLBaseExcel 5.0 SQL/400Excel .XLS files SQL/DSFoxBase Sybase SQL ServerFoxPro Sybase System 10Gupta SQLBase TeradataIMAGE/SQL Text filesINFORMIX XDB

Note: EXSYS Products use third party libraries for thedatabase support. The above list will grow. See theREAD.ME on your distribution disks for the databasescurrently supported.

P1: InstallationThe EXSYS interface to the databases is made through a third partylibrary of functions from Intersolv (Q+E Software). The connectionto the database is made through the Q+E DLL (dynamic linklibraries) which must be installed on your computer. There are twogroups of DLLs related to SQL. A base group of DLLs is requiredfor EXSYS tools to load and run - even if a system does not call foran SQL interface. These DLLs are loaded during the normal EXSYSinstall procedure.

P - SQL COMMANDS 1

Page 548: Manual Exsys

In addition to the DLLs provided with EXSYS, an ODBC compliantDLL for the specific database used is required. Because of licensingrestrictions, this ODBC layer is NOT provided with EXSYS. TheODBC DLL layer may be obtained from Intersolv as their "ODBCPack" which includes the DLLs for all the databases, or the DLL fora specific database may be obtained from Intersolv. ODBCcompliant DLLs from other companies are also supposed to work -that is the whole idea of ODBC - however, EXSYS Inc. recommendsusing the ODBC DLLs from Intersolv. An ODBC compliant DLLfor the specific database being used must be present to make use ofthe SQL commands in EXSYS.

Intersolv has a variety of licensing arrangements for distribution ofthe specific database DLLs within a company. Intersolv can bereached at:

Intersolv5540 Centerview Drive, Suite 324Raleigh, NC 27606TEL: (919)859-2220

If your application does NOT make use of the EXSYS SQLcommands, all required DLLs are provided with the EXSYSsoftware and can be distributed with your application.

IMPORTANT NOTE: Unlessspecific arrangements aremade with Intersolv, youare not licensed todistribute the Q+E "ODBCPack" DLLs to others.

P - SQL COMMANDS 2

Page 549: Manual Exsys

Installation:

Copy all DLL files from the EXSYS Professional Ver. 5.0 diskettesto the \WINDOWS\SYSTEM directory.

Install the Q+E ODBC Pack software according to themanufacturer's instructions.

To define a Data Source:Click on the ODBC icon in the WINDOWS Control Panel.Under DATA SOURCES, choose ADD.Under ADD DATA SOURCE, select database type.Under ODBC <database type> DRIVER SETUP:

Enter <database type source name>* in DATA SOURCE NAME.Enter a working directory, if known.Enter other information as appropriate.

CLOSE/EXIT all the way out.

* Database type source names are found in the READ.ME on yourdistribution disks.

P1.1: SQL Interface Technical Support

The Q+E Database Driver Reference provides details on theconnection to various commercial databases and SQL commandssupported. If you have any difficulty using the SQL commandscontact EXSYS Tech Support first. EXSYS will determine if aproblem is in the EXSYS software or in the Intersolv Q+E product.If the problem is in the connection between the Intersolv DLL andyour database, it may be more efficient for you to contact Intersolvdirectly. Intersolv will provide direct support only to licensed usersof their DLL, so this another reason to obtasin your ODBC layerfrom Intesolv.

P1.2: Backward Compatibility

While the DLLs required for EXSYS Professional Ver. 5 andEXSYS RuleBook PLUS have changed, the actual EXSYS SQLInterface commands have NOT. SQL commands or command filescreated for EXSYS Professional Ver. 4 or earlier should work thesame way in Ver. 5. If any differences are encountered, it is probablydue to differences in the way the Intersolv ODBC connects to yourdatabase or to EXSYS. If you find any differences in systemfunction, call EXSYS technical support for assistance.

P - SQL COMMANDS 3

Page 550: Manual Exsys

P2: SQL CommandsThe SQL interface in EXSYS has two basic modes of operation:

1. Associating an SQL call for a single element of data with anEXSYS variable. This is done with a single EXSYS commandthat can be associated with a variable or used in the commandlanguage.

2. Issuing an SQL command which may produce multiplerecords which may each have multiple fields. Since multipleitems of data are returned, the data can not be directly assignedto a single EXSYS variable. In this case, a series of commandsin the command language enables you to sequentially read thedata and assign it sequentially to the same EXSYS variable, orto multiple variables. The commands to do this can only beissued from the command language.

P2.1: Reading a Single Item of Data into a Single EXSYS Variable

SQL_READ_ONE("Connection String", "SQL Command","Format string", [EXSYS VAR to Assign Value to])

Reads a single value from a data base with an SQL call. This shouldbe used when limited SQL access in needed, or to associate an SQLcall with a variable. This command is also designed to return only asingle value. Only the first column of the first record returned will beassigned to the variable - even if there are multiple records returned.For multiple record assignments, use the other SQL commands. Thiscommand is most useful when used as a data acquisition commandassociated with a variable. It is the only SQL command that ispractical to use this way.

Connection String The SQL connection string. This identifiesthe database, server, or password. This iscurrently the same connection string in thecommand SQL_CONNECT() command.

SQL Command The SQL command to issue. This must bea legal SQL command for the database thathas been opened. See the Q+E DatabaseDriver Reference for legal SQL commandsfor each supported database.

Format String The format string for the returned data.See the Intersolv documentation providedwith their "ODBC Pack" on formatssupported for specific databases.

P - SQL COMMANDS 4

Page 551: Manual Exsys

EXSYS Variable This is the EXSYS variable to assign thedata to. If the EXSYS variable is a stringvariable, the data will be assigned as astring. If it is a numeric variable, the valuewill be converted to a numeric value andstored. The EXSYS variable name mustbe in square brackets.

The SQL_READ_ONE command can be associated with a variableby using it as a data acquisition command. To do this, precede theprompt text of the variable with the SQL_READ_ONE command.Be sure that the EXSYS variable specified in the SQL_READ_ONEcommand matches the variable it is a data acquisition command for.

The command can also be used independently in the commandlanguage to assign data. Since this command, connects anddisconnects from the data base each time, it is much less efficient thanmultiple SQL reads during a single connection. If many items ofdata are to be read, it is better to connect to the data base, makemultiple reads and then disconnect.

P2.2: SQL Commands that Return Multiple Items of Data

SQL commands can often return multiple items of data and multiplefields. To sequentially read this data and assign it to EXSYSvariables requires a series of operations. You must:

1. Connect to the database desired.

2. Issue an SQL command that will return data.

3. Make one of the records of returned data the currentlyactive record.

4. Assign a field from the returned data to an EXSYS variable.

5. Repeat step 4 until all of the data needed for the expertsystem processing is assigned and run the expert system rules.

6. If necessary return to step 3 and make another record ofreturned data active, read more data and continue processing.

7. When all of the data needed from the SQL command hasbeen processed, indicate that the SQL command is done. Youmay then issue another SQL command and continueprocessing. (This is important for releasing resources.)

8. Indicate that the connection to the database is no longerneeded. (This is important for releasing resources.)

P - SQL COMMANDS 5

Page 552: Manual Exsys

These operations are performed in the EXSYS command languages,although step 5 can also be used as a data acquisition commandassociated with a variable.

EXSYS supports simultaneous connections to multiple databases andsimultaneous SQL commands. In order to specify which database orSQL command is being referred to, EXSYS variables are used tocarry identifier information. When you connect to a database orissue an SQL command, a value is put in a special EXSYS variable.This variable is then used in other commands to specify the databaseor SQL command.

P3: Connecting to the Database

SQL_CONNECT("Connection String",[EXSYS VAR for DB ID])

Connects to the database. Connection String sets the connectionparameters and selects the type of database. [EXSYS VAR for DBID] is used by other commands.

Connection String The SQL connection string. Thisidentifies the database, server, and/orpassword. See the followinginformation on connection stringsand the Intersolv documentationprovided with their "ODBC Pack"for details on connection strings foreach database.

[EXSYS VAR for DB ID] This is an EXSYS variable that willbe assigned a value to use as anidentifier for the database opened.This identifier will be valid until thedatabase is closed. This variabledoes not need a value before the callis made.

P - SQL COMMANDS 6

Page 553: Manual Exsys

P3.1: Connection StringsWhen you connect to a database, a connection string must bespecified to tell EXSYS the specific database being used. Some databases also require other optional parameters.

For the current list of connection strings and their associateddatabases (for Version 5.0 ODBC), see the READ.ME file on yourEXSYS distribution diskettes.

For example, if you wanted to connect to Paradox, the connectcommand would be:

SQL_CONNECT("PARADOX", [ID])

The name of the database must be exactly as listed above, and mustbe in quotes.

Some databases allow / require additional information to be specified.See the Q+E Database Driver Reference for details on your specificdatabase. The user ID, server and password can be specified byadding options to the connection string with the database name:

User ID: -U:name

Password: -P:password

Server: -S:server

For example, suppose we were connecting to Oracle running on aserver and we wanted to specify our user ID and Password:

SQL_CONNECT("ORACLE -U:myname -P:mypass -S:server", [ID])

Many of the more powerful databases require the server, user ID andpassword. If you do not know the user ID, or do not want to hardcode a password into the expert system, you can use the -DIALOGoption. This will cause a dialog to appear when theSQL_CONNECT is executed. The dialog will prompt the user fortheir password, etc. The -DIALOG command can be used inconjunction with other options. For example, you might specify theserver with a -S:server but not specify the user or password. Thiswould look like:

SQL_CONNECT("ORACLE -S:server - DIALOG", [ID])

Some databases may support other options in the connection string.These are added into the string with no prefix. For details on thespecifics of connecting to each of the databases supported, see theQ+E Database Driver Reference.

P - SQL COMMANDS 7

Page 554: Manual Exsys

P4: Executing an SQL CommandSQL_EXEC([EXSYS VAR for DB ID],"SQL Command", [EXSYS ID for Ret Data])

Makes the call to the specified database to select record(s). Thiscommand only selects the appropriate records. It does not make anyspecific record active.

[EXSYS VAR for DB ID] This is the EXSYS variable thatwas assigned a value in theSQL_CONNECT() command.It identifies the database that theSQL call is being made to.

SQL Command An SQL command appropriate forthe database selected. See theIntersolv documentation for their"ODBC Pack" for the SQLcommands supported for each of thedatabases.

[EXSYS ID for Ret Data] This is an EXSYS variable that willbe assigned a value to use as anidentifier for the data returned fromthe specific SQL command. Thisidentifier will be valid until the SQLcommand is closed. This variabledoes not need a value before the callis made.

P4.1: Selecting the Next Record of Returned Data SQL_NEXTREC([EXSYS ID for Ret Data], [EXSYS Test Flag Var])

This command makes the next record of the data returned by theSQL call into the active record. The fields in this record can then beaccessed with the SQL_VALUES command. If no previouscommands have been executed to set an active record, the first recordthat was returned by the SQL command will be made active.[EXSYS Test Flag Var] will be 0 on successfully reading the record.

[EXSYS ID for Ret Data] This is the EXSYS variable thatidentifies the specific SQL commandthat returned data. This identifierwas set by the SQL_EXEC()command.

P - SQL COMMANDS 8

Page 555: Manual Exsys

[EXSYS Test Flag Var] This is an EXSYS variable that willbe assigned a value of 0 if thecommand was successfully executed.A non-zero value indicates that thereare no more records to read or anerror occurred. If there was anerror, a separate error message willbe displayed. Testing for a non-zerovalue can be used in a WHILE loopin the command language to indicatethat all records have been processed.

P4.2: Selecting the Previous Record of Returned Data

SQL_PREVREC([EXSYS ID for Ret Data],[EXSYS Test Flag Var])

This command makes the previous record of the data returned bythe SQL call into the active record. The fields in this record can thenbe accessed with the SQL_VALUES command. If no previouscommands have been executed to set an active record, the commandwill fail. [EXSYS Test Flag Var] will be 0 on successfully readingthe record.

The command SQL_REC_OPTIONS must have been calledimmediately after SQL_EXEC for this command to be active.

[EXSYS ID for Ret Data] This is the EXSYS variable thatidentifies the specific SQL commandthat returned data. This identifierwas set by the SQL_EXEC()command.

[EXSYS Test Flag Var] This is an EXSYS variable that willbe assigned a value of 0 if thecommand was successfully executed.A non-zero value indicates that thereare no more records to read or anerror occurred. If there was anerror, a separate error message willbe displayed. Testing for a non-zerovalue can be used in a WHILE loopin the command language to indicatethat all records have been processed.

P - SQL COMMANDS 9

Page 556: Manual Exsys

P4.3: Selecting a Random Record of Returned Data

SQL_RANDREC([EXSYS ID for Ret Data],recnum, [EXSYS Test Flag Var])

This command makes a random record of the data that was returnedby the SQL call into the active record. The fields in this record canthen be accessed with the SQL_VALUES command. [EXSYSTest Flag Var] will be 0 on successfully reading the record.

The command SQL_REC_OPTIONS must have been calledimmediately after SQL_EXEC for this command to be active.

[EXSYS ID for Ret Data] This is the EXSYS variable thatidentifies the specific SQL commandthat returned data. This identifierwas set by the SQL_EXEC()command.

recnum The number of the record to makeactive. This should be a valuebetween 1 and the total number ofrecords returned by the SQL_EXECcommand.

[EXSYS Test Flag Var] This is an EXSYS variable that willbe assigned a value of 0 if thecommand was successfully executed.A non-zero value indicates that thereare no more records to read or anerror occurred. If there was anerror, a separate error message willbe displayed. Testing for a non-zerovalue can be used in a WHILE loopin the command language to indicatethat all records have been processed.

P4.4: Finding the Number of Records of Returned Data

SQL_NUMREC([EXSYS ID for Ret Data],[EXSYS VAR for number of records])

Returns the number of records returned by the SQL statement into[EXSYS VAR for number of records].

The command SQL_REC_OPTIONS must have been calledimmediately after SQL_EXEC for this command to be active.

P - SQL COMMANDS 10

Page 557: Manual Exsys

[EXSYS ID for Ret Data] This is the EXSYS variable thatidentifies the specific SQL commandthat returned data. This identifier wasset by the SQL_EXEC() command.

[EXSYS Var for number This is an EXSYS variableof records] that will be assigned the number of

records returned by the specified SQL command.

P4.5: Creating Random Access Buffers for Returned Data SQL_REC_OPTIONS([EXSYS ID for Ret Data])

Sets up buffers for many data bases to support SQL_RANDREC,SQL_PREVREC, and SQL_NUMREC. This may require significantamounts of disk space for large sets of records. This command mustbe called immediately after SQL_EXEC. If this command fails, anerror message will be displayed. DO NOT use this command unlessSQL_RANDREC, SQL_PREVREC, or SQL_NUMREC arerequired. SQL_NEXTREC does not require this command.

[EXSYS ID for Ret Data] This is the EXSYS variable thatidentifies the specific SQL commandthat returned data. This identifierwas set by the SQL_EXEC()command.

P4.6: Releasing the Data Returned from an SQL Command

SQL_END_SQL([EXSYS ID for Ret Data])

Ends commands for data associated with the SQL commandassociated with [EXSYS ID for Ret Data]. Memory used for files /data associated with the SQL command will be released. After thiscommand is executed, the EXSYS variable [EXSYS ID for RetData] should not be used until another SQL_EXEC reassigns it avalue.

[EXSYS ID for Ret Data] This is the EXSYS variable thatidentifies the specific SQL commandthat returned data. This identifierwas set by the SQL_EXEC()command.

P - SQL COMMANDS 11

Page 558: Manual Exsys

P4.7: Disconnecting from a DatabaseSQL_DISCONNECT([EXSYS Var for DB ID])

Disconnects from the database associated with [EXSYS VAR forDB ID] which was obtained from SQL_CONNECT. After thiscommand is executed, the EXSYS variable [EXSYS VAR for DBID] should not be used until it is reassigned a value with anotherSQL_CONNECT command.

[EXSYS VAR for DB ID] This is the EXSYS variable that wasassigned a value in theSQL_CONNECT() command. Itidentifies the database that the SQLcall is being made to.

P4.8: Reading a Specific Field of Returned Data

SQL_VALUES([EXSYS ID for Ret Data], columnnumber, format, [EXSYS Var for Data])

This command assigns the data in a specified field (column) of theactive record in the data returned by the SQL command. The valueis stored in [EXSYS VAR for Data]. If [EXSYS VAR for Data] is astring variable, the value will be stored as a string. If [EXSYS VARfor Data] is numeric, the value will be converted to numeric."Format" allows formatting of date strings and should only be usedwith EXSYS string variables. The most general format string is "".

[EXSYS ID for Ret Data] This is the EXSYS variable thatidentifies the specific SQL commandthat returned data. This identifierwas set by the SQL_EXEC()command.

column number The column (field) number of thedata to be assigned. Numbers start at1.

format A format string to specify theformatting of data. See the Q+EDatabase Driver Reference. Themost general format string is "".Format strings other than "" shouldonly be used when assigning data toan EXSYS string variable.

P - SQL COMMANDS 12

Page 559: Manual Exsys

[EXSYS Var for Data] This is the EXSYS variable that willbe assigned the data. If the variableis a string variable, the valueassigned will be converted to astring. If it is a numeric, it will beconverted to a numeric.

P4.9: Reading the Name of a Column of Returned Data

SQL_COL_NAME([EXSYS ID for Ret Data],column number, [EXSYS VAR for Data])

Returns the name of the specified column (field) in the recordsreturned by the SQL command. This value is stored in [EXSYSVAR for data], which must be a string variable.

[EXSYS ID for Ret Data] This is the EXSYS variable thatidentifies the specific SQL commandthat returned data. This identifierwas set by the SQL_EXEC()command.

column number The column (field) number that you wantthe name of. Numbers start at 1.

[EXSYS Var for Data] This is the EXSYS variable that willbe assigned the data. The variableMUST be a string variable.

P4.10: Reading the Number of Columns of Returned Data

SQL_NUM_COLS([EXSYS ID for returned data],[EXSYS Var for Data])

Returns the number of columns (fields) in the records returned by theSQL command. Value is stored in [EXSYS Var for Data], whichmust be a numeric variable.

[EXSYS ID for Ret Data] This is the EXSYS variable thatidentifies the specific SQL commandthat returned data. This identifierwas set by the SQL_EXEC()command.

[EXSYS Var for Data] This is the EXSYS variable that willbe assigned the number of columns(fields) . The variable MUST be anumeric variable.

P - SQL COMMANDS 13

Page 560: Manual Exsys

P5: TransactionsMany SQL databases support transactions. This allows a series ofSQL commands to be executed that would modify the database, butnot have the modification actually made until the commands arecommitted. If for some reason, a decision is made to not actuallychange the database, the commands can be canceled withoutchanging the actual database.

Note: Not all databases support transactions.

To execute transactions:

1. Call SQL_BEGIN_TRANS()

2. Execute SQL commands.

3. If the changes are to be made execute a SQL_COMMITbefore closing the database. If the changes are to be canceled,execute a SQL_ROLLBACK.

P5.1: Beginning a TransactionSQL_BEGIN_TRANS([EXSYS VAR for DB ID])

Marks the start of a transaction with the database associated with[EXSYS VAR for DB ID] . Any modifications to the database willnot be actually made until a SQL_COMMIT is encountered. ASQL_ROLLBACK will cancel all modifications made following theSQL_BEGIN_TRANS. An error will produce an error message.

[EXSYS VAR for DB ID] This is the EXSYS variable thatwas assigned a value in theSQL_CONNECT() command.It identifies the database that theSQL call is being made to.

P5.2: Committing a TransactionSQL_COMMIT([EXSYS VAR for DB ID])

Commit modifications made to the database associated with[EXSYS VAR for DB ID]. All modifications made following theSQL_BEGIN_TRANS will be made to the database. An error willproduce an error message.

[EXSYS VAR for DB ID] This is the EXSYS variable that was assigned a value in the SQL_CONNECT()command. It identifies the database that the SQL call is being made to.

P - SQL COMMANDS 14

Page 561: Manual Exsys

P5.3: Canceling a TransactionSQL_ROLLBACK([EXSYS VAR for DB ID])

Cancel modifications made to the database associated with [EXSYSVAR for DB ID]. All modifications made following theSQL_BEGIN_TRANS will be canceled. An error will produce anerror message.

[EXSYS VAR for DB ID] This is the EXSYS variable that was assigned a value in the SQL_CONNECT() command.It identifies the database that the SQL call is being made to.

P6: Using SQL Commands

Reading a single item of data into an EXSYS variableUse the Data Acquisition command to associate a SQL_READ_ONEcommand with the EXSYS variable. Select "Data Acquisition"from the dialog box for adding / editing variables. Select "SQLInterface" and a dialog box will be displayed. Select the databasetype. Enter any required options for that database, and the SQLcommand to execute. Normally the SQL command will be aSELECT command. The first item of data returned by the SQLcommand will be assigned to the EXSYS variable. If string data isbeing returned, be sure that the EXSYS variable is a string variable.

Using the SQL commands in a Command FileFrequently SQL SELECT commands return multiple records.Stepping through these records is a procedural operation, so it isdone in the Command Language. In the .CMD file, connect to a database with the SQL_CONNECT command. Execute an SQLcommand with the SQL_EXEC command. If the command was aSELECT command, you may then step through the returned dataone record at a time and apply the expert system rules to the data.

For example:

1 SQL_CONNECT("PARADOX", [DB ID])2 SQL_EXEC([DB ID], "SELECT * FROM ACCTS

WHERE DAYS_LATE >30", [CMD ID])

3 SQL_NEXTREC([CMD ID], [TEST FLAG])4 WHILE ([TEST FLAG] == 0)

P - SQL COMMANDS 15

Page 562: Manual Exsys

5 SQL_VALUES([CMD ID], 1, "", [NAME])6 SQL_VALUES([CMD ID], 2, "", [ACCT NO])7 SQL_VALUES([CMD ID], 3, "", [MAX])8 SQL_VALUES([CMD ID], 4, "", [MIN])9 SQL_VALUES([CMD ID], 5, "", [AVG])10 SQL_VALUES([CMD ID], 6, "", [DAYS LATE])

11 CLEAR R ALL12 CLEAR Q ALL13 CLEAR C ALL14 RULES ALL15 REPORT SQLDEMO.OUT16 SQL_NEXTREC([CMD ID], [TEST FLAG])17 WEND

18 SQL_END_SQL([CMD ID])19 SQL_DISCONNECT([DB ID])

Note: The line numbers are not part of thecommand file and are included here only toallow easy reference to a line.

In this example, line 1 connects to the Paradox database DLL.The variable set in line 1, [DB ID] will be used in subsequentSQL_EXEC commands. Line 2 executes an SQL SELECTcommand to return data. The EXSYS variable [CMD ID] will beused in subsequent commands to refer to this data. Line 3 sets thenext (in this case the first) record of data returned by the selectcommand. The test flag variable [TEST FLAG] will be set to 0 ifthere was data returned and the commands enter the While loop inline 4. Lines 5-10 assign data to specific EXSYS variables. Lines11-13 clear out all previous data and the rules are run in line 14.A report of the results of the system for the first record of data isoutput by line 15. Line 16 attempts to make the next record of dataactive. If there was another record of data returned by the SQLcommand in line 2, the value of [TEST FLAG] will be set to 0 andthe While loop in line 4 will repeat. When the last record of data hadbeen analyzed, the value of [TEST FLAG] will not be 0 and thewhile loop will end. Line 18 releases the memory associated with theSQL command from line 2. Line 19 disconnects EXSYS from thedatabase.

P6.1: Some Basic SQL CommandsThe following commands are the some of the basic commands usedin SQL. Not all databases support all commands. There are MANYmore commands supported by powerful database programs. Consultyour database documentation and the Intersolv documentation thatcame with the Q+E Database Driver Reference for details onsupported commands for specific databases.

P - SQL COMMANDS 16

Page 563: Manual Exsys

SELECT

The SELECT command is used to retrieve records from thedatabase. All databases support this command to some extent.Paradox and dBase, among others, fully implement it. The basicform of the command is:

SELECT {* | field, ...} FROM filespec [additional clauses]

One or more fields can be specified. Additionally, clauses can beused to further refine the search. One common, and useful, clause isWHERE. For example:

SELECT * FROM dbname WHERE field > x

This command will return all fields of all records where a specifiedfield value is greater than x.

SELECT supports aggregate functions such as MIN, MAX, andAVG. Thus, the total of a particular column, where certainconditions are met, can be returned.

INSERT

The INSERT command is used to add new records to the database.The basic form is:

INSERT filespec (field, ...) VALUES (expr, ...)

One or more fields and values (expressions) can be specified.

UPDATE

The UPDATE command is used to change records in the database.The basic form is:

UPDATE filespec SET field=expr, ... [WHERE | CURRENT OF]

One or more fields and values can be specified.

P - SQL COMMANDS 17

Page 564: Manual Exsys

DELETE

The DELETE command is used to delete records in the database.The basic form is:

DELETE FROM filespec [WHERE | CURRENT OF]

CREATE TABLE

This command is used to create new database files. The basic formis:

CREATE TABLE filespec (field def, field def, ...)

DROP TABLE

This command is used to delete database files. The basic form is:

DROP TABLE filespec

P - SQL COMMANDS 18

Page 565: Manual Exsys

Chapter Q

ExDesign -Custom Screen Design Program

Q1: IntroductionExDesign is a versatile and easy-to-use utility for creating EXSYSProfessional GUI custom screens for data input, custom help andhypertext screens.

ExDesign allows the user to avoid having to create EXSYS CustomScreens "by hand", using a text editor. This helps anyone who wishesto create an EXSYS Custom Screen to avoid having to memorizeEXSYS Custom Screen Language syntax. As one selects and placesthe chosen Custom Screen Objects on the ExDesign Work Screen,the program automatically generates the correct syntax in the customscreen file. Also, the user can directly manipulate the position andsize of these objects as they refine their design. Other Attributes canbe adjusted via pull-down menus and dialog boxes.

ExDesign is also useful for modifying or updating existing EXSYSCustom Screens. It has built-in facilities for checking the syntax ofthe existing screens in a pre-created screen file as they are loaded.This makes it a useful debugging aid.

Q2: Master System HelpHelp is available at any time from the main work screen by selectingHelp under the Change menu. This calls the Master System Helpfunction. Click on the topic desired and a summary of the syntaxfor the command will be displayed. Help may also be activated onthe Macintosh by selecting the "About ExDesign" menu item (or onother platforms, the "About" menu item under File) and clicking onthe Help button.

Q3: File MenuThis menu is used whenever the user needs to create a new screenfile, load an existing one or save the currently loaded screen file. It isalso used to load another screen in an existing file or add a newscreen to a file of existing screens. Finally, it is also used to exit theprogram. Q - ExDesign Custom Screen Design Program 1

Page 566: Manual Exsys

Q3.1: NewThis menu option is used to create a new custom screen file. Untilone or more screens are added to the new file, it will be empty. Thefirst thing that ExDesign will require from the user in order to createthis file, will be the filename. A window appears immediately afterselecting this feature which contains an edit box provided for thispurpose. If the filename is typed in with no extension, the programwill provide the default .SCR extension. If it is desired that anotherextension be used, (for example .HLP when creating an EXSYSCustom Help file,) then it must be provided by typing the full nameof the file to be created into the edit box. The Open button can thenbe selected to open a file with the name provided. If the user changestheir mind, and decides not to pursue this option further, they canselect the Cancel Button. ExDesign will display a message stating thatno file was opened, and then return to the main work screen.

If the user happens to select a filename that already exists in thecurrent working directory, a window will appear with a messageasking if they wish to erase the existing file or cancel the action andreturn to the main work screen. If they choose to erase the existingfile, its contents will be lost. If the user wishes to check the contentsof the file before it is erased, they must use the Cancel button toreturn to the main work screen and then resume by selecting the FileOpen Menu.

If the user wishes to select another working directory in which toopen the new screen file, then they should use the scroll bar to moveto the end of the list of file and directory names in the list box. If thedesired directory is a subdirectory of the current directory, select itwhen it appears and click on the Open button. That directory willnow become the current directory. If the user selects the [..] listingand then clicks on Open, the current directory will be replaced by itsparent directory. They can also switch to a directory on anotherdrive by selecting the drive name in the list box and then clicking onthe Open button. This process can be continued, even combining theabove procedures, until the current directory is set to the one desired.However, when the desired directory is reached, the user will need toenter a valid filename in the edit box, before they can continue to thenext step: entering a screen identifier for their first new screen. Onemay, at any time, exit the process and return to the main workscreen by selecting the Cancel button.

Once a valid filename has been entered and that file has been opened,then it is necessary to specify an identifier for the first screen that isto be created. A window will appear for this purpose, containing anedit box where the user will need to type in the correct syntax forthe screen identifier. This syntax is described in Chapter I of theEXSYS Pro manual.

Q - ExDesign Custom Screen Design Program 2

Page 567: Manual Exsys

NOTE: Make sure that the screen identifierbegins with a "~" character.

Once this screen identifier has been input, click on the OK button.ExDesign will then return to the main work screen where one maybegin to create the new screen. It is possible, however, to abort theprocess by selecting the Cancel button, which will cause ExDesign todisplay an error message and then exit the program.

Q3.2: OpenThis menu option is used to open a existing screen file. The first thingthat ExDesign will require from the user in order to open this file willbe the filename. A window appears immediately after this feature isselected which contains an edit box provided for this purpose. If thefilename is typed in with no extension, the default .SCR extensionwill be added by the program before it attempts to load the file. If itis desired that another extension be used, (for example .HLP whencreating an EXSYS Custom Help file), then it must be provided bytyping the full name of the file to be created into the edit box. TheOpen button can then be selected to open a file with the nameprovided. If the user changes their mind, and decides not to pursuethis option further, they can then select the Cancel Button. ExDesignwill then display an message stating that no file was opened, and thenreturn to the main work screen.

The way to select another working directory, from which to open thenew screen file, varies among the various operating systems.In MS-Windows, use the scroll bar to move to the end of the list offile and directory names displayed in the list box. If the desireddirectory is a subdirectory of the current directory, select it when itappears and click on the Open button. That directory will nowbecome the current directory. If the user selects the [..] listing andclicks on Open, the current directory will be replaced by its parentdirectory. It is also possible to switch to a directory on another driveby selecting the drive name in the list box and then clicking on theOpen button. This process can be continued, even combining theabove procedures, until the current directory is set to the one desired.However, once the desired directory is reached, it will be necessaryto enter a valid filename in the edit box. This must be done beforeone can continue to the next step: entering a screen identifier for thefirst new screen. Alternatively, the user may select any of the screenfiles listed in the list box and then select Open. In either case,ExDesign will then attempt to load the indicated file. Also, if, forexample, the desired filename cannot be found and it is decided toexit the process before clicking on the Open button, one may returnto the main work screen by selecting the Cancel button.

Q - ExDesign Custom Screen Design Program 3

Page 568: Manual Exsys

Once the user has entered a valid filename and that file has beenopened, then it will be necessary to select an identifier from the listbox of existing screens for the screen that one wishes to edit. If thescreen identifier for an existing screen is selected, ExDesign willcheck the syntax of the custom screen commands as it attempts toexecute each command and thereby display that screen object on themain work screen. If it finds a syntax error, it will display a window,indicating the line in the file that it was attempting to execute when itencountered the error. After the user clicks on the OK button, theprogram will be unable to continue with the selected screen, andExDesign will abort.

If one wishes to add a new screen to the screen file, then the entry"** ADD NEW SCREEN **" should be selected. This entry appearsat the end of the screen identifier list. Once this entry is selected, awindow will appear containing an edit box enabling the user to enterthe new screen identifier. The syntax for EXSYS custom screenidentifiers is described on pp. I-5 through I-7 of this manual. (NOTE:Make sure that the screen identifier begins with a "~" character.)Once this screen identifier has been input, select the OK button.ExDesign will then return to the main work screen where the usermay begin to create the new screen.

If, however, it is decided to abort the process by selecting the Cancelbutton before inputting a screen identifier, ExDesign will display anerror message and then exit the program.

If the user has been editing a particular screen file, and wishes tobegin editing another screen in that file, (or add a new screen to thefile,) then they should follow the above procedures, beginning withselecting the File Open Menu. Using either the procedure for the listof filenames or the edit box provided, give the name of the currentfile, just as it was originally entered. Then, at the Screen Identifier listbox, select the Screen Identifier desired, or "**ADD NEWSCREEN**" to create a new screen and add it to the current file.

Q3.3: SaveThis menu option will save the current file using the name underwhich it was opened. It allows no interaction, and will simply save thefile, no questions asked. It is the quickest and easiest way toperiodically save the work that has been done in the currentExDesign editing session.

Q - ExDesign Custom Screen Design Program 4

Page 569: Manual Exsys

Q3.4: SaveAsThis menu option enables the user to save the current file under aname that they specify. Either a new name or the current name canbe used. By specifying a path that is different than the currentdirectory, the file can even be saved in another directory, even onanother drive. Simply, type the name that one wishes to use, with orwithout a new path, in the edit box in the window that appears.When this is completed, select the OK button. The process may beaborted by selecting Cancel and the program will return to the mainwork screen without saving the file.

Q3.5: PrintTo print the screen file produced, save the screens created, exitExDesign and print directly from the operating system.

Q3.6 ExitThis menu option enables the user to exit the program and return tothe Windows Program Manager. If no changes have been made toany of the screens in the current screen file, it will immediately exitthe program. If, however, any of the screens in the current file havebeen changed since the file was last saved, a dialog box will appearasking the user if they want to discard those changes and exit, or ifthey want to save them before exiting. The Cancel button will causeExDesign to return to the main work screen and the user mayresume editing, without any other effects upon the screens in thecurrent screen file.

Q3.7: AboutSelecting this option brings up a dialog box stating the currentversion number of the program. If the Help button on this dialog boxis selected the Master System Help function will be requested.

Q3.8: Adding a New ScreenTo add a new screen, select "New Window" under the "Windows"menu.

Q - ExDesign Custom Screen Design Program 5

Page 570: Manual Exsys

Q4: Object MenuExDesign provides two types of objects that can be placed on anEXSYS Custom Input Screen, control objects and graphical objects.Control objects are those that are capable of sending input data toEXSYS when they are activated during EXSYS run. This categoryincludes Push Buttons, Radio Buttons, Check Boxes, Edit Boxes,Slide Bars and Mouse Regions. Graphical objects are objects that aredrawn on the EXSYS Custom Screen at runtime, but are not capableof returning data to EXSYS, such as rectangles, ovals and lines.

The only time that it is recommended that one control object overlapanother control object is when overlaying mouse regions to cover acomplex shaped region of the screen. These overlapping mouseregions should all have the same return string. Control objects ofother types should not be overlapped at any time. You may howeveroverlap control and graphical objects, and the control objects willalways be displayed "on top" of the graphical objects. You may alsooverlap graphical objects with other graphical objects of any type. Inthis case, the last graphical object to be drawn, corresponding to thelast command line in the appropriate sequence in the EXSYSCustom Screen file, will be the one that is displayed "on top".

Note: Each and every EXSYS Custom Screenshould contain at least one Push Button, RadioButton or Check Box with the "ReturnImmediate" option selected. This function iscommonly implemented by placing an "OK" or"Continue" Button somewhere on each screen.

Once an object is placed on the screen, it can appear in one of two modes:

1. The actual display of the button, oval etc.

or

2. A manipulator box that enables you to resize and move theitem.

You can switch between the two modes by clicking on the item. Themanipulator box mode appears as a rectangle with small black boxesat the corners and sides. When the item is in this mode, you can:

1. Resize the box

Position the cursor on any of the small black boxes. Push theleft mouse button (or on Macintosh, the only mouse button)down and hold it down. Move the cursor. The size of the boxwill follow the cursor. The corner boxes allow both height andwidth to be changed at the same time. The side boxes onlychange one dimension. When the box is the desired size,release the mouse button.

Q - ExDesign Custom Screen Design Program 6

Page 571: Manual Exsys

2. Move the box

Position the cursor inside of the rectangle. Push the left mousebutton (or on Macintosh, the only mouse button) down andhold it down. Move the cursor. The box will follow thecursor. When the box is in the correct position, release themouse button.

3. Change options

When a item is selected, you can change its parameters bydouble clicking on the item. The options available depend onthe type of item selected and are discussed under the individualitems.

4. Align Items

When multiple items are selected, they can be aligned by usingthe Align menu item.

To select multiple items, hold down the shift key as you select the items.

To better understand screen command syntax and for examples, seeSection I on the Custom Screen Language.

Q4.1 Return StringsAll of the custom screen control objects can return data to EXSYSvariables and qualifiers - buttons, mouse regions, scroll bars. Thesyntax of the returned data is usually the same as data returned froman external program. (See Section H for details of the syntax.) Theone exception to this is the " to " conversion. In some cases thereturned data needs to contain a " character to designate a qualifiername or choice text string. Since the screen commands use " " todesignate strings, a " character in the string will be incorrectlyhandled. To avoid this problem, within quoted strings a single quotecharacter ' should be used. This will be converted to a " when thestring is returned. For example, if we want to set value 1 of thequalifier named color, the normal return string would be:

Q "COLOR" 1

but in a custom screen command use:

Q 'COLOR' 1

Notice that the word color is marked with ' rather than ". When thestring is returned, the ' will be internally converted to " to returnQ "COLOR" 1.

Q - ExDesign Custom Screen Design Program 7

Page 572: Manual Exsys

The dialog box for setting the parameters for the object will have anedit field marked "Return String". Enter the string you wish toreturn in this edit field.

Each control item selected may return only one line of data.However, a screen can return multiple items of data. In many cases,a particular button may indicate that the screen should terminate andreturn data. Sometimes clicking on any button will return data, inother cases multiple data items are set and then an OK buttonreturns all of the data that was set.

Returning Commands

In addition to returning data, buttons and/or other controls. canreturn commands. The commands are the same ones that can bereturned from an external program.

!WHY Displays the current rules being tested!? or !HELP Displays the custom help file associated

with the qualifier or variable.!KNOWN Displays the known data!EXIT Exits the program!END Terminate a hypertext stack - returns to

the starting screen even if there are several levels of hypertext screens.

For example, if the return string for a button was defined as:

!WHY

clicking on the button would display the rules that caused thequestion to be asked.

Passing Back a Hypertext Call

In addition to returning data, an object can return a call to display aEXSYS hypertext keyword screen. If the return string starts with an"?", the remainder of the string will be used as hypertext keyword.

When the system is run, if a hypertext word is returned, EXSYS willre-display the current custom screen after displaying the screen(s)associated with the keyword.

It is the responsibility of the developer to add hypertext screens forany hypertext keywords defined.

The return string syntax is:?keyword

Q - ExDesign Custom Screen Design Program 8

Page 573: Manual Exsys

For example, if a mouse region was defined:

~MOUSE("?Part 23", 200, 300, 60, 30 -I)

EXSYS would display the hypertext screen associated with thekeyword "Part 23" if a mouse click was made in the regionsspecified.

Passing back !END will terminate a hypertext stack and return to thestarting screen, even if there are several levels of hypertext screens.

Q4.2 RectanglesAll custom screen objects use a rectangle to define the size. Usuallyyou will set this rectangle by resizing and moving the manipulatorboxes. However, you can also directly enter the rectangleparameters in the dialogs associated with the various objects.

The size is specified by the horizontal and vertical coordinates of theupper left corner of the rectangle, the width of the rectangle and theheight of the rectangle.

Left side, top, horizontal size, vertical size.

For example: 10,10, 100, 50 means a rectangle with the upper leftcorner at the coordinates 10,10, a width of 100 pixels horizontally,and height 50 pixels vertically .

Q4.3: Push ButtonThis object is probably the most utilitarian of all the EXSYS customscreen objects that can be used as an input device. It is commonlyused for selecting values for variables that are to be used as flags. It isalso commonly used for selecting values for qualifiers. It is commonlyused for OK buttons, hypertext or custom help requesters and forbuttons to invoke internal commands such as for Known Data, etc.

When this object is initially added to your screen file by ExDesign, ithas a default size. The color cannot be changed via the ChangeMenu, however it can be resized. The minimum useful size is about10 to 20 pixels in either direction, and the maximum is about as largeas the attributes described by the most recent ~SET_WIN command.The Push Button command line is initially created with the label"BUTTON". This should be changed before the screen containing theobject is used.

Q - ExDesign Custom Screen Design Program 9

Page 574: Manual Exsys

Parameters

To change the parameters for a button double click on it.

Rectangle

The coordinates for the rectangle position can be directly set in theedit boxes or changed by clicking on the object and dragging thesides or corners to the correct size and position. See Q 5.2

Label

When a button is initially created, it is labeled BUTTON. This shouldbe changed to reflect the function of the button.

Different GUI operating systems use different size font for buttonlabels. If the system will be run on multiple operating systems, besure to leave enough room for the label to be written in the largestfont.

Return String

The data string to return to EXSYS. See Q4.2.

Return Immediately (-I)

Immediately return data to EXSYS when this button is pressed. Atleast one button on every screen should have a "ReturnImmediately" parameter set. If no button has this parameter, youwill not be able to terminate the screen. No data is returned toEXSYS until a button with a "Return Immediately" flag is clicked.

Active at Start (-A)

Make this button the default button. This button will be used if theRETURN key is pressed. Each screen should have no more thanone "Active at start" button.

Break a Pause (-P)

A screen can be designed to display some commands, pause and thendisplay more commands. This is done with the PAUSE commandand must be done by editing a screen created with ExDesign byhand. See information on the PAUSE command in section I. If abutton with a "Break a Pause" flag set is pressed, the program willstore all data entered to that point and continue with the nextcommand after the PAUSE.

Q - ExDesign Custom Screen Design Program 10

Page 575: Manual Exsys

No Output (-X)

The No Output option indicates that the return string does notcontain data that is to be returned to EXSYS for assignment to avariable or qualifier. This is usually used for buttons that containhypertext calls or commands.

Delete Command (-D)

If the return string is a ~command, in some cases the commandshould only be executed once - even if the button is pressed multipletimes. The -D option will prevent multiple calls to the samecommand. The command is again available for use after a reset, suchas a ~PAUSE followed by a ~GOTO.

Q4.4: Radio ButtonRadio buttons are a special type of button. They are defined in agroup and the user can select only one item out of the group. Theway they are represented differs among the various operatingsystems.

This object is commonly used to input unique values for variables(e.g. switches) and, especially, qualifiers. It can assign unique valuesbecause Radio Buttons can be grouped so that one, and only one, ofa group can be selected at any one time.

If multiple groups of Radio Buttons are present on the same screen,the groups must be delimited using the -S and -E options. However,these options must be added to the screen file command lines using atext editor, after the group(s) of Radio Buttons have been created.See the Custom Screen section chapter for information on using the-S and -E options.

When this object is initially added to your screen file by ExDesign, ithas a default size. It is drawn with black text over a whitebackground. Many of its attributes can be changed via the ChangeMenu. It can also be resized. The color of the radio button can notbe changed.

In MS-Windows and Macintosh, the radio button will be displayed ina standard font size, however the rectangle specified will define theregion for the button. A click anywhere in the rectangle will activatethe radio button. Care should be exercised to make sure that thedifferent objects' reserved screen areas do not overlap.

Q - ExDesign Custom Screen Design Program 11

Page 576: Manual Exsys

The Radio Button is initially created with the label "RADIOBUTTON". This should be changed before the screen containing theobject is used.

This syntax and optional parameters for a radio button are the sameas the Push Button with the following exceptions:

1. A radio button will add a -R to the button command:~BUTTON ... -R

2. The "Return Immediate" option is legal for radio buttonsbut not recommended because it violates the style guidelinesfor the various operating systems. There should be a group ofradio buttons to select a value and an "OK" Push Button toindicate that the correct value is selected.

3. Radio buttons support the -S and -E options to indicatemultiple groups of radio buttons on a single screen. If onlyone group of radio buttons is used, the -S and -E options arenot needed.

Q4.5: Check BoxCheck Boxes are a special type of button which displays if it has beenselected or not by a check. Most Check Boxes are displayed as textwith a small square box next to it. The box will have an X or checkin the box when the item is selected, and be empty when the item isnot selected.

This object is commonly used to input values for variables (e.g. flags)and non-exclusive values qualifiers that can be assigned multiplevalues at the same time.

When this object is initially added to your screen file by ExDesign, ithas a default size. The attributes can be set via the Change Menu. Inmost operating systems, the color of the check box can not bechanged. It can be resized. This is especially important when thereare several Check Boxes on the same screen, as some care should beexercised to make sure that the different objects' reserved screenareas do not overlap. Also, the Check Box command line is initiallycreated with the label "CHECK BOX". This should be changedbefore the screen containing the object is used.

This syntax and optional parameters for a radio button are the sameas the Push Button with the following exceptions:

1. A radio button will add a -C to the button command:~BUTTON ... -C

Q - ExDesign Custom Screen Design Program 12

Page 577: Manual Exsys

2. The "Return Immediate" option is legal for check boxes butnot recommended due to the style guidelines for the variousoperating systems. There should be a one or more checkboxes to select a value and an "OK" Push Button to indicatethat the correct value is selected.

Q4.6: Slide BarA slide bar is a horizontal or vertical bar that indicates a range ofvalues. A marker, or "thumb", slides along the bar and indicates thevalue selected. This object is frequently used to quickly set anumeric variable to a value within a specified range.

It has a drawback in that the accuracy of this assignment is limitedvia the relation between the total specified range of the slide bardivided by the number of pixels covered by its length. Horizontalbars are capable of greater resolution than vertical ones, in mostcommon screen resolutions. Even on a 1024 x 768 Super VGAscreen, it is impossible to get better than one part in one thousandaccuracy with this device. So, for any situation where better accuracyis required than this device can provide, the value will have to beinput directly using an edit box.

When this object is initially added to your screen file by ExDesign, ithas a default size in a vertical configuration. The configuration andattributes can be changed via a double click. The color of the slidebar can not be changed.

There are several options available for use with Slide Bars onEXSYS Custom Screens.

Parameters

To change the parameters for a slide bar, double click on it.

Rectangle

The coordinates for the rectangle position can be directly set in theedit boxes or changed by clicking on the object and dragging thesides or corners to the correct size and position. See Section Q 5.2

Some operating systems have a standard width for a slide bar. Evenif you try to make the slide bar wider, the system default size will beused. However, not all operating systems behave the same way, andother operating systems (such as Macintosh) will make a slide bar aswide as the rectangle. It is a good idea to make the rectangle for theslide bar as close to the desired size as possible, even if the operatingsystem draws the slide bar at a different width. This is especially trueif you will be moving your custom screens between operatingsystems. Care should be exercised to make sure that different slidebar's reserved screen areas do not overlap.

Q - ExDesign Custom Screen Design Program 13

Page 578: Manual Exsys

Return Prefix

This is an address prefix to identify where the data should beassigned in EXSYS. This should usually be an identifier for whatEXSYS variable will receive the data. For example if the data is tobe returned to the variable [X], the return prefix would be:

[X]

The value selected by the scroll will be appended to the prefix tomake an EXSYS data assignment statement. Since scroll bars canreturn non-integer data, the value should not be assigned to aqualifier.

Starting Value

This is the low end value for the slide bars value range.

End Value

This is the high end value for the slide bars value range. The valuethat can be selected will be between the low and high end values.

Vertical (-V) or Horizontal (-H) Slide Bar

The slide bar orientation must be set to vertical or horizontal.

Initial Thumb Position (-A:#)

The Thumb which indicates the value of the slider can be set to aninitial value when the screen is first displayed..

Display current value (-D:x,y)

The current value of the slide bar will be displayed at the coordinatesspecified.

No return value (-X)

Sometimes slide bars are used only to display a value graphically.This is usually done by having the initial thumb position be areplaceable value taken from an EXSYS variable. In these cases nodata should be returned from the slide bar. (Note: the METERcommand is a better way to display variable data graphically.)

Q - ExDesign Custom Screen Design Program 14

Page 579: Manual Exsys

Q4.7: Edit BoxEdit boxes are a rectangle that the user can type directly into.Information can be cut and paste from other applications into an editbox.

Edit boxes enable you to directly enter values for numeric and stringvariables. It has several options for controlling the manner in whichthese values can be entered. It is possible to enter values for severalrelated variables using the same edit box, or to restrict entry to onlyone value for one variable. It is also possible to fill the edit box withtext from a file or list of values and then make the box "read only",for use as an informational display only. Multiple options can be usedon same box.

When this object is initially added to your screen file by ExDesign, ithas a default size. When it is drawn it is represented by a box with ablack single pixel width outline. The box is filled with cyan overlaidwith a yellow crosshatch pattern. This representation is used to helpyou distinguish between different objects on your ExDesign workscreen. When the screen is drawn during an actual EXSYS run, itwill be drawn using the attributes you specify. The default attributesgiven to it by ExDesign are clear background with black text andline color. The text and fill color can not be changed. The otherattributes can be changed via a double click. The edit box can beresized by entering value or sizing/moving it as a manipulator box.Edit boxes should never overlap!

NOTE: At minimum, the edit box should belarge enough to display at least one line inthe specified font. If it can not, the edit boxwill not accept text. If you create small editboxes and they appear dead when the systemis run, try making them slightly larger.

There are several options available for use with Edit Boxes onEXSYS Custom Screens.

Parameters

To change the parameters for an edit box double click on it.

Rectangle

The coordinates for the rectangle position can be directly set in theedit boxes or changed by clicking on the object and dragging thesides or corners to the correct size and position. See Section Q 5.2

Q - ExDesign Custom Screen Design Program 15

Page 580: Manual Exsys

Return Prefix

This is an address prefix to identify where the data should be assignedin EXSYS. This should usually be an identifier for the EXSYSvariable to receive the data. For example if the data entered in theedit box is to be returned to the variable [S], the return prefix wouldbe:

[S]

The value entered in the edit box will be appended to the prefix tomake an EXSYS data assignment statement. Since edit boxes canreturn non-integer data, the value should not be assigned to aqualifier.

If the prefix string includes ##, the ## will be replaced by thenumber of the line in the edit region being returned. For example ifthe edit box was for an address that might be up to 5 lines, wemight have EXSYS string variables [ADDR1], [ADDR2],[ADDR3], [ADDR4] and [ADDR5]. The return prefix could be"[ADDR##]". The first line in the edit box would be assigned to[ADDR1], the second to [ADDR2], etc. Make sure to haveenough EXSYS variables to accept the data returned.

No Edit Box Border (-B)

The default is for EXSYS to draw a one pixel wide black borderaround the edit box. If you wish to eliminate this border, check theNo Border check box. If this is selected, you should indicate the editbox in some other way.

DO NOT Wrap text (-W)

By default, EXSYS will wrap text at the edge of the edit box. Ifinstead you wish to have the text scroll past the right side of thebox, check the Do Not Wrap Text check box. This is useful foraddresses where the name may not fit in the box and where theindividual lines of data are being assigned to individual EXSYSvariables.

Allow only a Single Paragraph (-1)

By default EXSYS allows multiple paragraphs in a single edit box.A paragraph is marked when the end user pressed the ENTER orRETURN key. If it is required that the data be a single paragraph(line), check the Single Paragraph check box. This is often usedwith the option to turn off word wrap.

Q - ExDesign Custom Screen Design Program 16

Page 581: Manual Exsys

DO NOT do automatic Horizontal Scroll (-H)

By default EXSYS will automatically horizontal scroll when theword wrap option is turned off. To have EXSYS only accept asmuch text as fits on a single line in the edit box, check theNo Horizontal Scroll check box.

DO NOT do automatic Vertical Scroll (-V)

By default EXSYS will automatically vertical scroll when there aremultiple lines. To disable the vertical scroll, check the No HorizontalScroll check box.

Make text read only (-R)

The text in an edit box can be made to be read only. This is usedwhen the text in the edit box is supplied from the screen commandsor a file of text. This text can be displayed in the screen for the enduser to read, but not modify. To make the edit box read only, checkthe Read Only check box.

NOTE: Even read only boxes WILL returndata unless the Do Not Return Data optionis also used.

Add text until a ~LISTEND command (-L)

There are two ways to add text to an edit field on startup - list thetext in the screen file or read the text from a file. The first requiresthat the file be later edited with a text editor. Select the Add UntilLISTEND command for the edit box. When you have finished withExDesign, edit the .SCR file with a text editor and add the lines oftext immediately following the ~EDIT command. On the line afterthe last line of text to put in the edit box, insert a ~LISTENDcommand. All text between the ~EDIT and ~LISTEND will be putin the edit box.

For example:

~EDIT ..... -LFirst line to put in edit boxSecond line to put in edit box . .Last line to put in edit box~LISTEND

Q - ExDesign Custom Screen Design Program 17

Page 582: Manual Exsys

Add the Contents of a File to the Edit Box(-F:filename)

The second way to add text to an edit box on startup is to read thetext from a file. To do this, check the Add File Contents check boxand enter the name of the file. When the system is run, the file willbe loaded into the edit box. Usually this is used with the read onlyoption when the text is only for display to end user.The file of text may have been created with the EXSYS reportgenerator just before screen display.

Text Size (-S:x)

The default text size to use in the edit box is "Normal text". Thiscan be changed to a Big font, Small font or Fixed Space font byclicking on the appropriate radio button. the Fixed Font size isuseful when displaying tabular data since it is not a proportionalspaced font.

Maximum Number of Lines to Return (-M:#)

To limit the number of lines of data returned, check the Max NumRet Lines check box and fill in the maximum number of lines. Thisis NOT the maximum that is accepted in the edit window. If morethan # lines are entered, they will be ignored. This prevents creatingundefined EXSYS variables with ## in the return prefix.

Do Not Return Data (-X)

All edit boxes will return data. Sometimes the data in the edit box isfor information only. Even read only boxes WILL return data unlessthis option is used. To disable the return of data for an edit box, checkthe Do Not Return Data check box. (A read only box can be aconvenient way to force a file of data into the return data file.)

Q4.8: LineA line is a graphical object, and cannot be used for data entry. It isused for visually dividing different areas of the screen. It is also usedfor creating outlines around areas of text, groups of buttons or otherobjects. Other uses include creating complex borders, highlightingportions of text and in drawing.

When this object is initially drawn on your work screen by ExDesign,it is drawn from the upper left corner. It can be moved to any part ofthe work screen and resized after converting it to a manipulator box.

Q - ExDesign Custom Screen Design Program 18

Page 583: Manual Exsys

It is drawn as a black line one pixel wide. The locations of the FROMand TO ends of the line can be changed by a double click.

The color of the line can be changed by clicking on the line to makeit a manipulator box and selecting the menu Change and thenDrawing. Select the Line Color and Line Width. The other colorattributes do not apply to lines.

The user should probably also refer to the syntax for the ~CURSETcommand in the EXSYS Custom Screen Command chapter beforeusing a text editor to modify an adjacent ~LINE command line in thecurrent EXSYS Custom Screen file.

Parameters

To change the parameters for a Line double click on it.

End Points

The coordinates for the from and to points of the line position can bedirectly set in the edit boxes.

Q4.9: ArrowThis is a graphical object, and cannot be used for data entry. It iscommonly used for visually dividing different areas of the screen. It isespecially useful for drawing attention to particular buttons orportions of text.

When this object is initially drawn on your work screen by ExDesign,it is drawn from the upper left corner. It can be moved to any part ofthe work screen and resized after converting it to a manipulator box.It is drawn as a black line one pixel wide.

The color of the Arrow can be changed by double clicking on theline and selecting the color button.

This object and the syntax for its command line are described on p. I-12 of this manual. The user should probably also refer to the syntaxfor the ~CURSET command before using a text editor to modify anadjacent ~ARROW command line in the current EXSYS CustomScreen file.

Parameters

To change the parameters for an Arrow double click on it.

Q - ExDesign Custom Screen Design Program 19

Page 584: Manual Exsys

End Points

The coordinates for the from and to points of the line position can bedirectly set in the edit boxes.

Arrow Points

The arrow can have points at the from end, to end or both. Selectthe appropriate radio button.

Q4.10: OvalThis is a graphical object, and cannot be used for data entry. It iscommonly used for visually dividing different areas of the screen. It isalso used for creating outlines around areas of text, groups of buttonsor other objects. Other uses include creating complex borders, as itcan be used to create all sorts of circular objects. These objects canbe combined with other objects, so that by overlapping these objectson the work screen, curved lines may be added to these objects.When this object is initially drawn on your work screen by ExDesign, itis drawn as a round circle. It can be "stretched" or moved to any partof the work screen and resized after converting it to a manipulator box.It is drawn as a black line with a white fill color.The color of the Oval can be changed by double clicking on the Ovaland selecting the color button..

Parameters

To change the parameters for an Oval double click on it.

Rectangle

The coordinates for the rectangle position can be directly set in theedit boxes or changed by clicking on the object and dragging thesides or corners to the correct size and position. See the See Q 5.2

Q4.11: RectangleThis is a graphical object, and cannot be used for data entry. It iscommonly used for visually dividing different areas of the screen. It isalso used for creating outlines around areas of text, groups of buttonsor other objects. Other uses include creating complex borders andhighlighting portions of text. It can be used whenever the effect ofcreating a "box" around another screen object is desired, especiallywhen the effect of "boxes within boxes" is desired.

Q - ExDesign Custom Screen Design Program 20

Page 585: Manual Exsys

When this object is initially drawn on your work screen by ExDesign,it is drawn as a square. It can be moved to any part of the workscreen and resized after converting it to a manipulator box. It isdrawn as a black line with a white fill color.

The color of the Rectangle can be changed by double clicking on itand selecting the color button.

Parameters

To change the parameters for an Rectangle double click on it.

Rectangle

The coordinates for the rectangle position can be directly set in theedit boxes or changed by clicking on the object and dragging thesides or corners to the correct size and position. See Q 5.2.

Q4.12: Rounded RectangleThe Rounded Rectangle is the same as the Rectangle command, buthas rounded corners.

Q4.13: TextThis object is used to add areas containing pure text to a screen. Itcan be used to put a label on a screen object, or for informationalmessages or explanations.

When this object is initially added to your screen it is placed inside abox. It is given an initial label of Text. Which uses the Normal Fontsize, with black foreground color text and a white background.

The color of the Text can be changed by double clicking on the Textand selecting the color button.

Parameters

To change the parameters for Text double click on it.

Rectangle

The coordinates for the text position can be directly set in the editboxes or changed by dragging the text to the desired position.See Q 5.2

Q - ExDesign Custom Screen Design Program 21

Page 586: Manual Exsys

Text

The text to display can be entered / modified in the edit box.

Text Size

The size of the text can be Large, Normal or Small. Select theappropriate radio button.

Q4.14: Mouse BoxThis feature is used to add active mouse regions, also known as "hotspots" to a screen. It can be used in conjunction with areas of text,PCX file display areas and other graphical screen objects. It isespecially useful for labeled diagrams, charts, graphs and otherfigures.

When this object is initially added to your screen it is placed inside abox. The box is drawn with a dotted black outline over a clearbackground. This representation will not be used on your EXSYSCustom Screen at runtime, but is only used on your ExDesign workscreen to help you distinguish between screen objects.

Note: When the screen is actually run, aMouse Box is invisible. If you want todefine the mouse box, you must add arectangle around it.

Parameters

To change the parameters for a mouse box double click on it.

Rectangle

The coordinates for the rectangle position can be directly set in theedit boxes or changed by clicking on the object and dragging thesides or corners to the correct size and position. See Q 5.2

Return String

The data string to return to EXSYS. See Q4.2.

Q - ExDesign Custom Screen Design Program 22

Page 587: Manual Exsys

Return Immediately (-I)

Immediately return data to EXSYS when there is a click in themouse box. At least one button or mouse box on every screenshould have a "Return Immediately" parameter set. If nothing hasthis parameter, you will not be able to terminate the screen. No datais returned to EXSYS until a button or mouse box with a "ReturnImmediately" flag is clicked.

Break a Pause (-P)

A screen can be designed to display some commands, pause and thendisplay more commands. This is done with the PAUSE commandand must be done by editing a screen created with ExDesign byhand. See information on the PAUSE command in EXSYS ManualSection I. If a mouse box with a "Break a Pause" flag set is clickedon, the program will store all data entered to that point and continuewith the next command after the PAUSE.

No Output (-X)

The No Output option indicates that the return string does notcontain data that is to be returned to EXSYS for assignment to avariable or qualifier. This is usually used for buttons that containhypertext calls or commands.

Delete Command (-D)

If the return string is a ~command, in some cases the commandshould only be executed once - even if the mouse box is clicked onmultiple times. The -D option will prevent multiple calls to the samecommand. The command is again available for use after a reset, suchas a ~PAUSE followed by a ~GOTO.

Return on DOUBLE Click (-2)

This option is very similar to the Return Immediate option, howeverthis option requires a DOUBLE click to return. The ReturnImmediate option requires only a single click.

Q - ExDesign Custom Screen Design Program 23

Page 588: Manual Exsys

Q4.15: PCX (MS-Windows only)This feature enables you to add a region to your work screen fordisplaying a file containing a graphical image stored in the popularPCX format. This is especially useful for applications that will requirethe user to identify a region on a chart or map, identify a piece ofequipment on a diagram, etc.

EXSYS will display the PCX image from the file name indicated. Ifthe image that is stored on the PCX file is larger than the size givenin the RCT of the ~IMAGE command, it will display as much as willfit matching the upper left corner of the image to the upper leftcorner of the PCX box on your EXSYS Custom Screen. If theimage is smaller, the areas between the right and bottom edges of theimage and the right and bottom edges of the PCX box will be filledwith white.

Horizontal Offset

The number of pixels for the horizontal offset into the image.The default is 0, which is the left edge of the image.

Vertical Offset

The number of pixels for the vertical offset into the image.The default is 0, which is the top edge of the image.

Q - ExDesign Custom Screen Design Program 24

Page 589: Manual Exsys

Q4.16: MetersMeters are used to display animated data about the state of EXSYSvariables. Meters are not used for data input. Meters are mosteffective in systems that run repeatedly with constantly changingdata, such as when EXSYS is connected to the PI process historianpackage. However, meters can also be used to display static data, orin cases where data is manually input.

The meter displays the data in one of three forms:

HorizontalVertical

Dial

100

80

60

40

20

70.1

1.0 1.5 2.0 2.5 3.0 3.5 4.0

2.32

3

4

5

6

7

5.34

In MS-Windows, Meters can be placed over a PCX image created ina "paint" program to provide a background. Make sure that the~IMAGE command occurs before the ~METER commands.

Meters reflect the current value of the EXSYS variable that they areassociated with. The meter value is updated when theUPDATE_METER command is encountered in the command file.One way to do this is to have a command file of the form:

DISPLAY(meter.scr /C /N)WHILE ([X] < 200) RULES ALL UPDATE_METERS CLEAR(ALL)WEND

In this case, the first line displays a screen that contains the meters.The /C and /N are needed to have the screen be displayed and thenhave EXSYS continue executing commands. The commands then

Q - ExDesign Custom Screen Design Program 25

Page 590: Manual Exsys

enter a WHILE loop. In this case, if [X] is greater than or equal to200, the WHILE loop terminates, possibly to do some additionalanalysis, or to run additional commands that might display an alarm.First we run the rules which may involve automatic data acquisitionof variable values. Then the meters are updated to reflect the valuesused in that run. The data is then cleared and rerun. On each loopthrough, the meters will be updated to reflect the values on that run.

Parameters

To change the parameters for a mouse box double click on it.

Rectangle

The coordinates for the rectangle position can be directly set in theedit boxes or changed by clicking on the object and dragging thesides or corners to the correct size and position. See Q 5.2

Variable

A meter reflects the value of a specific EXSYS variable. Select thevariable to use.

Shape

Select to have the meter be a Horizontal, Vertical or Dial meter.

Label

The meter can be given a label to identify it, such as "Pressure".If no label is desired, leave the edit box blank.

Scale

The scale for the meter is specified by the minimum value, maximumvalue and number of increments. Since each increment will belabeled, be careful to allow enough space between increments for thevalues. Also, select increments that divide the scale in to roundnumbers (or use the Scale Precision option below)

Alarm Thresholds

The alarm thresholds specify high and low threshold values. If theEXSYS variable value passes these values, the color of the meter willchange to reflect an alarm condition. If no alarm values are desired,select values outside of the range of the meter.

Q - ExDesign Custom Screen Design Program 26

Page 591: Manual Exsys

Bar Color

The default meter colors is a blue bar which becomes red whenalarm thresholds are passed. The color of the bar can be changed toany other color desired.

Alarm Bar Color

The default meter colors is a blue bar which becomes red whenalarm thresholds are passed. The color of the alarm bar can bechanged to any other color desired.

Do Not Add a Scale

If a meter without a scale is desired, check the No Scale box.The alarm threshold values will still be active.

Scale and Value Precision

The scale and value of the variable is displayed in the meter. Tocontrol the precision that the value is displayed with enter a precisionspecification. This is of the form A.B. The value A is the totalnumber of digits displayed. The value B is the number displayedright of the decimal point. To force a value to have 3 digits with nomore than 1 digit right of the decimal point, use 3.1.

Q4.17: List Boxes, Buttons and EditsA list box is a rectangle that lists multiple items that can be selected.If there are too many to fit in the box, a scroll bar allows you tomove around in the list. List boxes are ideal when you want youruser to select one, or more, items out of a defined list. The "list" toput in the list box can be defined in the custom screen commands,come from a file or be the list of values for a specific qualifier. Thelist box can either return the value selected, or the number of thevalue. The data can be returned to a qualifier or variable. Single,multiple choice or "read only" lists can be created.

In addition to the standard list box, EXSYS also supports "listbuttons" and "list edits". A list button is like a list box, but takes upless space. Only the selected item is displayed, but when you click onit the full list drops down for you to select from. List Buttons aresometimes called "Drop Down Lists". A "list edit" is similar to a ListButton in that only a single item is display and the full list dropsdown, but the end user can also type directly into an edit region toenter values not it the list. A single screen can have up to 50 listboxes, buttons and edits.

Q - ExDesign Custom Screen Design Program 27

Page 592: Manual Exsys

Parameters

To change the parameters for a mouse box double click on it.

Rectangle

The coordinates for the rectangle position can be directly set in theedit boxes or changed by clicking on the object and dragging thesides or corners to the correct size and position. See Q 5.2

If the List Edit or List Button options are used, only a small editregion or button will be displayed. The width will be the widthspecified, but the height will be only about 20-30 pixels (dependingon operating system). The position will be determined by the upperleft corner. When the list is "pulled down" by the arrow, the listdisplayed will be the full size specified by the rectangle. Make surethat the rectangle defined is large enough to display a reasonableoption of the list.

Return Prefix

The string to precede the return data. Usually "Q#" or "[...]" toidentify the qualifier or variable. If the Q"name" form is preferred,replace the " with '. For example, to return data to the qualifiernamed "COLOR", we would use:

Q 'COLOR'

The text of the list item(s) selected will be preceded by the "retprefix" string and must make a valid EXSYS data assignmentstatement. The default is to return the actual string selected. Forqualifiers, it is usually necessary to return the number of the itemselected. This is done by using the Return Number (-N) option.

Control Type

The default is to make a list box. This can be changed to two otherforms of lists.

LISTBUTTONOnly a button will be displayed with an arrow next to it. Aclick on the arrow displays the full list to make a selection.The current selection is displayed on the button.

LISTEDITList edits a similar to list buttons, but the displayed value canbe directly changed by typing into it.

Q - ExDesign Custom Screen Design Program 28

Page 593: Manual Exsys

Putting Data in the ListData can be added to the list several ways.

Note: because the list text display isnot directly controlled by EXSYS, hypertext can NOT be used in the elements in the list.

List of data followsRead all following lines of text into the list until a ~LISTENDis encountered. In this case the data can not be entered fromExDesign and must be edited with a text editor. To do thisfinish designing the screen with ExDesign and save the file.Open the file with a text editor and find the ~LIST command.Immediately after the ~LIST command, add lines in the screenfile. This is the data that will be added to the list. After the lastline of data for the list, add ~LISTEND.

Read contents of text file into the listIf a file of data is selected, enter the name of the file containingthe list elements.

Add the Values from a QualifierAdd the list of possible values from qualifier # to the list.

If there is no # specified, the qualifier associated with the screen willbe used. For a ~~Q_DEFAULT screen, use only -Q. If the screen isassociated with a specific qualifier, only the -Q is needed. If thequalifier is not indicted by the screen name, or if there are multiplelist boxes from different qualifiers, use the -Q# form.

Return the number of the element selected (-N)The usual default is to return the text of the item selected. Thisoption should be used for lists associated with qualifiers. Listsassociated with variables will usually return the actual string selectedfrom the list. For example:

~LIST "[X] " 100, 75, 200, 180 -F:zzz.dat -N

would create a list box and put the values from file zzz.dat in it. Thereturn string would be "[X] " followed by the number of the valueselected.

NOTE: If either the return prefix stringstarts with 'Q' or the -Q option is used,EXSYS will assume that the number of theitem should be returned and willautomatically add the -N. In these cases the-N is not needed.

Q - ExDesign Custom Screen Design Program 29

Page 594: Manual Exsys

Return the string value (-S)

This is normally the default, however if either the return prefix stringstarts with 'Q' or the -Q option is used, EXSYS will assume that thenumber of the item should be returned. To override this, use the -S(This should rarely be needed.)

Make the listbox READONLY (-R)

This can be used for displaying data that is not to be selected by theend user. This option can not be use with List Edits or List Buttons.

Return Immediately on Double Click (-I)

By default EXSYS will not return from a list box until a button ormouse region with a Return Immediate flag set is clicked. In somecases where a screen has a single list box, it is convenient to have adouble click on a list box item indicating that the data should beprocessed immediately, without clicking on an OK button. Thisoption applies only to list boxes and not list button or list edits.

Allow multiple selections (-M)

The default in listboxes is to allow only one item to be selected. TheMultiple option allows multiple items to be selected. If a limit isspecified, EXSYS will allow multiple items to be selected, but willcheck that not more than # have been selected. This option can notbe used with List Buttons or List Edits which can never have morethan one value selected.

Some item in the list MUST be selected (-G)

If nothing is selected, EXSYS will display an error message andrequire the user to select something.

Do not return data for the item (-X)

No data will be returned. This is usually only used with the ReadOnly option.

Q - ExDesign Custom Screen Design Program 30

Page 595: Manual Exsys

Set starting selected value (-D)

The default is for EXSYS to make the first item in the list the startingselected value. This can be changed. The command has severalforms:

1. Do not select any item at startup (-D).

2. Make item # in the list the starting selected value (-D#).

3. For List Edits the string in the edit box is set to the specified string (-D"string"). This form applies only to List Edits.

Q5: Aligning ObjectsTo align object, select 2 or more objects on the work screen. Unlikethe Change Menus, it actually requires that more than one object berepresented as a manipulator box when it is invoked. The usershould, in fact, select all of the objects that are to be simultaneouslyaligned by changing each of them to its manipulator boxrepresentation. It is also important to note that the edges of thegroups manipulator will be used to set the alignment of all of thepreviously selected objects.

Position

This feature allows the user to modify the position attributes of agroup of objects, from the values that are stored on thecorresponding command lines in the screen file, to those of thegroups manipulator.

1. Select the items to be aligned.

2. Under the "Align" menu, select "Move"

3. Select to align to the top edge, bottom edge, left edgeor right edge of the last item selected.

For example, if you select several items and select "Top Edge", all ofthe top edges will align.

Stretch

Stretch is the same as Move except each object stretches to thespecified edge.

Q - ExDesign Custom Screen Design Program 31

Page 596: Manual Exsys

Size

The size of the items selected can also be aligned. The size of theLAST item selected will be used as the size all other items are set to.

1. Select the items to be made the same size.

2. Select the item to be used as the guide LAST.

3. Under the "Align" menu, select "Size"

4. Select to set widths or heights the same.

Color

The color of the items selected can also be aligned.

1. Modify one of the objects so it has the desired color.

2. Select the items to be made the same color.

3. Under the "Align" menu, select "Color".

Spacing

The spacing between objects can be made the same.

1. Select the objects.

2. Pull down "Align Spacing".

3. Select horizontal or vertical.

Q6: Selecting Multiple ObjectsObjects can be quickly selected by dragging a lasso around them. Tocreate the lasso, find a point that is not on any object, push down andhold the left mouse button and drag out the lasso around the objectsto be selected, and release the mouse button. All objects that arecompletely inside the lasso will be selected. If you hold the shift keywhile you drag out the lasso, then all objects that are partially ortotally inside the lasso will be selected.

Q - ExDesign Custom Screen Design Program 32

Page 597: Manual Exsys

Chapter R

Fuzzy LogicFuzzy logic is a very powerful technique that enables you to buildexpert systems that more closely reflect the real world. If you lookat many books on fuzzy logic, they are filled with arcane set theorynotation and are quite difficult to read and understand. As withmany complex subjects, there is a core portion of fuzzy logic thatcan be easily explained and implemented. This is surrounded by themuch more complex, rigorous mathematics of the subject, that arenot necessary for the average user.

EXSYS Inc. has a 12 year history of taking complex and difficultconcepts of expert system theory and making them easy to use andunderstand. EXSYS takes this same approach to fuzzy logic. UsingEXSYS Professional, the core portion of fuzzy logic has been madeeasy to use in expert system development.

R1: IntroductionSuppose you are building an expert system to control thetemperature of hot water fed to a machine. In a non-fuzzy system,you might have a rule

IFThe input water is too hot

THENMix cold water with the input stream

When this rule is run, it will ask the end user if the input water is"too hot". Since this is a somewhat ambiguous question, you couldadd a rule to derive more specific information.

IF[INPUT TEMP] > 180

THENThe input water is too hot

Now the system will ask about the water temperature. Thisinformation might come from the end user or directly frominstrumentation.

The problem with this approach, is nothing happens at a temperatureof 179.9999 and the system may add too much cold water at

R - FUZZY LOGIC 1

Page 598: Manual Exsys

180.0001. This can result in the temperature being put intooscillation rather than being brought to the desired temperaturesmoothly.

The situation would be improved by adding more rules

IFThe input water is a little too hot

THENThe amount of cold water to add to the input is a little

IFThe input water is too hot

THENThe amount of cold water to add to the input is medium

IFThe input water is way too hot

THENThe amount of cold water to add to the input is a lot

with temperature rules to derive the values

IF[INPUT TEMP] <= 160

THENThe input water is OK

IF[INPUT TEMP] > 160

and [INPUT TEMP] < 180THEN

The input water is a little too hot

IF[INPUT TEMP] >= 180

and [INPUT TEMP] < 200THEN

The input water is too hot

IF[INPUT TEMP] >= 200

THENThe input water is way too hot

This breaks up the single step function into three steps. As the inputwater gets a little too hot, you try adding a little cold water. If this isnot enough, and the temperature of the input water continues to rise,at 180 you increase the amount of cold water added. If thetemperature reaches 200, you increase the amount of cold wateragain.

R - FUZZY LOGIC 2

Page 599: Manual Exsys

The three step system clearly is better at controlling the process andmore closely reflects the way a human operator would react. A hardbreak point at 180 in the first system has been made slightly "fuzzier"by breaking it into three steps. But you had to write three times asmany rules to do it. Suppose you want to break the process into 100steps and have many functions to control. The number of rulesneeded would become enormous and impractical. What would bebest, is to make it a continuous function rather than a series of steps.The solution is Fuzzy Logic.

R1.1: How Fuzzy Logic Is Implemented in EXSYS ProfessionalFuzzy logic is a technique of assigning degrees of confidence tovarious possible options, based on the value of a variable. In yourrules you did this in a crude way that could be diagrammed in agraph as:

Temperature150 160 170 180 190 200

little too hot too hot way too hot1

0

Conf

OK

The confidence for each of the three possible values is either 0 or 1depending on the temperature. There is no overlap and theconfidence changes abruptly at a specific break point.

It would be better to gradually increase the confidence in each of thevalues as the temperature increases.

As a graph, this would look more like:

Temperature

150 160 170 180 190 200

little too hot too hotway too hot1

0

Conf

OK

In this system, as the temperature increases, the confidence in eachof the three ranges will gradually increase (and in some cases, falloff) smoothly. At a temperature of 152, the confidence in "a littletoo hot" starts to increase from 0 and reaches 1 at 162. Thetemperatures between 152 and 162 give a continuous smoothlyincreasing confidence value. For any temperature, the graph showsthe confidence in each of the values. Notice that for some

R - FUZZY LOGIC 3

Page 600: Manual Exsys

temperatures, you have some confidence in two different values. At175, "a little too hot" has a confidence of .8 and "too hot" has aconfidence of .4. This is a great advantage, since you want the rulesbased on "too hot" to kick in gradually, rather than suddenly at athreshold value.

It is very important to remember that in a fuzzy system, there isa confidence associated with EACH VALUE of a qualifier - notjust the qualifier as a whole.

These graphs of confidence in a qualifier value, versus a variable(temperature) are called "membership functions" and are the key tomaking an expert system "fuzzy". For a simple case like this, itwould be possible to write a series of rules that calculated theconfidence, but it would be very cumbersome, even for this simpleproblem.

In EXSYS Professional, fuzzy logic is implemented by two simpletechniques:

1. QUALIFIERS can be made fuzzy based on an EXSYSvariable and membership functions. Membership functionsare defined with a point and click graphical user interfacethat provides easy visualization.

2. VARIABLES can be "de-fuzzified" based on theweighted average of a qualifier's confidence values. This ishow a fuzzy system ends up giving a preciserecommendation. (More on this later.)

Use of the existing EXSYS Professional data elements (qualifiersand variables) makes the addition of fuzzy logic to applications veryeasy.

Returning to the example, in a fuzzy logic version you would havefour simple rules.

IFThe input water is OK

THENThe amount of cold water to add to the input is none

IFThe input water is a little too hot

THENThe amount of cold water to add to the input is a little

R - FUZZY LOGIC 4

Page 601: Manual Exsys

IFThe input water is too hot

THENThe amount of cold water to add to the input is medium

IFThe input water is way too hot

THENThe amount of cold water to add to the input is a lot

Now you do not have to create a set of rules to convert a temperatureto a qualifier value. Instead you simply click on the "Fuzzify" boxwhen defining the qualifier.

A screen is displayed that allows you to define the membershipfunction. The membership function is defined by clicking on thegraph to indicate the shape of the function, or point coordinates aredirectly entered into a table. Each value of the qualifier has aseparate membership function, and each function is made up of asmany as to 8 straight line segments. Therefore, complexmembership function sets can be defined. A test function enablesyou to easily check the confidence of each qualifier value for anyvalue of the variable. The graph window can be scrolled andrescaled to display the entire set of membership functions.

For this problem, the membership functions are drawn to look like:

Temperature150 160 170 180 190 200

little too hot too hotway toohot1

0

Conf

OK

Once the membership function is defined for the qualifier, you donot need to add additional rules to derive the value for the qualifier.When the qualifier value is needed, EXSYS Professional willautomatically ask the value of the associated variable "temperature".The confidence of the appropriate qualifier values will then be set,based on the temperature. This confidence is automatically passedthrough to the items set in the THEN part.

For example, at a temperature of 175, "a little too hot" has aconfidence of .8 and "too hot" has a confidence of .4. Based on therules, "add a LITTLE water" would get a confidence of .8 and "addMEDIUM water" would get a confidence of .4. If the rules hadmore than one IF condition, the confidence of the IF parts would becombined before assigning the confidence to the THEN part. The

R - FUZZY LOGIC 5

Page 602: Manual Exsys

way the IF confidence is combined is handled automatically byEXSYS. In an actual system, many factors would be taken intoaccount to determine the confidence values of the "amount of waterto add".

R1.2: Defuzzification

Now you have a system that gives levels of confidence in thevarious amounts of water to add. The problem has been made fuzzy,and the answer we get is certainly fuzzy. In a plant environment,we do not want to tell the operator that "a little water should beadded with .8 confidence and a medium amount of water should beadded with .4 confidence". The operator just wants to know howmuch water to add. This is "de-fuzzification" - taking a fuzzystatement and converting it back to a precise number.

In EXSYS Professional, to make a qualifier fuzzy, you associate avariable. To de-fuzzify a value for a variable you associate aqualifier. This is typically a weighted average of the variousconfidences assigned to the qualifier values. For example, supposeyou have a variable [WATER TO ADD] and you base its value onthe de-fuzzification of the "add water" qualifier. You could use theformula:

[WATER TO ADD] = 2 * (confidence in "add a LITTLE") +

5 * (confidence in "add MEDIUM") +

10 * (confidence in "add ALOT")

In this example, it would be (2*.8) + (5*.4) = 3.6

This is about what you would expect. It is more than "add aLITTLE" amount of 2 but less than the "add MEDIUM" amount of 5.

R - FUZZY LOGIC 6

Page 603: Manual Exsys

R1.3: Advantage of Fuzzy Sets

The first one rule non-fuzzy system would have an "add water"graph that would look like:

Temperature150 160 170 180 190 200

Water

Clearly a very crude control.

With three rules, but without Fuzzy Logic, the graph improves to:

Temperature150 160 170 180 190 200

Water

But when you add Fuzzy Logic, you easily obtain a continuousgraph:

Temperature

150 160 170 180 190 200

Water

This is a much better way to control the process since it will tend tomake corrections smoothly. The exact shape of the graph isdetermined by the shape of the membership functions.

R - FUZZY LOGIC 7

Page 604: Manual Exsys

R1.4: IF / THEN Only

One difference between Fuzzy systems and other EXSYSProfessional systems is that in the Fuzzy mode, rules must be IF /THEN, not IF / THEN / ELSE. This is because of the way thatconfidence is propagated from the IF part of the rule to the dataassigned by the rule. If the IF part is false, there may be nocalculable confidence values that can be passed through to the ELSEpart. To avoid this problem, in the Fuzzy mode, EXSYS does notallow ELSE parts.

Any statement that can be made in the ELSE part of a rule can alsobe made in the THEN part of a rule with modified IF conditions.

R2: Building Fuzzy Systems - The MechanicsBuilding a fuzzy system in EXSYS Professional is identical tobuilding a non-fuzzy system in most respects. All of the EXSYS ruleediting functions, interfaces, custom screens and hypertext areavailable to build your application. The logic of the system can bedeveloped using terms such as "add a little water" in the example.Once the basic logic of your system has been developed, some (or all)of the qualifiers can be fuzzified. It's as simple as associating avariable and drawing the membership functions. If specific values arerequired as output, those variables have de-fuzzifying formulas addedto them based on one or more of the qualifiers. EXSYS Professionalautomatically will propagate the confidence of the data in the IF partthrough to the THEN part.

R2.1: Starting a System

When a new expert system is started, a screen is displayed forsetting the title, author, confidence mode, etc. To start a fuzzysystem, click on the "Fuzzy" radio button.

Because fuzzy logic handles confidence in such a different way thanthe other confidence modes in EXSYS, it is not possible to take asystem developed in another confidence mode and directly move itto Fuzzy. (This is also true of moving between any of the otherEXSYS confidence modes.) However, if you can take the basicstructure of an existing system, and create a new fuzzy system:

1. Print out your existing system in Rule Compiler format.(Select Print under the File menu, click on Rule CompilerFormat and enter a file name.)

R - FUZZY LOGIC 8

Page 605: Manual Exsys

2. Change the confidence mode to fuzzy:

PROBABILITY SYSTEM: 6

3. Fuzzy does not support ELSE - any rule with ELSE mustbe deleted and the logic modified to handle the ELSE. (ELSEparts can always also be described as the THEN part of a rule.)

4. Modify all choice confidence value to the Fuzzy system(a value between -1 and 1)

5. Compile the system with the EXSYS Rule CompilerVersion 5.0 or later.

6. Edit the system to add fuzzy membership functions, etc.with the EXSYS Professional Rule Editor Version 5.0 or later.

It is strongly recommended that a few small fuzzy systems be builtand printed in rule compiler format before attempting to move alarger existing system to Fuzzy confidence mode.

R2.2: Fuzzifying a Qualifier

To make a qualifier fuzzy, go to the dialog box that displays all ofthe qualifiers. This can be done by selecting "Qualifier List" underthe "Rule" menu item, or by clicking on the "Qualifier" button whenadding conditions to a rule. This dialog has a check box labeled"Fuzzify". Select a qualifier in the top list box and click on theFuzzify button.

R - FUZZY LOGIC 9

Page 606: Manual Exsys

A window will be displayed for defining the membership function.

The text of the qualifier is displayed in the top of the dialog box.Each of the qualifier's associated values are in the list button justunder it. To select a value, click on the value list button. It dropsdown to display all of the values. Click on a value and it becomesthe currently active value. Each value should have an associatedmembership function defined for it. All of the functions aredisplayed on the graph simultaneously, but in different colors. Thegraph for the currently selected value is in bold yellow and has smallboxes at each vertex. Only the currently selected value can have itsmembership function edited.

The graph represents the confidence (0 to 1) on the vertical axis,versus the value of an EXSYS variable on the horizontal axis. Thevariable used to set the fuzzy confidence values is selected in theupper right of the dialog. Click on the variable list button. A dropdown list of the variables in the system will be displayed. Click onthe variable to use to fuzzify the qualifier. If none of the variablesare appropriate, click on the "New" button to add another variable.The variable selected must be a numeric variable.

The scale of the graph is displayed in the edit boxes at the lowercorners of the graph. In the example above, the graph displaysvalues from 0 to 100. There are several ways to change the scaledisplayed:

1. Click on the UP / DOWN arrow under the lower and uppervalues. This will increase or decrease the value by an amountdependent on the existing values and redraw the graph.

R - FUZZY LOGIC 10

Page 607: Manual Exsys

2. Click on the UP / DOWN arrow under the middle of thegraph. This will scroll both values up or down by 1/3 of thewindow but will keep the width of ranges the same. Forexample if we start with a range of 0 to 100, a click on the UPbutton will produce a range of 33 to 133.

3. Directly enter values in the upper or lower edit box andclick on the UPDATE button. This allows any range desiredto be set. Note: No change will be displayed until theUPDATE button is clicked.

4. Clicking on the "Zoom In" button halves the scale andzooms in on the center of the graph. Clicking on the "ZoomOut" button doubles the scale and zooms out on the center ofthe graph.

A membership function graph is made up of up to 8 line segments.The segments are continuous and are defined by up to 7 vertices.The left most vertex is considered to go horizontally to the leftinfinitely. The right most vertex is considered to go horizontally tothe right infinitely. Each vertex is entered by pointing and clickingwith the mouse, or by entering values in the table at the right of thedialog box.

To add a membership function with the mouse:

1. Select a qualifier value in the top list button.

2. Move the cursor onto the graph area.

3. Press the left mouse button (or on Macintosh, the singlebutton ) down. While the mouse button is held down, twonumbers will be displayed under the graph. The first is thehorizontal position at the cursor position and the second is theconfidence at the cursor position. As the cursor is moved,these values will change.

4. When the cursor is at the position desired, release themouse button. (If you do not want to add a vertex, move themouse off the graph are before releasing the button.) A smallbox will be displayed at the vertex point and the membershipfunction line will connect to that vertex.

5. To move a vertex, click down in the box at the vertex. Asyou move the mouse (with the button down) the vertex will bedragged on the graph. When the vertex is positionedcorrectly, release the mouse button. When a vertex is beingmoved, it can not be dragged off the graph area. If a vertex ismoved past its neighbor vertices, EXSYS will automaticallyreorder the numbering of the vertices when the mouse buttonis released.

R - FUZZY LOGIC 11

Page 608: Manual Exsys

6. To delete a vertex, click down on the vertex and drag it tothe box of another vertex. Release the button while in thebox of the other vertex. All vertices between the two will bedeleted.

7. When adding a vertex between vertices, EXSYS willautomatically connect it to the two adjacent vertices.

As vertices are added with mouse, their values are automaticallyadded to the table.

The other way to define the membership function graph is to directlyenter the coordinates of the vertices in the edit boxes on the right ofthe window. This is often easier than using the mouse. When usingthe mouse, the finest resolution on the graph is one pixel. The rangeof the graph is divided by the number of pixels. This limits thepossible values that can be selected. If the value desired can not beselected, enter the closest value with the mouse and edit the valuelater.

The values entered in the table will NOT take effect until eithera button is clicked, a new value selected, the ENTER key pressedor a mouse click on the graph region.

Most functions will have a vertex that starts and ends with aconfidence of either 1 or 0. The confidence value of the first vertexis used for all values less than the position of the first vertex. Theconfidence value of the last vertex is used for all values above theposition of the last vertex. Values other than, 0 or 1 can be used forthe first or last values, but would be somewhat unusual.

Once membership functions have been added, they can be tested intwo ways.

1. Position the cursor in the red rectangle just under the graphwindow. Press the mouse button down. A white vertical linewill be drawn on the graph. The horizontal position of theline is displayed under the graph. At each point where thevertical line crosses a membership function, the confidencevalue will be displayed. The vertical line can be movedaround on the graph by moving in the red rectangle whileholding the mouse button down. Values of 0 and 1 are notdisplayed due to overlap problems.

R - FUZZY LOGIC 12

Page 609: Manual Exsys

2. Click on the "Test" button. A dialog box will be displayed.

Value to test:Do Test

O K

A value slightly lower than the lowest vertex position will bein the edit box at the top of the dialog. The confidence valuesfor each qualifier value are displayed. To test a specificvalue, enter the value of the variable that you wish to test inthe edit box at the upper left and click on the "Do Test"button. The associated confidence for each qualifier valuewill be displayed in list box. this may be repeated as often asdesired.

To test a series of values, use the scroll bar under the editregion. Clicking on the arrows moves the test value up/downby 1% of the range of vertex position values. Clickingbetween the arrow and thumb moves the test value by 5%.The entire range of values, can be examined by clicking to theright of the thumb 20 times or on the right arrow 100 times. Ifa value is entered in the edit region and "Do Test" selected,the thumb is repositioned.

When done testing, click on the "OK" button.

Example:

To use the example in the introduction. We could have a qualifier:

The input water is

1. OK2. a little too hot3. too hot4. way too hot

R - FUZZY LOGIC 13

Page 610: Manual Exsys

We would select the "Fuzzify" button and build the membershipfunctions.

Temperature150 160 170 180 190 200

little too hot too hotway too hot

1

0

Conf

OK

First select the "OK" value and enter a vertex of 155 with aconfidence of 1 and a second vertex at 160 with a confidence of 0.All temperatures less than 155 will give the "OK" value aconfidence of 1. Next select the "a little too hot" value and enter avertex at 152 with a confidence of 0. Then enter vertices at 162 withconfidence 1, 175 with a confidence of 1 and 182 with confidence 0.Then select the third value by clicking on the value list button andclicking on the "too hot" value. The membership function weentered for the first value is still on the graph, but is now thin redline. The current value is always a bold yellow line. We wouldenter vertices of 172 with confidence 0, 179 with confidence 1, 198with a confidence of 1 and 203 with confidence 0. Then select thelast value "way too hot" and enter vertices 195 with confidence 0and 202 with confidence 1. This last function only requires twovertices since we want the confidence of 1 to apply to all valueabove 202.

We then create an EXSYS variable named TEMPERATURE as thevariable to use for the function. We then only need to add the fourrules we had defined:

IFThe input water is OK

THENThe amount of cold water to add to the input is none

IFThe input water is a little too hot

THENThe amount of cold water to add to the input is a little

IFThe input water is too hot

THENThe amount of cold water to add to the input is medium

R - FUZZY LOGIC 14

Page 611: Manual Exsys

IFThe input water is way too hot

THENThe amount of cold water to add to the input is a lot

When EXSYS needs the value of the qualifier "The input water",instead of asking the user to select a qualifier value, it willautomatically ask for the value of the variable TEMPERATURE.The value of temperature will determine which qualifier values areselected and what confidence is assigned to them. This confidencewill be propagated to the THEN parts of the associated rules.

It is important to make sure some value for the qualifier will beassigned for any value of the variable that may be input. Thisusually means that at least one membership function should have aconfidence of 1 going infinitely to the left and at least one functionshould have a membership function going infinitely to the right. Inour example we accomplished this with the "OK" and "way too hot"functions which extend to cover all temperatures.

Temperature150 160 170 180 190 200

little too hot too hotway too hot

1

0

Conf

OK

The other option is to constrain the possible value of the variable[TEMPERATURE]. There could be a rule that says if thetemperature is less than 150, to do something else.

R2.3: Choices in a Fuzzy System

In a EXSYS Fuzzy Mode system, choices have confidence valuesbetween -1 and 1. A value of -1 indicates high certainty that thechoice is incorrect or invalid. A value of 1 indicates high certaintythat the choice is correct or valid. When a choice is added to theTHEN part of a rule, you will be asked to assign a confidence valuefor that choice. The confidence value assigned will be combinedwith the confidence for the IF part to produce the final confidenceassigned by that rule. The values assigned by multiple rulescombine to give the final value for the choice.

R - FUZZY LOGIC 15

Page 612: Manual Exsys

For example, if we have a rule:

IFThe color is red

THENChoice 1: Confidence = 1

If we know with absolute certainty (confidence = 1) that the color isred, we can be sure that Choice 1 is valid. However, in a fuzzysystem, the confidence that the color is red may not be 1. If thatqualifier had an associated membership function, it is likely to havea value other than 1. It will all depend on the qualifier's associatedfuzzy variable and membership function.

EXSYS multiplies the confidence of the IF part by the confidenceassociated with the choice in the THEN part and combines it withthe current confidence for the choice. This allows the propagationof the fuzzy confidence.

The confidence assigned to the choice is the product of theconfidence of the IF part and the confidence assigned to the choicein the rule. If we have the rule:

IFThe color is red

THENChoice 1: Confidence = .8

and the confidence in the qualifier was 0.6, the confidence assignedto the choice in this rule would be .6 * .8 = .48

If multiple rules assign confidence to an individual choice, the valuescombine. The algorithm used is described later, but basically:

1. Any positive confidence value increases the finalconfidence.

2. Any negative confidence value decreases the finalconfidence.

3. When a choice has a low confidence value, a high valuesignificantly increases the confidence. However, once achoice has a fairly high confidence value, additional highvalues only increase the final value slightly.

4. Equal positive and negative confidence values cancel.

The same applies to qualifiers that are assigned values in the THENpart of a rule. Using our rule:

IFThe input water is a little too hot

THEN The amount of cold water to add to the input is a little

R - FUZZY LOGIC 16

Page 613: Manual Exsys

If the confidence the input water is a little too hot is .7, theconfidence assigned to "The amount of cold water to add to theinput is a little" will be given a confidence of .7 by this rule, whichwill be combined with any other confidence assigned to thisqualifier value.

For the details on the mathematical algorithms usedto calculate and combine confidence values seeSection 6.

One of the biggest differences between the EXSYS Fuzzy mode andother EXSYS modes is that in Fuzzy, there is a distinct confidenceassociated with each VALUE of the qualifier, not just the qualifieras a whole (as in confidence mode 5).

When a qualifier is displayed in the "Known Data" window or in areport, it will have the confidence of each value displayed wheneverthe confidence is less than 1. For example, suppose we have thequalifier "The color is Red and Blue" with the confidence of "Red"at .8 and "Blue" at .4. It would be displayed as:

The color is Red (Conf=.8) and Blue (Conf =.4)

If the confidence of Blue was 1, the confidence value would not belisted:

The color is Red (Conf=.8) and Blue

R - FUZZY LOGIC 17

Page 614: Manual Exsys

R3: Defuzzifying a Variable

A fuzzy expert system typically produces a set of conclusions withvarying degrees of confidence. This may be a good representationof the real world, but it may not be practical to give as advice to anend user. The solution is to "defuzzify" a value out of fuzzy data.In EXSYS this is done by associating a fuzzy qualifier with avariable.

The qualifier used to defuzzify a variable must be either:

1. Defined to be fuzzy and associated with a set ofmembership functions based on a DIFFERENT variable.

2. Assigned values in the THEN parts of rules based on fuzzyIF parts.

One of these is required to give the qualifier different confidencesfor each of its values. It does not make sense to defuzzify based ona qualifier that always has confidence 1.

A weighted sum of the confidences assigned to the qualifier valuesis used to calculate a value for the variable.

Suppose we have a fuzzy qualifier with possible values "add alittle", "add medium" and "add a lot", and the confidence for thesevalues has been determined by a propagation of confidence frommembership functions or rules. To calculate a specific amount toadd we might set up a weighted sum:

[AMOUNT TO ADD] = 2 * (confidence in "add a LITTLE') + 5 * (confidence in "add MEDIUM") +

10 * (confidence in "add ALOT")

This will produce a non-fuzzy amount that can be recommended tothe end user. This is exactly the way it is done in EXSYS. Todefuzzify a value for a variable:

1. Select the dialog where the variable is defined. This is displayed by selecting "Variable List" from the "Rule" menu item or clicking on "Variables" when building a rule. Select avariable and click on "Edit".

2. Click on the "Defuzzify" check box.

R - FUZZY LOGIC 18

Page 615: Manual Exsys

3. A dialog is displayed:

Qualifier

Weighting Factor:Qualifier Value

Set New ValueNormalize

O KCancel Do NOT Defuzzify this Variable

4. Click on the Qualifier list button. A list of all qualifiers inthe system will drop down. Select the desired qualifier.

5. Select the first value by clicking on the Qualifier Value listbutton. It will drop down to display each value and the associated weighting factor.

6. Enter the weighting factor desired for this value in the "Weighting Factor" edit box and click "Set New Value". Theweighting factor can be any numeric value. Repeat 5 and 6 for each of the qualifier values.

7. If you wish to normalize the weighting factors, so that the weighted sum is divided by the sum of the factors, click on

the "Normalize" button. (This is equivalent to forcing the sum ofthe weighting factors to be 1, and is not normally necessary.)

8. Click OK.

Now when the expert system runs, the value of the variable will becalculated from the weighted sum.

A few things to note:

1. To be calculated, the variable MUST be either:

A. Used in the rules

B. Flagged for display with the results

C. Forced to be calculated in the command language with acommand such as:

R - FUZZY LOGIC 19

Page 616: Manual Exsys

2. Do NOT use the same variable to fuzzify a qualifier as you useto defuzzify based on the qualifier. If qualifier 1 is fuzzified basedon [X], do not defuzzify [X] based on qualifier 1. It is OK todefuzzify [X] based on some other qualifier or to defuzzify someother variable based on qualifier 1.

R3.1: Validation and Defuzzified Variables

If EXSYS validation is run on a system which has defuzzifiedvariables, the values of the variable(s) will be displayed in theresults tree along with the choice values. This makes it easy to test afuzzy system.

1. Select to run validation in a systematic mode.

2. Any qualifier that has a fuzzy membership functionassociated should be marked to be Derived.

3. The variables used to set fuzzy values for the qualifiersshould be marked to either have a single value (to limit thetest) or allowed to range over values that will assignconfidence values to the qualifiers.

4. The variables that are to be defuzzified should be markedto be derived.

5. Run the validation tests and look at the tree diagram. Itshould display the variation of both the choice confidencevalues and the defuzzified values for the variation in inputdata.

6. Using the new validation graphing display is a convenientway to examine the data. See Section 5 on GraphingValidation Data for details.

R - FUZZY LOGIC 20

Page 617: Manual Exsys

R4: Building Fuzzy Systems - Techniques and Demos

R4.1: When

Fuzzy logic is a powerful technique and has applicability in manyproblems. However, it is not the solution to all problems. Bewareof "fuzzyitis" - using fuzzy logic even when it is not needed orwhen it is counterproductive. Fuzzy logic increases the complexityof a system and decreases the ability of the end user to easilyunderstand how recommendations were made. There are severalfactors to consider to decide if fuzzy logic is a good approach to aproblem.

Fuzzy logic should be used only when:

1. Precise numerical data is available to fuzzify a qualifier.

In a Fuzzy system, qualifiers are fuzzified based on a numericvalue and fuzzy membership functions. If there is no way tonumerically measure a value, it is unlikely that fuzzy can beused effectively.

2. The degree to which something is true varies continuously,not in jumps, and the determination of the current state issubjective.

Fuzzy logic is best used when there is no specific hard breakpoint in the data. A determination of "how hot" something ismay be a good choice for fuzzy logic. It is a somewhatsubjective judgment that different individuals would makedifferently as the temperature increases. We would not expecta major change in our confidence in "hot" for a very smallchange in temperature.

On the other hand, regulatory compliance systems often havevery precisely defined limits. Regulation or law may allow upto X amount of something. Any amount more than X is aviolation, even if it is a tiny amount. The state of the qualifierchanges very abruptly at the threshold. This may not be agood case for fuzzy logic - although fuzzy logic can be usedvery effectively to handle advance warning systems that usethe increasing confidence that a violation may occur as X isapproached.

R - FUZZY LOGIC 21

Page 618: Manual Exsys

3. It is not necessary for the end user to be able to easily traceevery step of the logical process that resulted in the answer.

The complexity of confidence assigned by membershipfunctions and the ways in which confidence is combined andpropagated by the rules make it much more difficult for anend user to trace the steps in the logic. In fuzzy systems,usually the results are presented to the end user with lessexplanation.

R4.2: HowIf the three criteria are met, fuzzy may be an excellent solution to aproblem. Each problem is different, but the following is a goodapproach to building fuzzy systems:

1. Define qualifiers that describe the problem with values stated ingeneral terms such as:

low, normal, highsafe, getting near threshold, over thresholdcool, warm, hot, very hot

Do not create membership functions yet.

2. Define qualifiers that will be used for the defuzzification. Theseare the conclusions that the system will reach. Again these shouldbe in general terms such as:

The amount to add isnonelownormalhigh

The machine speed should belownormalfast

Do not create defuzzifying functions yet.

3. Write rules that uses the qualifiers defined in #1 to describe thelogic of the process and to arrive at conclusions which assign valuesto the qualifiers in #2.

For example:

IFThe temperature is high

and The pressure is normalTHEN

The amount to add is high

R - FUZZY LOGIC 22

Page 619: Manual Exsys

This type of rule should be written for each possible case. This canbe done in EXSYS Professional or, for many systems, it is may befaster to do it in EXSYS RuleBook.

To use RuleBook:

A. RuleBook does not directly support the Fuzzy confidencemode, but no choices will be added, so start a new system inany of the available confidence modes.

B. Add the qualifiers described in #1 and #2.

C. Build trees using the qualifiers from #1 in the IF part andfrom #2 in the THEN part. These trees should be completeand represent the logic of the decision making process.

D. Save the RuleBook system for future use, and print therules in EXSYS Rule Compiler format to a file.

E. Edit the text file of rules and change the line:

Probability System: x to

Probability System: 6

F. Compile the edited file with the EXSYS Rule Compiler.The resulting .rul and .txt files can be read by EXSYSProfessional. The system will be set for fuzzy logic and all ofthe qualifiers and rules will be defined. This can then befurther edited with EXSYS Professional.

4. Once the rules are built, run the system to make sure that it givescorrect answers. In this mode, the end user will be asked for thevalues of the qualifiers. It is important to make sure the system isworking at this level before fuzzy membership functions are added.

5. Edit the rules to add additional weighting factors in some rules,choices where needed in the rules, messages, etc. Test that theseadditions are working as expected. Add choices to force backwardchaining or run in a FORWARD chaining mode by addingFORWARD and NOBACKWARD to the .cfg file for the system.

6. For each qualifier in #1 that can be fuzzified based on a variable,define the variable and create fuzzy membership functions for thequalifiers. - THIS IS THE DIFFICULT PART.

Rules are a typical way to represent the facts we know.Telling someone "if.. then.." is done frequently. It is the waywe think. However, building membership functionsrepresenting the simultaneous confidence of different optionsis not something most people have experience doing. Also,

R - FUZZY LOGIC 23

Page 620: Manual Exsys

except for the rare case where there is statistical data, theexact form of the membership function is undefined. It mustbe created based on the human experts opinion of how muchconfidence to give each option. It takes some practice to learnhow to do this well. Do not be surprised if the membershipfunctions defined will have to be modified later when we testthe system.

Do not associate data acquisition commands with the variables yet.

7. Define the output variables and the defuzzifying weightingfunctions for the qualifiers in #2.

8. Run the system to make sure the variables defined are correctlysetting values for the qualifiers. If a qualifier is being directly askedand it should have gotten a value from a fuzzy variable, check thequalifier fuzzy parameter definition and trace file.

9. When the system appears to be giving good results for individualsets of data, run a systematic validation test of the system.

A. Select Validation from the Options menu.

B. Click on Systematic (System.)

C. Set ALL qualifiers that have a fuzzy membership functionand variable to be Derived. Other qualifiers may be tested orderived depending on the details of the system.

D. Set each of the fuzzy variables associated with a qualifierto be tested across a range of values that covers the expectedinput values. Set the output variables that are defuzzified tobe Derived.

E. Run the validation test. Depending on the size of thesystem, this may take some time or be finished quickly.

F. Select to see the branched tree diagram. While thiscontains all of the data we want, it is difficult to pull thepieces we need together. To make it easier to view the data,click on the Graph button.

G. Now we can graph the data many ways. Select a graph axisvariable, and optionally some other constraints. Click Done.

H. In the right side of the graph window, pull down the listbutton labeled "None" and select one of the output variables.The possible values will be graphed. This can be repeated forup to 3 output variables or choices on the same graph.

R - FUZZY LOGIC 24

Page 621: Manual Exsys

I. The graphs may show a band of values indicating the highand low values found. The exact value is determined by theparameter in the upper left box. Double click on one of theitems in the box. It will be set for its lowest value and thegraph will be redrawn. Clicking on the Up and Down buttonsallows the value of this parameter to be changed. Eachchange will redraw the graph.

J. By manipulating the parameter values chosen to graph andthe value of individual parameters, it is possible to take a 2dimensional slice of the data even though the data may be n-dimensional. Stepping through on one parameter allows the 2dimensional slice to be moved through the n-dimensionalspace in any direction. This gives tremendous flexibility toview the data. Look for places where the graphs do notappear as expected. If you would expect a function tocontinuously increase, and at some point it dips - there is aproblem. If values do not change as a parameter is varied,and you expect it to - there is a problem.

10. If any problems are detected, they are probably due to errors inthe definition of the membership function. If the cause is notimmediately obvious, run the system by hand around the pointwhere the problem occurs. If modification of the membershipfunction is needed, make changes and rerun the validation test.

11. When the system tests properly and all the graphs appearcorrect, add any required data acquisition commands toautomatically get data for variables or any command files to controlrepetitive execution of the system.

R4.3: Demos

Several demo fuzzy logic systems are provided with EXSYSProfessional. Examine these systems. Use the "Examine TreeDiagram" option under the Options menu to examine graphs of thesystems.

R - FUZZY LOGIC 25

Page 622: Manual Exsys

R5: Graphing Validation DataEXSYS Professional ver 5 adds a new way to graphically examinethe data produced during system validation. This is a very powerfulway to examine the effects changing a variable may have on theresults in a multi-variable system. Both the values of variables andchoices can be examined.

1. Run validation of a knowledge base. Select "Validation"under the "Options" menu. Select "systematic" validation.

2. Set the parameters for the validation. This sets whichqualifiers / variables should be tested, which are locked at asingle value, and which are to always be derived. (See themain EXSYS Manual for setting the parameters.)

If the knowledge base uses fuzzy logic, any qualifierthat has a fuzzy membership function associated shouldbe marked to be Derived. The variables used to setfuzzy values for the qualifiers should be marked toeither have a single value (to limit the test) or allowedto range over values that will assign confidence valuesto the qualifiers. The variables that are to be defuzzifiedshould be marked to be derived.

3. After the validation tests have run, select to see the treediagram. This tree now has a button marked "Graph". Clickon this button.

4. The Validation Graph Setup window will be displayed:

Graph Axis Variable:

Undefined Constraints:

Possible Values:

Set

Done

Defined Constraints:

This window is used to set the parameters for the graph. The graphproduced has an axis variable which can be any input variable used

R - FUZZY LOGIC 26

Page 623: Manual Exsys

in the system. Outputs for other variables or choices can be graphedagainst this variable for any combination of constraints.

For example, suppose a system uses a variable TEMPERATURE(plus other data) to determine the confidence in a choice "ADDWATER". We could select TEMPERATURE as the graph variable.If we did not add any other constraints we might get a graph:

TEMPERATURE90 100 110 120 130

This graph has a band of values that indicate the possible range ofvalues of the choice ADD WATER for each temperature tested inthe validation test. Remember that in the system there are otherfactors besides temperature that determine the final results. Forexample, at a temperature of 120, all possible combinations of inputwhich produced a confidence for ADD WATER were taken fromthe validation test tree. The maximum and minimum values aredisplayed and combined for each temperature to make the graph.

R5.1: Setting ConstraintsThis graph can be examined in many ways. In the Validation GraphSetup window all of the available constraints set when the validationwas run are displayed. Any constraint can be limited by clicking onit, selecting values and clicking on the "Set" button . The definedconstraints are displayed in the lower list box on the window. Tochange a defined constraint, double click on it to move it back to theUndefined constraint section.

The graph data is taken from the .TR1 validation tree file createdwhen validation is run. This file is KB_NAME.TR1. Each line inthe file represents one of the tests done during the system validation.During graphing, each line is read. The values for the input qualifierand variables must meet all of the specified constraints and one ofthe items to be graphed must be assigned a value in the conclusions.

R - FUZZY LOGIC 27

Page 624: Manual Exsys

For example, if the line in the tree file is:

Q1:2 Q3:1 [TEMPERATURE]:100 >>> C1:5 C2:8

This means that this particular test used input data of qualifier 1value 2, qualifier 3 value 1 and a temperature of 100. For this data,the output choice 1 got a value of 5 and choice 2 got a value of 8. Ifthere were no constraints specified, and we were graphing choice 1,the value of 5 would be saved as a possible value for a temperatureof 100. After each line in the file is read, the minimum andmaximum values for each possible temperature are graphed.

If constraints are applied, less of the lines in the file will be used.Suppose qualifier 1 is a type of material being processed. To see thegraph for only material 2 we would select qualifier 1 in the"Undefined Constraints", select value 2 and click on set. Now thegraph would still include the above line, but would not graph theline:

Q1:1 Q3:1 [TEMPERATURE]:100 >>> C1:7

because this line uses qualifier 1 value 1 which does not match outconstraint.

Note: the Axis Variable is really a defined constraint, but values aredisplayed for all possible values.

The graph can be constrained to examine results for any possiblecombination of input conditions.

R - FUZZY LOGIC 28

Page 625: Manual Exsys

R5.2: Display Variables

After the constraints are set the graph window is displayed.

Constraints

Up DownSlice Constraint

GRAPH

Setup

Graph

Graph Item 1

Graph Item 2

Graph Item 3

Auto Scale

DONE

The axis of the graph will be the variable selected in the setupwindow. The actual data that is graphed is selected in the list boxeson the right side of the Validation Graph window. Up to three itemscan be simultaneously graphed.

The items which can be selected are:

1. Choices set by the system

2. Variables assigned values in the rules

3. In a Fuzzy Logic system, variables assigned valuesthrough defuzzification of a qualifier value.

To select an item, click on the list button pull down and select anitem. If the same item is selected in multiple lists, it will only bedisplayed in the first. To select nothing, click on "NONE", the firsttime in each list. As each item is selected, EXSYS will redraw thegraph.

R5.3: Examining Values on the Graph

When the graph is displayed, the specific values for each item canbe examined by clicking on the graph. The axis value nearest to themouse click will be selected and a black vertical line will be drawn.The values where this line intersects the graph are displayed underthe graph items on the right.

R - FUZZY LOGIC 29

Page 626: Manual Exsys

Only values which were used in the validation test can be displayed.This is because only these values have been tested. For example, ifthe validation test allowed [TEMPERATURE] to go from aminimum of 90 to a maximum of 130 in 10 degree increments, wecan only test on 90, 100, 110, 120 and 130. The other values are notknown in the validation test. To examine the value at 105, thevalidation test would have to be done again with differentparameters to hit this value.

R5.4: Constraints on the Validation Graph

The list box in the upper left of the validation graph has all of theconstraints used for the graph. Any constraint that has multiplevalues can be tested for each value individually. This is equivalentto looking at a 2 dimensional slice of the data and being able tomove the slice in a third dimension.

1. Double click on the constraint. The constraint will appearin the bottom black region of the constraint box with the first(lowest) value selected.

2. The graph will automatically redraw for that value.

3. Click on the UP button to move up to the next value of theconstraint and to redraw the graph.

4. Continue clicking on the UP and DOWN buttons toincrease / decrease the constraint value.

The process can be repeated as many times as necessary. If youwish to switch to another constraint, double click on it to make it theactive constraint. Note the previous constraint will remain at its lastvalue. This allows problems found in a particular value of oneconstraint to be narrowed down by testing others. All of theconstraints can be reset by clicking on the Setup button.

R6: Combination of Confidence

IF PARTIn a rule, the IF part may be made up of one or more conditions. Ifthere is only a single condition, the confidence of the IF part is theconfidence of the single condition. When there is more than onecondition, it becomes more complex. The final calculatedconfidence of the IF part will be used in the assignment ofconfidence in the THEN part.

R - FUZZY LOGIC 30

Page 627: Manual Exsys

The IF part can be made up of 3 types of data items.

1. Qualifiers - These may have multiple values ORed in asingle qualifier, or may represent an OR block in a rule.

2. Mathematical expressions - these may have multiplevariables.

3. Choice tests.

It is important to understand how confidence is combined for eachof these items, but it should be remembered that in an actual system,EXSYS takes care of all of the math automatically.

R6.1: Qualifier ConditionsIf a qualifier has only one value set by the fuzzy membershipfunction, the confidence is simply the confidence of that value.When there are more than one qualifier values in a condition theconfidence of each value is combined. Each of the values must beconsidered.

For example, if we have the condition:

The color is red or blue

We must combine the confidence of "The color is red" and "Thecolor is blue".

There are two built in options in EXSYS Professional for calculatingthe combined confidence value. (More can be added using EXSYSLinkable Object Modules.)

Default Method of Combination

The default method is to use the formula:

Combined_Conf = Combined_Conf + (Value_Conf * (1 - Combined_Conf))

The Combined_conf starts at 0 and the formula is applied for eachvalue in the qualifier that has a value greater than 0.

For example, if value "red" has a confidence of 0.8 and value "blue"has a confidence of 0.6, the combined confidence for "The color isred or blue" is:

Initially Combined_Conf = 0

For the value "red"

Combined_Conf = 0 + .8 * (1-0) = .8

R - FUZZY LOGIC 31

Page 628: Manual Exsys

The formula is then repeated for "blue"

Combined_Conf = .8 + .6 * ( 1 - .8) = .92

The final combined confidence is 0.92.

This formula has the advantages that

1. It never exceeds a value of 1.0.

2. Each positive confidence increase the final confidence.

3. It does not matter what order is used (Try the calculationwith "red"=.6 and "blue"=.8 and it gives the same answer.)

If only "red" had been set, or if "blue" had a negative confidencevalue, only the confidence for "red" would have been used.

Maximum Method of Calculating Qualifier Confidence

An alternate method for calculating the overall confidence of aqualifier with multiple values is also available. This alternatemethod is chosen by using the EXSYS configuration optionUSE_FUZZY_MINMAX which can be set in the .CFG file orpassed on the command line. In this system, the maximumconfidence for the values set is used. In the example above, themaximum would be the 0.8 for "red". No other value would becombined with it. This system is appropriate for some problems.

OR Blocks in a Rule

If there are multiple qualifiers in the IF part of a rule in the form ofan OR Block, the overall confidence of the block is calculated thesame as the values in a single qualifier.

The default is to combine the confidence for each of the qualifiers inthe OR Block using the same formula as above:

Combined_Conf = Combined_Conf + (Value_Conf *(1 Combined_Conf))

For example, if we had three qualifiers in an OR Block:

The color is red or blueOR The temperature is highOR Today is Monday

and the confidence of "The color is red or blue" is 0.92, theconfidence of "The temperature is high" is .85 and "Today isMonday" is not true (confidence = 0):

R - FUZZY LOGIC 32

Page 629: Manual Exsys

the combined confidence for the OR block would be:

The Combined_Conf is initially 0.

Adding in "The color is red or blue"

Combined_Conf = 0 + (.92 * (1 - 0)) = .92

Adding "The temperature is high"

Combined_Conf = .92 + (.85 * (1 - .92)) = .988

The confidence for "Today is Monday" is not used since it'svalue is not greater than 0.

If the configuration option USE_FUZZY_MINMAX is set, thecombined confidence would be the maximum confidence of any ofthe qualifiers in the OR Block. In this example, it would be the 0.8for "The color is red or blue".

Assigning Confidence to a Qualifier

Qualifier data has confidence assigned in three ways:

1. If the qualifier is directly asked of the end user, or set by andexternal source, the confidence in the data is taken to be 1.

2. If the qualifier value(s) are set by a fuzzy membership functionand associated variable, the confidence is set by the membershipfunction.

3. If the qualifier is assigned a value in the THEN part of a rule, theconfidence is propagated from the IF part of the rule, and combinedwith any confidence in the THEN part.

R6.2: Variable Conditions

In the IF part of a rule, variables are used in Boolean tests. In mostcases, it is better to design systems so that variables have confidenceequal to 1. This is done by not assigning values to variables in theTHEN part of rules that have IF parts with uncertain confidence.This is often the case since numeric values should be known withhigh confidence as compared to more subjective statements inqualifiers.Any variable that has its value set by direct user input, or data froman external source, is assumed to have confidence equal to 1.

R - FUZZY LOGIC 33

Page 630: Manual Exsys

In those cases where variables must be given confidence less thanone, the default confidence for any formula that has multiplevariables is to multiply the confidence for each variable that has avalue greater than 0. If any variable has a confidence of 0 or lessthan 0, the confidence for the formula will be 0.

If the USE_FUZZY_MINMAX configuration option is set, theconfidence for a formula will be the minimum confidence of thevariables used in the formula.

R6.3: Choice ConditionsChoice conditions in the IF part which are true have confidence 1.This is because the condition is actually a test of the confidencevalue. For example:

Choice 1 > .7

means that the confidence of Choice 1 is greater than .7 . This iseither true or false. Since the confidence of Choice 1 is precise, theconfidence in the statement is 1.

If the Choice condition is false, the rule will be false.

R6.4: Overall IF ConfidenceThe overall confidence of the IF part of a rule is based on a combin-ation of the confidence of each part. A part can be a single conditionbased on a qualifier, formula, choice or an OR block of qualifiers.

The overall confidence is the product of the confidences for each ofthe parts.

If the configuration option USE_FUZZY_MINMAX is chosen, theoverall confidence for the IF part is the minimum confidence of any part.

For example, if we had the IF part:

IF X] > [Y]

AND The color is red or blue OR The temperature is high OR Today is MondayAND Choice 1 > .5

and the confidence of

[X] is .7[Y] is .8"The color is red or blue" is 0.92,"The temperature is high" is .85"Today is Monday" is not true(confidence = 0):"Choice 1" is .9

R - FUZZY LOGIC 34

Page 631: Manual Exsys

Using the default mode, first we would calculate the confidence ofthe OR Block:

The color is red or blueOR The temperature is highOR Today is Monday

This is .988 (same as the example above)

The confidence of the formula [X] > [Y] is 0.7 * 0.8 = .56

The confidence of "Choice 1" is .9

The combined confidence for the IF part would be .988 * .56 * .9 =.498

Using the same example, with the USE_FUZZY_MINMAX option:

First we would calculate the confidence of the OR Block:

The color is red or blueOR The temperature is highOR Today is Monday

This is .8 (maximum value of The color is red or blue)

The confidence of the formula [X] > [Y] is 0.7 (minimumvalue)

The confidence of "Choice 1" is .9

The combined confidence for the IF part would be theminimum of .8 , 0.7 and .9, for a overall confidence of 0.9.

R - FUZZY LOGIC 35

Page 632: Manual Exsys

R6.5: IF Conditions Summary

DefaultUSE_FUZZY_MINMAX

QualifierValues X=X+Y(1-X) Maximum value conf.

OR Blocks X=X+Y(1-X) Maximum condition conf.

Formulas Product of Minimum variable conf. variable conf.

Choices 1.0 1.0

Overall IF Product of conf. Minimum conf.

R6.6: Rule Confidence Threshold

In the Fuzzy Mode, EXSYS rules are only considered to be TRUEwhen the IF confidence is above a certain threshold. This is toprevent multiple rules with very low confidence values fromincreasing the confidence in a choice. The default threshold value is0.1. This value can be changed by using the configuration option:

FUZZY_THRESHOLD=#

where # is a value greater than or equal to 0 and less than 1.

Setting the threshold to 0 means that all possible rules will be used.If you find that too many rules with low confidence are firing, raisethe threshold.

R - FUZZY LOGIC 36

Page 633: Manual Exsys

THEN PARTWhen a rule fires in the Fuzzy Mode, the IF part will be TRUE.This means that each qualifier, formula, choice condition andqualifier OR block in the IF part is TRUEand has confidence greater than 0.

The overall IF confidence is calculated and applied to the itemsassigned in the THEN part. The confidence assigned to an itemdepends on:

1. The confidence of the IF part

2. The confidence assigned in the rule

3. The item's previous confidence

The calculation of the IF part confidence is described in Section 6.1through 6.4.

R6.7: Choices (THEN part)When choices are added to the THEN part of a rule, a confidence isassociated with a value of -1 to 1. A single choice may have valuesset in multiple rules. The overall confidence for the choice iscalculated by:

1. The IF confidence is multiplied by the confidence assigned to thechoice in the THEN part. (This will be referred to as IA for IFconf * Assigned Conf.)

2. The IA value is combined with the current confidence by a seriesof formulas. There are multiple formulas to correctly handle thecases of positive and negative confidence. (The current confidenceis referred to as CC.)

If IA and CC are both positive,

New choice Confidence isIA + (CC * (1 - IA))

(This is the same formula as used in the IF part to combineconfidence in ORs.)

If IA and CC are both negative,

New choice Confidence is- ( (- IA) + ((-CC) * (1 - (-IA))))

(This is the same formula but both values are made positive,combined as above and the resulting confidence is made negative.)

R - FUZZY LOGIC 37

Page 634: Manual Exsys

If either IA or CC is negative, but not both,

CMIN = minimum of the absolute values of IA and CC

New choice Confidence is( IA + CC) / (1 - CMIN)

For example, suppose we have a rule with the IF confidence of .75and we assign three choices:

THEN

Choice 1: Conf = .8Choice 2: Conf = -.3Choice 3: Conf= -.7

Where the current choice confidence values set are:

Choice 1 .55Choice 2 .4Choice 3 -.6

For choice 1:

IA = .75 * .8 = .6CC = .55

Since both are positive:

New Choice 1 Conf = .6 + (.55 * ( 1- .6)) = .82

For choice 2:

IA = .75 * -.3 = -.225CC = .4

Since one is positive and one is negative:

CMIN = minimum absolute value = .225 (NOTE: positive value)

New Choice 2 Conf =( -.225 + .4) / (1 - .225) = .226

For choice 3:

IA = .75 * -.7 = -.525CC = -.6

Since both are negative:

New Choice 3 Conf =-( .525 + (.6 * ( 1- .525))) = -.81

Previous NewChoice 1 .55 .82Choice 2 .4 .226Choice 3 -.6 -.81

R - FUZZY LOGIC 38

Page 635: Manual Exsys

The rules for combining confidences may seem complicated (mostlybecause they are), but the good news is that EXSYS does all thework for you. The main points to remember are:

1. Any positive confidence value increases the finalconfidence.

2. Any negative confidence value decreases the finalconfidence.

3. When a choice has a low confidence value, a high valuesignificantly increases the confidence. However, once achoice has a fairly high confidence value, additional highvalues only increase the final value slightly.

4. Equal positive and negative confidence values cancel.

R6.8: Qualifiers (THEN Part)

Qualifiers are handled almost the same as Choices. When a qualifiercondition is added to the THEN part of a rule, normally it will havea confidence of 1. Other confidence values can be assigned byentering a confidence value in the edit box when building thecondition.

In the Fuzzy Mode, qualifiers do not have a single assignedconfidence - each value has its own confidence. So when qualifiervalues are assigned in the THEN part, each value must beconsidered separately. The same formulas that are used for choicesare used, but they are simply used for each value independently.

R6.9: Variables (THEN Part)

Variables are assigned a value in the THEN part. This is alsohandled like Choices. The difference is that the assignmentstatement does not have an associated confidence factor. Instead thecombined confidence of the variables in the assignment are used asthe condition confidence. These are combined with the confidencein the IF part using the same formulas as choices.

R - FUZZY LOGIC 39

Page 636: Manual Exsys

R6.10: Changing the Way Confidence is Combined

The formulas selected to combine confidence in EXSYSProfessional should work for most problems. TheUSE_FUZZY_MINMAX configuration option gives some controlover the way confidence is combined. However, we recognize thatfor some systems totally different formulas for combiningconfidence may be required. It is possible to completely change theformulas for combining fuzzy confidence using the EXSYSLinkable Object Modules.

The functions used to combine fuzzy confidence are included in theC source code provided with EXSYS Linkable Object Modules.These functions can be modified, compiled and linked to makecustom EXSYS Editors and Runtimes. See the EXSYS LinkableObject Module manual for details on making theses changes.

R - FUZZY LOGIC 40

Page 637: Manual Exsys

Chapter S

Screen Templates

IntroductionCustom screen templates are generic custom screen designs thatautomatically apply to all of your qualifiers or variables. The entirelook and feel of the end user interface can be modified by creating asingle screen definition. The template screen is designed withreplaceable parameters for the qualifier, qualifier values andvariable prompt text. Whenever a qualifier is needed, the textspecific to that qualifier will be used to replace the parameters.Qualifier value text can be automatically used to label buttons,define mouse "hot spots" or be included in list boxes. Variables canuse the prompt text and an edit region to ask for the value. A singletemplate applies to all of the qualifiers or variables in the system.

S - SCREEN TEMPLATES 1

Page 638: Manual Exsys

S1: Using TemplatesA set of template files is provided with EXSYS Professional. Theseare labeled TEMPLT##.SCR, where ## is the number of the screen.Each template file contains templates for both qualifiers andvariables in a similar design style. This documentation illustratesthe design styles for each of the template files.

Most of the template screens for qualifiers use buttons to display thequalifier values. The screen designs have from 2 to 6 buttons. Ifthere are more buttons in a design than there are qualifier values, theextra buttons will not be displayed.

NOTE: If there are MORE qualifier values thanbuttons in the design, the extra values will NOT bedisplayed.

Select a template design that has enough buttons. If you like aspecific design, but it does not have enough buttons, make a copy ofthe template file and add buttons with EXDESIGN or a text editor.

S2: To Add Templates to Your SystemIf you already have a .SCR file

Append the contents of the template file to your .SCR file with a texteditor or operating system commands.

If you do not have a .SCR file

Make a copy of the template file and name it the same name as yourexpert system with a .SCR file extension. (For example, if yourexpert system is named FISH and you want to add template 7, youwould make a copy of the file TEMPLT7.SCR and rename itFISH.SCR.)

S - SCREEN TEMPLATES 2

Page 639: Manual Exsys

S3: Previewing Your ScreensAfter the template file is added, select Screen Preview from theEXSYS Editor's Option menu. Select to see All Qualifiers and AllVariables. EXSYS will display each of your qualifiers and variablesusing the template design (unless a specific custom screen has beendesigned for the qualifier or variable).

Check each screen to see that the text fits in the space provided bythe template and all qualifier values are listed. If you wish to changethe screen design, either edit the .SCR file or select another templatedesign.

S4: Template Designs

In the following template designs, "$Q$" would be replaced by thetext of the qualifier. $V#$ would be replaced by the text of thequalifier's value #. $T$ would be replaced by the text used toprompt for the variable.

S - SCREEN TEMPLATES 3

Page 640: Manual Exsys

Template Style 1 TEMPLT1.SCR

Allows a single qualifier value to be selected. Up to 6 qualifiervalues are allowed. The qualifier value text must be short enough tofit on the button.

Template 1 - Qualifier

Template 1 - Variable

S - SCREEN TEMPLATES 4

Page 641: Manual Exsys

Template Style 2 TEMPLT2.SCR

Allows multiple qualifier values to be selected. Up to 5 qualifiervalues are allowed. The qualifier value text must be short enough tofit on the check box line.

Template 2 - Qualifier

Template 2 - Variable

$T$

S - SCREEN TEMPLATES 5

Page 642: Manual Exsys

Template Style 3 TEMPLT3.SCR

Allows a single qualifier value to be selected. Up to 5 qualifiervalues are allowed. The qualifier value text must be short enough tofit on the radio button line.

Template 3 - Qualifier

Template 3 - Variable

$T$

S - SCREEN TEMPLATES 6

Page 643: Manual Exsys

Template Style 4 TEMPLT4.SCR

Allows selecting from qualifier values displayed in a list box. Up to30 qualifier values are allowed. The qualifier value text must beshort enough to fit on one line in the box.

Template 4 - Qualifier

Template 4 - Variable

S - SCREEN TEMPLATES 7

Page 644: Manual Exsys

Template Style 5 TEMPLT5.SCR

Allows a single qualifier value to be selected using a mouse region.Only 2 qualifier values are allowed. The qualifier value text mustbe short enough to fit on the mouse region. It will wrap to fit.

$Q$

Template 5 - Qualifier

$Q$

Template 5 - Variable

OK

S - SCREEN TEMPLATES 8

Page 645: Manual Exsys

Template Style 6 TEMPLT6.SCR

Allows a single qualifier value to be selected. Up to 3 qualifiervalues are allowed. The qualifier value text must be short enough tofit on the button.

Template 6 - Qualifier

Template 6 - Variable

S - SCREEN TEMPLATES 9

Page 646: Manual Exsys

Template Style 7 TEMPLT7.SCR

Allows a single qualifier value to be selected. Up to 3 qualifiervalues are allowed. The qualifier value text must be short enough tofit on the button.

$Q$

$V1$

$V2$

$V3$

Template 7 - Qualifier

$T$

OK

Template 7 - Variable

S - SCREEN TEMPLATES 10

Page 647: Manual Exsys

Template Style 8 TEMPLT8.SCR

Allows multiple qualifier values to be selected. Up to 4 qualfiervalues are allowed. The qualifier value text must be short enough tofit on the check box.

$Q$

OK

$V1$

$V2$

$V3$

$V4$

Template 8 - Qualifier

$T$

OK

Template 8 - Variable

S - SCREEN TEMPLATES 11

Page 648: Manual Exsys

Template Style 9 TEMPLT9.SCR

Allows a single qualifier value to be selected. Up to 6 qualifiervalues are allowed. The qualifier value text must be quite short tofit on the buttons.

Template 9 QualifierTemplate 9 - Qualifier

Template 9 Qualifier

Template 9 - Variable

$t$

S - SCREEN TEMPLATES 12

Page 649: Manual Exsys

Template Style 10 TEMPLT10.SCR

Allows selecting from qualifier values displayed in a list box. Up to30 qualifier values are allowed. The qualifier value text must beshort enough to fit on one line in the box.

OK

$Q$

Template 10 - Qualifier

OK

$T$

Template 10 - Variable

S - SCREEN TEMPLATES 13

Page 650: Manual Exsys

Template Style 11 TEMPLT11.SCR

Allows a single qualifier value to be selected. Up to 4 qualifiervalues are allowed. The qualifier value text must be short enough tofit on the button.

$Q$

$V1$

$V2$

$V3$

$V4$

Template 11 - Qualifier

$Q$

Template 11 - Variable

OK

S - SCREEN TEMPLATES 14

Page 651: Manual Exsys

S5: Modifying / Creating Your Own Templates

New templates can be created or variations of the existing templatescan be created. To make a template file:

1. Create a new template file with Exdesign or a text editor.

2. Create a screen labeled ~~Q_DEFAULT (note there are TWO ~, just like a hypertext key word). This is the template screen for qualifiers.

3. Design a qualifier screen. Wherever you would want the qualifier text, use the text $Q$ - this must be used as a text statement (no command on the line) and must be the only text in the command. If you wish the text to wrap after a specific number of pixels, the -W option can be used.

For example:~CURSET 155, 70$Q$ -W:400

would position the cursor to 155, 70 and write the text of the qualifier. The qualifier text would word wrap at 400 pixels, so no text would extend beyond the horizontal pixel 555 (155 + 400).

4. Add the values for the qualifier. These should be either buttons, mouse regions or list boxes. The text of value #

would be listed as $V#$. The return string should be just the number of the value. Define enough buttons to handle the

qualifier with the largest number of values. Buttons for values that do not exist for an individual qualifier will not be used. Qualifiers that have too many values for the available buttons will not display an error, but will only display as many values as there are buttons.

For example:

~BUTTON "$V1$", "1", 200, 160, 250, 40 -I

would create a button and label it with the text of value 1. Note that the return string is the value number, "1".

If only a single value can be selected, the buttons should use thereturn immediate (–I ) option to return immediately when one button

S - SCREEN TEMPLATES 15

Page 652: Manual Exsys

is pressed. Alternatively, radio buttons can be used with an "OK"button. In that case, only the OK button should have a returnimmediate (–I) option.

If multiple items can be selected, use check boxes and an "OK"button. Only the OK button should have a return immediate (–I)option.

Mouse regions can also be used, but should only be used when allqualifiers have the same number of values. If there are more buttonsthan qualifier values, the extra buttons will not be created. If mouseregions are used, the decoration for the mouse region will still bedrawn.

To put the values in a list box, use the ~LIST command and use the-Q option to load the list with the qualifier values. Make the list boxwide enough to hold the qualifier values.

For example:

~LIST "", 130, 130, 260, 150, -Q -N -M -G -I~BUTTON "OK", "", 220, 220, 60, 40 -I -X

would create a list box and allow multiple items to be selected.When the OK button is pressed, the selected items would bereturned as the selected values of the qualifier.

5. Create a screen labeled ~~V_DEFAULT (note there areTWO ~, just like a hypertext key word). This is the templatescreen for variables.

6. Define a variable screen. Usually this screen will have a similar design, color and border as the ~~Q_DEFAULT screen. It may be easier to copy parts of the ~~Q_DEFUALTscreen with a text editor rather than re-building it.

7. Wherever you would want the variable prompt text, use thetext $T$ - this must be used as a text statement (no commandon the line) and must be the only text in the command. If youwish the text to wrap after a specific number of pixels, the -Woption can be used.

For example:

~CURSET 155, 70$T$ -W:400

would position the cursor to 155, 70 and write the prompt textfor the variable. The variable text would word wrap at 400 pixels, so no text would extend beyond the horizontal pixel 555 (155 + 400).

S - SCREEN TEMPLATES 16

Page 653: Manual Exsys

8. Add an edit region to allow the end user to enter a value for the qualifier. The edit region should have no text in the return string prefix.

For example:

~EDIT "", 125, 160, 150, 30 -B~BUTTON "OK", "", 220, 220, 60, 40 -I -X

would add an edit region to enter the value. When the OK button is pressed the value will be accepted.

NOTE: The template screen must:

1. Return data for only a single qualifier or variable.

2. Use the $Q$, $V#$ and $T$ for prompt text.

If there are more buttons or mouse textregions defined than are needed for a specificqualifier, the extra buttons/mouse regionswill not be activated. If there are too manyvalues for the available buttons, the extravalues will be ignored - with no errormessage.

3. The return string should be only the value, not the addressinformation. For example, suppose qualifier 3 has 3 values,the return string associated with buttons or mouse regionswould be "1", "2" and "3" - NOT "Q3 1", "Q3 2" "Q3 3". Thetemplate screen must be generic. Likewise an edit region in avariable input screen should have no prefix - only the datainput should be returned. EXSYS will automaticallyassociate it with the variable being asked with the templatescreen.

S - SCREEN TEMPLATES 17

Page 654: Manual Exsys

For example, suppose you use the screen developed in the ParameterReplacement section for all of the qualifiers in the system.

Text of qualifier

Qualifier value 1

Qualifier value 2

Qualifier value 3

You add the screen code for a qualifier default screen:

~~Q_DEFAULT~SET_WIN 20, 20, 470, 265~TEXTSIZE LARGE~CURSET 55, 48$Q$ -W:300~BUTTON "$V1$", "1", 93, 90, 300, 42,-I~BUTTON "$V2$", "2", 93, 145, 300, 42,-I~BUTTON "$V3$", "3", 93, 200, 300, 42,-I~END

Now whenever a qualifier is to be asked, this custom screen will beused (unless the qualifier has another custom screen specificallyassociated with that qualifier).

Each qualifier will be asked the same way. If some qualifiers onlyhave 2 possible values, only two buttons will be displayed.However, if any qualifier has more than 3 values, only the first 3values will be displayed. Make sure that you have enough buttonsor mouse regions for the maximum number of possible values in anyqualifier.

S - SCREEN TEMPLATES 18

Page 655: Manual Exsys

S6: Editing an Existing TemplateYou may find that an existing template is correct in most respects,but needs some modification. Make a copy of the template and editit with Exdesign or a text editor.

Common Modifications:

Problem: The template uses buttons, and your system allowsmultiple values to be selected.

Solution: Convert buttons to check boxes and add an OK button.

Problem: The template allows multiple values to be selected,but your system only allows a single value.

Solution: Convert check boxes to buttons with a returm immediate -I option, or a list box that only allows a single item to be selected.

Problem: The template does not have enough buttons.

Solution: Add buttons or convert to a list box.

Problem: The system must run in monochrome and thetemplate only looks good in color.

Solution: Edit the colors with Exdesign on a monochrome computer to make an acceptable combination.

S7: Handling Individual ScreensThe template design style will apply to ALL of your qualifiers andvariables. If you wish to use another style of custom screen forsome of the qualifiers or variables, define specific custom screensfor them. Any qualifier or variable that has its own custom screendefined will use that screen rather than the template screen.

In some systems most screens can be defined successfully with atemplate, but some individual screens do not fit. For example,suppose most qualifiers had only 2 values, but one had 25. If youdesign the template to handle 25, it will not look good with only 2.If you design the template for 2 values, it will not display 25. Onesolution would be a list box, but a better one is to make a specialindividual screen for the 25 values case and a template for the rest.

S - SCREEN TEMPLATES 19

Page 656: Manual Exsys

To make an individual screen that maintains the templates designstyle:

1. Open the .SCR file with a text editor.

2. Copy the ~~Q_DEFAULT or ~~V_DEFAULT screen andgive it a name for a specific qualifier (e.g. "~Q 4")

3. Edit the new screen using ExDesign or a text editor to addwhatever special modifications are needed for the individual qualifier or variable.

When the system runs the individual screens will be used for thespecial cases and the template will be used for the rest.

S - SCREEN TEMPLATES 20

Page 657: Manual Exsys

EXSYS ProfessionalAddendum

The following new functions are notdescribed in the EXSYS Professional Manual.

Additional functions may be found in theREAD.ME file on the EXSYS distribution disks.

1. New Custom Screen Commands

Custom Screen Mouse Region LabelsIf a mouse command has a /T:"..." option, the text specified will bewritten into the mouse region using the current text size andbackground / foreground colors. Text will wrap at the boundary ofthe mouse region.

For example:

~MOUSE "1", 20, 20, 100, 40 /T:"Click Here"

will create a mouse "hot spot" and label it "Click Here" using thecurrent text size and colors.

The $V#$ replaceable parameter can also be used as the mouseregion label, in which case the text will be picked up from theappropriate qualifier's value text.

Wrapping Text in Custom ScreensIf a -W:# is added to any text line, the text will wrap at a width of #pixels. The wrap will be made on the space between words closestto the width specified. This is useful with replaceable parameters orstrings with [[ ]] replacement to make sure that they do not exceedthe right edge of the screen.

EXSYS Professional ADDENDUM - 1

Page 658: Manual Exsys

For example, the text line in a custom screen:

This is a text string with embedded text from [[X]]. -W:300

would be word wrapped at 300 pixels regardless of the final lengthof the string after the value of [X] was inserted.

Custom Screen MetersYou can now easily display the values of variables in customscreens using meters. A horizontal, vertical or dial meter can beadded to a custom screen with a single line in screen command file,or using ExDesign. The meter is associated with an EXSYSvariable and will dynamically display the value.

If the variable is changing in time, such as a system that ismonitoring instrumentation, the meters can be animated. Metersize, shape, scale, and high/low alarm thresholds can be specified.Meters are especially effective when tied to the EXSYS / PIinterface. Process data collected by Oil System, Inc.'s PI (PlantInformation) System can be analyzed by EXSYS and displayedusing EXSYS custom screens.

Meters can also be used to indicate system progress through a largeamount of data or to display results in a very graphical way. TheUPDATE_METERS command in the EXSYS command languagecontrols when the meters are updated.

There are three types of meters:

HorizontalVertical

Dial

100

80

60

40

20

70.1

1.0 1.5 2.0 2.5 3.0 3.5 4.0

2.32

3

4

5

6

7

5.34

EXSYS Professional ADDENDUM - 2

Page 659: Manual Exsys

Syntax:Horizontal Meters:

~METER-H var, rct, "label", scale_min, scale_max, num_incr, alarm_high alarm_low

Vertical Meters:

~METER-V var, rct, "label", scale_min, scale_max, num_incr, alarm_high alarm_low

Dial Meters:

~METER-D var, rct, "label", scale_min, scale_max, num_incr, alarm_high alarm_low

Parameters

varThe name of the EXSYS variable whose value will bedisplayed by the meter. The display of the meter will forceEXSYS to derive a value for the variable. Usually a dataacquisition command would be associated with the variableso that data would be automatically fed into the meter. Thevariable should be in [ ], and not in " ".

rctThe outer rectangle for the meter. This is given as 4 values inthe standard EXSYS syntax for rectangles in custom screen:

top column, top row, width in pixels, height in pixels

labelThis is a label for the meter. If no label is desired, use "". If alabel is specified, make sure that it is small enough to fit onthe meter.

scale_minThe low value for the scale on the meter.

scale_maxThe high value for the scale on the meter.

num_incrThe number of increments on the meter scale. Whenselecting the number of increments remember that theincrements will be labeled, so it is better to select a value thatwill divide the range between scale_min and scale_max intosegments that have easily represented values. For example, if

EXSYS Professional ADDENDUM - 3

Page 660: Manual Exsys

scale_min = 0 and scale_max=1, choosing num_incr=3 willresult in repeating decimals: .3333333.. and .666666...Choosing num_incr=4 would be better to get .25, .5 and .75.If it is necessary to chose num_incr that result in repeatingdecimals, use the /S#.# option to make the display fit on themeter.

alarm_highThe threshold value where the alarm color is set. Inhorizontal or vertical meters, values over this alarm thresholdwill change the bar color from blue to red. In dial meters thealarm range is displayed as a red "pie" section on the dial.The alarm threshold does not actually send any alarm - it justchanges the display color. If no high alarm is desired, set thealarm_high to be a value above the maximum possible value.

alarm_lowThe threshold value where the alarm color is set. Inhorizontal or vertical meters, values less than this alarmthreshold will change the bar color from blue to red. In dialmeters the alarm range is displayed as a red "pie" section onthe dial. The alarm threshold does not actually send anyalarm - it just changes the display color. If no low alarm isdesired, set the alarm_low to be a value below the minimumpossible value.

Example:

~METER-V [Z], 120, 95, 85, 180, "TEMP", -1, 1, 8, .8, -.4

will draw a vertical meter displaying the value of EXSYS variable[Z]. The meter will have the upper left corner at coordinates 120, 95.It will be 85 pixels wide and 180 pixel high. The label will be TEMP.The scale will go from -1 to 1 divided into 8 equal segments. A highalarm threshold is set for .8 and a low alarm threshold is set for -.4

Options/AC:color Alarm bar color.

The default alarm bar color is red. Using /AC: color allowsthe color to be changed. The color can be:

REDGREENBLUECYANMAGENTAYELLOWBLACKDKGRAYGRAYLTGRAYWHITE

For example: /AC:BLACK changes the alarm bar color to black.

EXSYS Professional ADDENDUM - 4

Page 661: Manual Exsys

/MC:color Bar color.The default meter bar color is blue. This can be changed toany of the colors listed above in /AC. This command has noeffect on dial meters which have no bar.

/NS Do not add a scale.The meter is displayed, but no scale is added. The valuedisplayed at the bottom of the meter is still displayed.

/V#.# Value Precision.The size and precision of the value displayed at the bottom ofthe meter can be controlled with /Va.b. The a value is thetotal number of digit to use. The b value is the number ofdigits to display right of the decimal point. For example, ifthe value should be displayed to only 2 digits right of thedecimal point using /V4.2.

/S#.# Scale Precision.This is the same as the /V option, but applies to the labels onthe scale of the meter.

Updating Meters - UPDATE_METERSCommandThe meter will be initially drawn with the current value of themetered variable. The updating of the meters is controlled with theUPDATE_METERS command in the EXSYS Command Language.The meters will NOT update until this command is encountered. AnUPDATE_METERS will update the meters on ALL displayedscreens - even screens called through hypertext.

The usual technique is to display a meter screen with a "DISPLAYfile /C /N" command. The /C causes the screen to be interpreted asa custom screen language file. The /N causes the screen to bedisplayed, but to have EXSYS processing continue. (Without the/N, EXSYS will wait for the screen to be closed, which is not whatwe want.)

When the screen is displayed, the meters will show the currentvalues of their associated variables. Then use a WHILE loop toprocess the data, clear the variables and read in new data for thevariables. Then call the UPDATE_METERS command to redrawthe meters with the new values.

For example, the following is a simple command file to display andupdate meters.

DISPLAY(meter.scr /C /N)WHILE ([X] > 200) CLEAR(ALL) UPDATE_METERS RULES ALLWEND

EXSYS Professional ADDENDUM - 5

Page 662: Manual Exsys

The first line, displays the screen with the meters. In this case weassume that the meter variables are set to automatically get valuesthrough data acquisition commands. The WHILE loop willcontinue until [X] > 200. Each time through the WHILE loop, theUPDATE_METERS command is encountered and the meters on alldisplayed screens will be updated with new data. The rules are runto analyze the values and possibly warn of some developingproblem, etc.

List Boxes, Buttons and EditsEXSYS Custom Screens now support list boxes, list buttons and listedits. A list box is a rectangle that lists multiple items that can beselected. If there are too many to fit in the box, a scroll bar allowsyou to move around in the list. List boxes are ideal when you wantyour user to select one, or more, items out of a defined list. The"list" to put in the list box can be defined in the custom screencommands, come from a file or be the list of values for a specificqualifier. The list box can either return the value selected, or thenumber of the value. The data can be returned to a qualifier orvariable. Single, multiple choice or "read only" lists can be created.

In addition to the standard list box, EXSYS also supports "listbuttons" and "list edits". A list button is like a list box, but takes upless space. Only the selected item is displayed, but when you clickon it the full list drops down for you to select from. A "list edit" issimilar in that only a single item is display and the full list dropsdown, but the end user can also type directly into an edit region toenter values not it the list. A single screen can have up to 50 listboxes, buttons and edits.

Syntax:~LIST "ret prefix" rct options

"ret prefix"The string to precede the return data. Usually "Q#" or[variable] to identify the qualifier or variable. If theQ"name" form is preferred, replace the " with '. For example,to return data to the qualifier named "COLOR", we woulduse:

~LIST "Q 'COLOR'" rct

The text of the list item(s) selected will be preceded by the"ret prefix" string and must make a valid EXSYS dataassignment statement. The default is to return the actualstring selected. For qualifiers, it is usually better to return thenumber of the item selected. This is done by using the -Noption.

EXSYS Professional ADDENDUM - 6

Page 663: Manual Exsys

rctThe rectangle for the list specified as an EXSYS rectangle.The rectangle will specify the size and position of the list box.This is given as 4 values in the standard EXSYS syntax forrectangles in custom screen:

top column, top row, width in pixels, height in pixels

If the -E or -B options are used, only a small edit region orbutton will be displayed. The width will be the width specified,but the height will be only about 20-30 pixels (depending onoperating system). The position will be determined by the upperleft corner. When the list is "pulled down" by the arrow, the listdisplayed will be the full size specified by the rct.

Options:

Control Types:

The default is to make a list box. This can be changed to two otherforms of lists.

-B Make the list a LIST BUTTON. Only a button will bedisplayed with an arrow next to it. A click on the arrowdisplays the full list to make a selection. The currentselection is displayed on the button.

-E Make the list as LIST EDIT. List edits a similar to listbuttons, but the displayed value can be directly changed bytyping into it.

Putting Data in the List:

Data can be added to the list several ways.

Note: because the list text display iscontrolled by the operating systems andnot directly controlled by EXSYS,hypertext can NOT be used in theelements in the list.

-L List of data follows.Read all following lines of text into the list until a ~LISTENDis encountered. If this option is used, list the strings to add tothe list immediately after the ~LIST command, one item per

EXSYS Professional ADDENDUM - 7

Page 664: Manual Exsys

line. After the last line, add ~LISTEND. All lines will beadded to the list. For example,

~LIST "Q 1", 100, 50, 150, 200 -LRedBlueGreenWhite~LISTEND

will create a list box and put the values Red, Blue, Green andWhite in it.

-F:fileRead contents of the text file into the list. The file shouldhave one item per line.

For example:

~LIST "Q 1", 100, 50, 150, 200 -F:colors.dat

will create a list box and add the contents of the file "colors.dat"into the list.

-Q# Add the list of possible values from qualifier # to the list. Thelist of the values for the qualifier are the values defined whenbuilding the expert system. This is useful for templatescreens or when parameter replacement is desired.

If there is no # specified, the qualifier associated with thescreen will be used. For a ~~Q_DEFAULT screen, use only-Q. If the screen is associated with a specific qualifier, onlythe -Q is needed. If the qualifier is not indicted by the screenname, or if there are multiple list boxes from differentqualifiers, use the -Q# form.

The values will be added one per line, so make sure that thelist is wide enough to hold the longest value text.

For example:

~LIST "Q 1", 100, 50, 150, 200 -Q1

will create a list box and add the values associated withqualifier 1 into the list.

EXSYS Professional ADDENDUM - 8

Page 665: Manual Exsys

Other Options:

-N Return the number of the element selected.

The usual default is to return the text of the item(s) selected.The -N option should be used for lists associated withqualifiers. Lists associated with variables will usually returnthe actual string selected from the list. For example:

~LIST "Q 1 " 100, 75, 200, 180 -F:zzz.dat -N

would create a list box and put the values from file zzz.dat init. The return string would be "Q 1 " followed by the numberof the value selected.

NOTE: If either the return prefix string starts with'Q' or the -Q option is used, EXSYS will assumethat the number of the item should be returned andwill automatically add the -N. In these cases the -Nis not really needed.

-S Return the string value. This is normally the default, howeverif either the return prefix string starts with 'Q' or the -Q optionis used, EXSYS will assume that the number of the itemshould be returned. To override this, use the -S (This shouldrarely be needed.)

-R Make the list box READONLY. This can be used fordisplaying data that is to be read but not selected by the enduser. This option can not be use with the -E or -B options.

-I Return Immediately on Double Click (-I)By default EXSYS will not return from a list box until abutton or mouse region with a Return Immediate flag set isclicked. In some cases where a screen has a single list box, itis convenient to have a double click on a list box item indicatethat the data should be processed immediately, withoutclicking on an OK button. This option applies only to listboxes and not list button or list edits.

-M Allow multiple selections. The default in list boxes is toallow only one item to be selected. The -M allows multipleitems to be selected. If the -M# form is used, EXSYS willallow multiple items to be selected, but will check that notmore than # have been selected. This option can not be usedwith the -B and -E options.

-G Some item in the list MUST be selected. If nothing isselected, EXSYS will display an error message and requirethe user to select something.

-X Do not return data for the item. This is usually only usedwith the -R option.

EXSYS Professional ADDENDUM - 9

Page 666: Manual Exsys

-D Set starting selected value.The default is for EXSYS to make the first item in the list thestarting selected value. This can be changed. The commandhas several forms:

-D Do not select any item at startup.

-D# Make item # in the list the starting selectedvalue.

-D"string" For List Edits (-E option) the string in the edit box is set to string. This form applies only whenthe -E option is used.

New Button Options

-G Applies to radio buttons only. Can be put on anybutton in the group. Requires that a selection be made from this group.

-N<id>,<id>... Selection of this button requires that text be entered in the edit fields specified by <id>.

-J<type><id>,<type><id>...Selection of this button enables items specified by <type><id>.

-K<type><id>,<type><id>...Selection of this button disables items specified by <type><id>.

-Y Brings this button up inactive. It must then be enabled by another button with a J option.

-LABEL:"string"String is the label used to refer to this button in

Enable and Disable commands.

<type>: B,E,M, or S for Button, Edit, Mouse, or Scroll Region.

<id>: Number or Label of another item. Number is theposition of the item of that particular type in the custom screen definition. Label is the string defined by the LABEL:"string" option on anotheritem. Double quotes must be used.

For example: -JM"abc" on a selected button will enable themouse region that has the label "abc". -JM2 will enable the

same mouse region if it is the second mouse region defined in the custom screen.

EXSYS Professional ADDENDUM - 10

Page 667: Manual Exsys

New Edit Field Options

-TI The value entered must be an integer.

-TN The value entered must be numeric; either floating or integer type.

-CX# The string entered must be no more than # characters long.

-CM# The string entered must be at least # characters long.

-VX# An atof() of the string must return a value no more than #.

-VM# An atof() of the string must return a value of at least #.

-G A value must be entered into the edit box.

-Y Brings this edit field up inactive. It must then be enabled by another button with a J option.

-LABEL:"string"String is the label used to refer to this Edit Field in Enable and Disable commands.

New Mouse Region Option

-LABEL:"string" String is the label used to refer to this Mouse

Region in Enable and Disable commands.

Image CommandEXSYS Professional for MS-Windows can display graphic imagesin the .PCX format. This is done through the Custom Screencommand ~IMAGE. The format of this command is:

~IMAGE "filename.PCX" rct -V# -H#

where the filename is in double quotes and rct is the usual X,Y,Width and Height coordinates. Since the PCX image is not resizedto fit the rectangle, only that portion (starting at the upper left cornerof the image) that fits inside is displayed. You can use the -V# andH# switches, where # is the number of pixels, to offset the PCXimage within the rectangle.

EXSYS Professional ADDENDUM - 11

Page 668: Manual Exsys

This command can be used in a custom screen specification (.SCRfile) for a variable or qualifier input screen. It can also be used in acustom screen file (other than the .SCR file) that can be displayedwith the DISPLAY command in the command file, report generator,or the THEN part of a rule. The DISPLAY command has thefollowing format:

DISPLAY(filename -C -R -N)

where filename is the name of the custom screen file you createdwith a text editor or the report generator. The options are asfollows:

-C Indicates that the file is in custom screen format.-R Allows data to be returned to EXSYS from a custom

screen file.-N EXSYS continues processing without waiting for the

displayed file to close.

Note: When using the MS-Windows Paint programto create a PCX image, you must first save it as a.BMP file then reopen it and save it as a .PCX image.This insures that the palette is stored in the image file.

2. "Close File" Menu Option Active

Previously, to go from running or editing one knowledge base toanother, you had to exit EXSYS and then start another session.Now, you can just close one knowledge base and start anotherwithout exiting EXSYS. When CLOSE is selected, all activeEXSYS windows will close. For a second or two, the screen willrapidly flash a few times while EXSYS is clearing out the old data.Once the flashing has stopped, you may open a new system. Do notattempt to open a new system until the previous system has beencompletely closed.

3. Resizeable Edit WindowsThe EXSYS Rule Editing window can now be resized. If you areworking on a workstation or higher than VGA resolution monitor,you can now increase the size of the edit window to fit more on thescreen at a single time.

EXSYS Professional ADDENDUM - 12

Page 669: Manual Exsys

4. Note_OnlyWhen an application is delivered to end users, sometimes it isdesirable to allow the user ask for some explanation about a rule, butnot see the actual rule. The "NOTE_ONLY" configuration optionenables this to be easily implemented. When the end user asks tosee the rule through "why" or "how", only the note associated withthe rule is displayed. The note can provide a readable textexplanation of what the rule means. End users do not need to learnEXSYS rule syntax. They receive an easily readable explanation ofeven complex rules. Also, since the note can contain replaceablevariable and qualifier values, the note can reflect the actual dataused during the run. Hypertext can also be included in the note toassist users in the terminology.

Add the NOTE_ONLY configuration option to the application's.CFG file or on the command line. For each rule that might bedisplayed, add a complete explanation in the NOTE field for therule. The note can contain hypertext and [[ ]] expressions to explainthe rule.

5. Hypertext in ReferencesHypertext can now be used in the reference associated with a rule.Previously the reference was displayed in a dialog box and hypertextwas not supported. Now the reference is displayed in a true window.The hypertext in the reference can be associated to other documentsthat display additional information on the source of the rule.

6. Concatenate filesOne expert system technique that can be used to build documents isto have the rules select predefined paragraphs (files) andconcatenate them together. This is very useful for building manytypes of documents. In many operating system, the concatenationcould be done by running a operating system command toconcatenate the files as an EXSYS external program. This was notthe most efficient technique, and was not possible at all on theMacintosh. A new CONCAT function enables you to easilyconcatenate files using only EXSYS internal commands.

The CONCAT command is an EXSYS internal command. Thesyntax is :

CONCAT(file1, file2)

The contents of file 2 will be added at the end of file 1.

EXSYS Professional ADDENDUM - 13

Page 670: Manual Exsys

7. Copy Notes and ReferencesWhen adding the note or reference part of a rule, it is now possibleto copy the text of the note or reference from another rule. From thedialog box where the note / reference is entered, click on Copy.Enter the number of the rule to copy the note / reference from.

8. ODBC InterfaceCurrent Databases Supported:

ALLBASE INGRESBetrieve InterBaseClipper Microsoft SQL ServerDatabase Manager NetWare SQLDB2 OracleDB2/2 ParadoxDB2/6000 PROGRESSdBase II, III, IV,V SQLBaseExcel 5.0 SQL/400Excel .XLS files SQL/DSFoxBase Sybase SQL ServerFoxPro Sybase System 10Gupta SQLBase TeradataIMAGE/SQL Text filesINFORMIX XDB

Installation

Copy all .DLL files from the EXSYS Professional v5.0 diskettes tothe \WINDOWS\SYSTEM directory.

Install the Q+E ODBC Pack software according to themanufacturer's instructions.

To Define a Data Source:

Click on the ODBC icon in the WINDOWS Control Panel.Under DATA SOURCES, choose ADD.Under ADD DATA SOURCE, select database type.Under ODBC <database type> DRIVER SETUP:

Enter <database type source name>* in DATA SOURCE NAME.Enter a working directory, if known.Enter other information as appropriate.CLOSE/EXIT all the way out.

* Database type source names are in the READ.ME on yourdistribution disks.

EXSYS Professional ADDENDUM - 14

Page 671: Manual Exsys

DLL Distribution:

The ODBC DLLs distributed with EXSYS Professional v5.0 are:

ODBC.DLL QEGUIxx.DLL QEQRYxx.DLLQEMDSxx.DLL QESQLxx.DLL QEUTLxx.DLLQELIB.DLL

** xx might be 03 or 06 depending on your software revision.

All other general DLLs you use will be distributed with your Q+EODBC Pack. These DLLs will be looking for the particular DLL ofyour database (shipped with your database software). For example,the file PXENGWIN.DLL is shipped with PARADOX. In order toaccess your PARADOX files, this DLL must be present in eitheryour working directory or in \WINDOWS\SYSTEM.

You can purchase the ODBC drivers individually from yourdatabase vendor. Alternately, you can order the entire set, orindividual drivers (per seat) from the following vendor:

INTERSOLV5540 Centerview Drive, Suite 324Raleigh, NC 27606(919) 859.2220

9. Running Version 4.0 Systems under Version 5.0If you have properly installed your Q+E ODBC Pack and EXSYSDLLs, your previous system should run without modification.

Possible errors are:

Application Error: Call to Undefined Data Link

This occurs if your old QELIB.DLL file (from EXSYS ProfessionalV4.0) is being accessed instead of the newer one. Insure that thelatest QELIB.DLL is in \WINDOWS\SYSTEM.

[Microsoft][ODBC DLL] Data source not found and no defaultdriver specified

This can occur if you are trying to open a database that you haven'tsetup a Data Source for. Review the installation instructions abovefor setting up a Data Source.

EXSYS Professional ADDENDUM - 15

Page 672: Manual Exsys

10. New Configure OptionsThe following configuration commands can be used in theEXSYS.CFG, EDITXSP.CFG, <KBNAME>.CFG or commandline.

Note: Some can only be used on the command line.

MAXIMIZEStart the Runtime in a maximized window. Must be called fromcommand line (NOT .cfg). Only applies to Runtime.

SCREEN_TITLE=xxxxxMakes the title for the main windows xxxxx.

NOTEBOOK_OFFDisables the notebook function and button in applicable windows.

HOW_OFFNow disables both display of data and the HOW button on theResults window.

ICONIZERuntime Only - starts Runtime as an icon and runs. Automaticallysets NO_TITLE. Should be used with an expert system filename,and end with EXIT. Must be called from command line (NOT .cfg).Only applies to Runtime.

NO_OUTPUTStarts Runtime as a small window in upper left. System setsNO_TITLE. Should be used with an expert system filename, andend with EXIT. Must be called from command line (NOT .cfg).Only applies to Runtime.

SQL_TRACEUse with TRACE=... option. Turns on extra tracing of SQLcommands.

SUPPRESS_UPDATE_CHECKSets XVT flag to not check certain actions on an UPDATE event -use with care.

11. EVAL( ) CommandProfessional now supports the EVAL() option as a Data Acquisitioncommand for variables and qualifiers. This allows a variable orqualifier to get its value based on a formula, possibly involving othervariables. Simply type EVAL(formula) in the edit box at the top of

EXSYS Professional ADDENDUM - 16

Page 673: Manual Exsys

the Data Acquisition dialog box. For example, the variable [X]could have the function EVAL( [Z] / 2) associated with it. Thiswould set [X] to the value [Z]/2.

12. DISPLAY Command OptionsNew option to DISPLAY command options allow the point size tobe set:

/P# sets point size to #

If used with /S, type is TIMES If used with /F, type is FIXED If used with /N, type is HELVETICA Default is HELVETICA

13. New Report Generator CommandsMESSAGE Displays all messages set in RuleBook. (Also

works in EXSYS Professional to display all text only varibles.)

V /M Display all text only varibles. (In RuleBook, display all messages set.)

C/Q/V /A"xxx" Put xxx after each choice, qualifier or variable printed. Use with /S to make list of items on oneline. /A", " /S makes comma delimited text file.

C/Q/V /A123 Put ASCII character 123 after each choice, qualifier or variable printed. Use with /S to makelist of items on one line.

NOTE /W:# Wraps text at column #.

EXSYS Professional ADDENDUM - 17

Page 674: Manual Exsys

14. System Requirements386SX or better PC compatable running MS-Windows v3.1 in386 enhanced mode. It will start in standard mode but at times itwill not work properly.

An XT and a 286 will not work since you have to run in 386 mode.To force it to use 386 enhanced mode, use the command: win /3 tocall MS-Windows.

2 MB of extended RAM memory (minimum); 4 MB of extendedRAM (recommended). The more memory you have, the faster MS-Windows and EXSYS will run. With a 386-16MHz, an older harddrive, no dedicated swap file, and 2MB memory, the average delayin redrawing windows is approx. 1.5 seconds. A dedicated swap fileis recommended. See your MS-Windows manual for instructions onhow to create one. This will make MS-Windows run faster.

4 MB of Hard Disk space free. EXSYS uses about 1 MB of thisfor the program. Utilities and .dll files can take an additional 2 MB.Allow at least 1 MB for for your expert system files.

VGA graphics or better. EGA graphics will not show the bottomsof the screens. Therefore, you cannot resize the screen since youcannot click-and-drag the bottom of the screen up.

If you have any questions, please call technical support at:(505)256-8356,fax: (505)256-8359, Email: [email protected] write to:

EXSYS Inc.1720 Louisiana Blvd. NESuite 312Albuquerque, NM 87110 USA

EXSYS Professional ADDENDUM - 18