⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 insmult.c

📁 NASA 开发使用的一个专家系统
💻 C
📖 第 1 页 / 共 2 页
字号:
   /*******************************************************/   /*      "C" Language Integrated Production System      */   /*                                                     */   /*              CLIPS Version 6.05  04/09/97           */   /*                                                     */   /*           INSTANCE MULTIFIELD SLOT MODULE           */   /*******************************************************//*************************************************************//* Purpose:  Access routines for Instance Multifield Slots   *//*                                                           *//* Principal Programmer(s):                                  *//*      Brian L. Donnell                                     *//*                                                           *//* Contributing Programmer(s):                               *//*                                                           *//* Revision History:                                         *//*                                                           *//*************************************************************/   /* =========================================   *****************************************               EXTERNAL DEFINITIONS   =========================================   ***************************************** */#include "setup.h"#if OBJECT_SYSTEM#include "argacces.h"#include "extnfunc.h"#include "insfun.h"#include "msgfun.h"#include "msgpass.h"#include "multifun.h"#include "router.h"#define _INSMULT_SOURCE_#include "insmult.h"/* =========================================   *****************************************                   CONSTANTS   =========================================   ***************************************** */#define INSERT         0#define REPLACE        1#define DELETE         2/* =========================================   *****************************************      INTERNALLY VISIBLE FUNCTION HEADERS   =========================================   ***************************************** */#if ANSI_COMPILERstatic INSTANCE_TYPE *CheckMultifieldSlotInstance(char *);static INSTANCE_SLOT *CheckMultifieldSlotModify(int,char *,INSTANCE_TYPE *,                                       EXPRESSION *,int *,int *,DATA_OBJECT *);static VOID AssignSlotToDataObject(DATA_OBJECT *,INSTANCE_SLOT *);#elsestatic INSTANCE_TYPE *CheckMultifieldSlotInstance();static INSTANCE_SLOT *CheckMultifieldSlotModify();static VOID AssignSlotToDataObject();#endif/* =========================================   *****************************************       EXTERNALLY VISIBLE GLOBAL VARIABLES   =========================================   ***************************************** *//* =========================================   *****************************************          EXTERNALLY VISIBLE FUNCTIONS   =========================================   ***************************************** */#if (! RUN_TIME)/***************************************************  NAME         : SetupInstanceMultifieldCommands  DESCRIPTION  : Defines function interfaces for                 manipulating instance multislots  INPUTS       : None  RETURNS      : Nothing useful  SIDE EFFECTS : Functions defined to CLIPS  NOTES        : None ***************************************************/globle VOID SetupInstanceMultifieldCommands()  {   /* ===================================      Old version 5.1 compatibility names      =================================== */   DefineFunction2("direct-mv-replace",'b',PTIF DirectMVReplaceCommand,                   "DirectMVReplaceCommand","4**wii");   DefineFunction2("direct-mv-insert",'b',PTIF DirectMVInsertCommand,                   "DirectMVInsertCommand","3**wi");   DefineFunction2("direct-mv-delete",'b',PTIF DirectMVDeleteCommand,                   "DirectMVDeleteCommand","33iw");   DefineFunction2("mv-slot-replace",'u',PTIF MVSlotReplaceCommand,                   "MVSlotReplaceCommand","5*uewii");   DefineFunction2("mv-slot-insert",'u',PTIF MVSlotInsertCommand,                   "MVSlotInsertCommand","4*uewi");   DefineFunction2("mv-slot-delete",'u',PTIF MVSlotDeleteCommand,                   "MVSlotDeleteCommand","44iew");   /* =====================      New version 6.0 names      ===================== */   DefineFunction2("slot-direct-replace$",'b',PTIF DirectMVReplaceCommand,                   "DirectMVReplaceCommand","4**wii");   DefineFunction2("slot-direct-insert$",'b',PTIF DirectMVInsertCommand,                   "DirectMVInsertCommand","3**wi");   DefineFunction2("slot-direct-delete$",'b',PTIF DirectMVDeleteCommand,                   "DirectMVDeleteCommand","33iw");   DefineFunction2("slot-replace$",'u',PTIF MVSlotReplaceCommand,                   "MVSlotReplaceCommand","5*uewii");   DefineFunction2("slot-insert$",'u',PTIF MVSlotInsertCommand,                   "MVSlotInsertCommand","4*uewi");   DefineFunction2("slot-delete$",'u',PTIF MVSlotDeleteCommand,                   "MVSlotDeleteCommand","44iew");  }#endif/***********************************************************************************  NAME         : MVSlotReplaceCommand  DESCRIPTION  : Allows user to replace a specified field of a multi-value slot                 The slot is directly read (w/o a get- message) and the new                   slot-value is placed via a put- message.                 This function is not valid for single-value slots.  INPUTS       : Caller's result buffer  RETURNS      : CLIPS_TRUE if multi-value slot successfully modified,                 CLIPS_FALSE otherwise  SIDE EFFECTS : Put messsage sent for slot  NOTES        : CLIPS Syntax : (slot-replace$ <instance> <slot>                                  <range-begin> <range-end> <value>) ***********************************************************************************/globle VOID MVSlotReplaceCommand(result)  DATA_OBJECT *result;  {   DATA_OBJECT newval,newseg,oldseg;   INSTANCE_TYPE *ins;   INSTANCE_SLOT *sp;   int rb,re;   EXPRESSION arg;      result->type = SYMBOL;   result->value = CLIPSFalseSymbol;   ins = CheckMultifieldSlotInstance("slot-replace$");   if (ins == NULL)     return;   sp = CheckMultifieldSlotModify(REPLACE,"slot-replace$",ins,                            GetFirstArgument()->nextArg,&rb,&re,&newval);   if (sp == NULL)     return;   AssignSlotToDataObject(&oldseg,sp);   if (ReplaceMultiValueField(&newseg,&oldseg,rb,re,&newval,"slot-replace$") == CLIPS_FALSE)     return;   arg.type = MULTIFIELD;   arg.value = (VOID *) &newseg;   arg.nextArg = NULL;   arg.argList = NULL;   DirectMessage(sp->desc->overrideMessage,ins,result,&arg);  }  /***********************************************************************************  NAME         : MVSlotInsertCommand  DESCRIPTION  : Allows user to insert a specified field of a multi-value slot                 The slot is directly read (w/o a get- message) and the new                   slot-value is placed via a put- message.                 This function is not valid for single-value slots.  INPUTS       : Caller's result buffer  RETURNS      : CLIPS_TRUE if multi-value slot successfully modified, CLIPS_FALSE otherwise  SIDE EFFECTS : Put messsage sent for slot  NOTES        : CLIPS Syntax : (slot-insert$ <instance> <slot> <index> <value>) ***********************************************************************************/globle VOID MVSlotInsertCommand(result)  DATA_OBJECT *result;  {   DATA_OBJECT newval,newseg,oldseg;   INSTANCE_TYPE *ins;   INSTANCE_SLOT *sp;   int index;   EXPRESSION arg;      result->type = SYMBOL;   result->value = CLIPSFalseSymbol;   ins = CheckMultifieldSlotInstance("slot-insert$");   if (ins == NULL)     return;   sp = CheckMultifieldSlotModify(INSERT,"slot-insert$",ins,                            GetFirstArgument()->nextArg,&index,NULL,&newval);   if (sp == NULL)     return;   AssignSlotToDataObject(&oldseg,sp);   if (InsertMultiValueField(&newseg,&oldseg,index,&newval,"slot-insert$") == CLIPS_FALSE)     return;   arg.type = MULTIFIELD;   arg.value = (VOID *) &newseg;   arg.nextArg = NULL;   arg.argList = NULL;   DirectMessage(sp->desc->overrideMessage,ins,result,&arg);  }  /***********************************************************************************  NAME         : MVSlotDeleteCommand  DESCRIPTION  : Allows user to delete a specified field of a multi-value slot                 The slot is directly read (w/o a get- message) and the new                   slot-value is placed via a put- message.                 This function is not valid for single-value slots.  INPUTS       : Caller's result buffer  RETURNS      : CLIPS_TRUE if multi-value slot successfully modified, CLIPS_FALSE otherwise  SIDE EFFECTS : Put message sent for slot  NOTES        : CLIPS Syntax : (slot-delete$ <instance> <slot>                                 <range-begin> <range-end>) ***********************************************************************************/globle VOID MVSlotDeleteCommand(result)  DATA_OBJECT *result;  {   DATA_OBJECT newseg,oldseg;   INSTANCE_TYPE *ins;   INSTANCE_SLOT *sp;   int rb,re;   EXPRESSION arg;      result->type = SYMBOL;   result->value = CLIPSFalseSymbol;   ins = CheckMultifieldSlotInstance("slot-delete$");   if (ins == NULL)     return;   sp = CheckMultifieldSlotModify(DELETE,"slot-delete$",ins,                            GetFirstArgument()->nextArg,&rb,&re,NULL);   if (sp == NULL)     return;   AssignSlotToDataObject(&oldseg,sp);   if (DeleteMultiValueField(&newseg,&oldseg,rb,re,"slot-delete$") == CLIPS_FALSE)     return;   arg.type = MULTIFIELD;   arg.value = (VOID *) &newseg;   arg.nextArg = NULL;   arg.argList = NULL;   DirectMessage(sp->desc->overrideMessage,ins,result,&arg);  }  /*****************************************************************  NAME         : DirectMVReplaceCommand  DESCRIPTION  : Directly replaces a slot's value  INPUTS       : None  RETURNS      : CLIPS_TRUE if put OK, CLIPS_FALSE otherwise  SIDE EFFECTS : Slot modified  NOTES        : CLIPS Syntax: (direct-slot-replace$ <slot>                                 <range-begin> <range-end> <value>) *****************************************************************/globle BOOLEAN DirectMVReplaceCommand()  {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -