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

📄 insmult.c

📁 clips源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
   /*******************************************************/   /*      "C" Language Integrated Production System      */   /*                                                     */   /*              CLIPS Version 6.24  06/05/06           */   /*                                                     */   /*           INSTANCE MULTIFIELD SLOT MODULE           */   /*******************************************************//*************************************************************//* Purpose:  Access routines for Instance Multifield Slots   *//*                                                           *//* Principal Programmer(s):                                  *//*      Brian L. Donnell                                     *//*                                                           *//* Contributing Programmer(s):                               *//*                                                           *//* Revision History:                                         *//*      6.23: Correction for FalseSymbol/TrueSymbol. DR0859  *//*                                                           *//*      6.24: Renamed BOOLEAN macro type to intBool.         *//*                                                           *//*************************************************************//* =========================================   *****************************************               EXTERNAL DEFINITIONS   =========================================   ***************************************** */#include "setup.h"#if OBJECT_SYSTEM#include "argacces.h"#include "envrnmnt.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_OP      2/* =========================================   *****************************************      INTERNALLY VISIBLE FUNCTION HEADERS   =========================================   ***************************************** */static INSTANCE_TYPE *CheckMultifieldSlotInstance(void *,char *);static INSTANCE_SLOT *CheckMultifieldSlotModify(void *,int,char *,INSTANCE_TYPE *,                                       EXPRESSION *,long *,long *,DATA_OBJECT *);static void AssignSlotToDataObject(DATA_OBJECT *,INSTANCE_SLOT *);/* =========================================   *****************************************          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 KB  NOTES        : None ***************************************************/globle void SetupInstanceMultifieldCommands(  void *theEnv)  {   /* ===================================      Old version 5.1 compatibility names      =================================== */   EnvDefineFunction2(theEnv,"direct-mv-replace",'b',PTIEF DirectMVReplaceCommand,                   "DirectMVReplaceCommand","4**wii");   EnvDefineFunction2(theEnv,"direct-mv-insert",'b',PTIEF DirectMVInsertCommand,                   "DirectMVInsertCommand","3**wi");   EnvDefineFunction2(theEnv,"direct-mv-delete",'b',PTIEF DirectMVDeleteCommand,                   "DirectMVDeleteCommand","33iw");   EnvDefineFunction2(theEnv,"mv-slot-replace",'u',PTIEF MVSlotReplaceCommand,                   "MVSlotReplaceCommand","5*uewii");   EnvDefineFunction2(theEnv,"mv-slot-insert",'u',PTIEF MVSlotInsertCommand,                   "MVSlotInsertCommand","4*uewi");   EnvDefineFunction2(theEnv,"mv-slot-delete",'u',PTIEF MVSlotDeleteCommand,                   "MVSlotDeleteCommand","44iew");   /* =====================      New version 6.0 names      ===================== */   EnvDefineFunction2(theEnv,"slot-direct-replace$",'b',PTIEF DirectMVReplaceCommand,                   "DirectMVReplaceCommand","4**wii");   EnvDefineFunction2(theEnv,"slot-direct-insert$",'b',PTIEF DirectMVInsertCommand,                   "DirectMVInsertCommand","3**wi");   EnvDefineFunction2(theEnv,"slot-direct-delete$",'b',PTIEF DirectMVDeleteCommand,                   "DirectMVDeleteCommand","33iw");   EnvDefineFunction2(theEnv,"slot-replace$",'u',PTIEF MVSlotReplaceCommand,                   "MVSlotReplaceCommand","5*uewii");   EnvDefineFunction2(theEnv,"slot-insert$",'u',PTIEF MVSlotInsertCommand,                   "MVSlotInsertCommand","4*uewi");   EnvDefineFunction2(theEnv,"slot-delete$",'u',PTIEF 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      : TRUE if multi-value slot successfully modified,                 FALSE otherwise  SIDE EFFECTS : Put messsage sent for slot  NOTES        : H/L Syntax : (slot-replace$ <instance> <slot>                                 <range-begin> <range-end> <value>) ***********************************************************************************/globle void MVSlotReplaceCommand(  void *theEnv,  DATA_OBJECT *result)  {   DATA_OBJECT newval,newseg,oldseg;   INSTANCE_TYPE *ins;   INSTANCE_SLOT *sp;   long rb,re;   EXPRESSION arg;   result->type = SYMBOL;   result->value = EnvFalseSymbol(theEnv);   ins = CheckMultifieldSlotInstance(theEnv,"slot-replace$");   if (ins == NULL)     return;   sp = CheckMultifieldSlotModify(theEnv,REPLACE,"slot-replace$",ins,                            GetFirstArgument()->nextArg,&rb,&re,&newval);   if (sp == NULL)     return;   AssignSlotToDataObject(&oldseg,sp);   if (ReplaceMultiValueField(theEnv,&newseg,&oldseg,rb,re,&newval,"slot-replace$") == FALSE)     return;   arg.type = MULTIFIELD;   arg.value = (void *) &newseg;   arg.nextArg = NULL;   arg.argList = NULL;   DirectMessage(theEnv,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      : TRUE if multi-value slot successfully modified, FALSE otherwise  SIDE EFFECTS : Put messsage sent for slot  NOTES        : H/L Syntax : (slot-insert$ <instance> <slot> <index> <value>) ***********************************************************************************/globle void MVSlotInsertCommand(  void *theEnv,  DATA_OBJECT *result)  {   DATA_OBJECT newval,newseg,oldseg;   INSTANCE_TYPE *ins;   INSTANCE_SLOT *sp;   long theIndex;   EXPRESSION arg;   result->type = SYMBOL;   result->value = EnvFalseSymbol(theEnv);   ins = CheckMultifieldSlotInstance(theEnv,"slot-insert$");   if (ins == NULL)     return;   sp = CheckMultifieldSlotModify(theEnv,INSERT,"slot-insert$",ins,                            GetFirstArgument()->nextArg,&theIndex,NULL,&newval);   if (sp == NULL)     return;   AssignSlotToDataObject(&oldseg,sp);   if (InsertMultiValueField(theEnv,&newseg,&oldseg,theIndex,&newval,"slot-insert$") == FALSE)     return;   arg.type = MULTIFIELD;   arg.value = (void *) &newseg;   arg.nextArg = NULL;   arg.argList = NULL;   DirectMessage(theEnv,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      : TRUE if multi-value slot successfully modified, FALSE otherwise  SIDE EFFECTS : Put message sent for slot  NOTES        : H/L Syntax : (slot-delete$ <instance> <slot>                                 <range-begin> <range-end>) ***********************************************************************************/globle void MVSlotDeleteCommand(  void *theEnv,  DATA_OBJECT *result)  {   DATA_OBJECT newseg,oldseg;   INSTANCE_TYPE *ins;   INSTANCE_SLOT *sp;   long rb,re;   EXPRESSION arg;   result->type = SYMBOL;   result->value = EnvFalseSymbol(theEnv);   ins = CheckMultifieldSlotInstance(theEnv,"slot-delete$");   if (ins == NULL)     return;   sp = CheckMultifieldSlotModify(theEnv,DELETE_OP,"slot-delete$",ins,                            GetFirstArgument()->nextArg,&rb,&re,NULL);   if (sp == NULL)     return;   AssignSlotToDataObject(&oldseg,sp);   if (DeleteMultiValueField(theEnv,&newseg,&oldseg,rb,re,"slot-delete$") == FALSE)     return;   arg.type = MULTIFIELD;   arg.value = (void *) &newseg;   arg.nextArg = NULL;   arg.argList = NULL;   DirectMessage(theEnv,sp->desc->overrideMessage,ins,result,&arg);  }/*****************************************************************  NAME         : DirectMVReplaceCommand  DESCRIPTION  : Directly replaces a slot's value  INPUTS       : None  RETURNS      : TRUE if put OK, FALSE otherwise  SIDE EFFECTS : Slot modified  NOTES        : H/L Syntax: (direct-slot-replace$ <slot>                                <range-begin> <range-end> <value>) *****************************************************************/globle intBool DirectMVReplaceCommand(  void *theEnv)  {   INSTANCE_SLOT *sp;   INSTANCE_TYPE *ins;   long rb,re;   DATA_OBJECT newval,newseg,oldseg;

⌨️ 快捷键说明

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