home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / KAPA2.ZIP / CLIBUTIL.ZIP / KAPPA.H < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-13  |  112.1 KB  |  2,942 lines

  1. /**************************************************************
  2.                                  kappa.h 
  3. **************************************************************/
  4.  
  5. /******************************************************/
  6. /*     Copyright (c) IntelliCorp 1988,89,90           */
  7. /******************************************************/
  8.  
  9. /**********************************************************************
  10.         Define macros which eliminates loading unsued
  11.         portions of the windows.h file
  12. ***********************************************************************/
  13. #define NOCOMM                          /* no communication */
  14. #define NOKANJI                         /* thanks, but no kanji for now */
  15. #define NOWH                            /* no window hooks */
  16. #define NOSOUND                         /* no sounds for now */
  17. #define NOMINMAX                        /* use our own */
  18.  
  19. #include <windows.h>
  20. #include <stdio.h>
  21.  
  22. /* KAPPA Configuration Paramters */
  23.  
  24. #define INFERENCE
  25. #define EDITORS
  26. #define L123
  27. #define TEXTPRINT
  28. #define DBASE
  29. #define BITMAPWIDGET
  30. #define BROWSER
  31. #define INTERPRETER
  32. #define BINSAVE
  33. #define KALHELP
  34. #define METHODSLIB
  35. #define INPUTFORM
  36. #define SINGLEMENU
  37. #define WRITEKAL
  38. #define TOOLBOX
  39. #define GUIDELINES
  40. #define KALSAVE
  41. #define ABOUTBOX
  42.  
  43. /* #define EMS */
  44.  
  45. #define KERNEL          1
  46. #define DEVELOP         2
  47. /* #define RUNTIME      3 */
  48.  
  49. /* general declarations */
  50. #define KAPERROR -1
  51.  
  52. #define SHORT   short
  53. typedef WORD FAR * LPWORD;
  54. #define LNULL   (LPSTR)0
  55. #define LPNULL  (LPSTR)0
  56. typedef LPSTR FAR *LPLPSTR;
  57.  
  58. #define ITEMID  WORD
  59. #define ATOMID  ITEMID
  60. #define ANYID   ITEMID
  61. #define NULLID  (ITEMID)0
  62. #define LPITEM  LPSTR
  63.  
  64. /* some specific definitions */
  65. #define CSTR    7
  66.  
  67. /***********************************/
  68. /*  Window ID's of KAPPA's Children  */
  69. /***********************************/
  70. #define ID_INTERPRET            1
  71. #define ID_TRACE                2
  72. #define ID_COMMENT              3     /* [mlm]  2/15/90 */
  73.  
  74. /**************************/
  75. /* THE STRING TABLE SIZE  */
  76. /**************************/
  77. #define CCHMAXSTRING 50         /* max chars in strings in the rc file */
  78.  
  79. /******************************/
  80. /*  Return Buffer Size        */
  81. /******************************/
  82. #define RET_BUFFER_LEN  200
  83.  
  84. /******************************/
  85. /* MAX size for Comment Window
  86. /******************************/
  87. #define MAX_COMMENT_SIZE        4000
  88.  
  89. /* Length of name of object and slot */
  90. #define NAME_LEN        32
  91.  
  92. /****************************/
  93. /* IDM... ID for Menus      */
  94. /* IDT... ID for Timers     */
  95. /* IDD... ID for Dialog Box */
  96. /****************************/
  97.  
  98. /***********************/
  99. /* NEXT THE MENU ITEMS */
  100. /***********************/
  101.  
  102. #define IDM_NEW         100     /* File Menu */
  103. #define IDM_OPEN        101
  104. #define IDM_SAVE        102
  105. #define IDM_SAVEAS      103
  106. #define IDM_SETUPPRINT  104
  107. #define IDM_EXIT        105
  108. #define IDM_HELP        106
  109. #define IDM_ABOUT       107
  110. #define IDM_PRINTSCREEN 108
  111. #define IDM_TRPFILE     109
  112. #define IDM_KAL         199
  113. #define IDM_RULEREL     901
  114. #define IDM_WRITEFILE   900
  115.  
  116. #define IDM_UNDO        110     /* Interpreter Text Edit Menu */
  117. #define IDM_CUT         111
  118. #define IDM_COPY        112
  119. #define IDM_PASTE       113
  120. #define IDM_CLEAR       114
  121. #define IDM_RESET       115
  122. #define IDM_EXPLAIN     116
  123.  
  124. #define IDM_START       120     /* Session Menu */
  125. #define IDM_INITWIDGETS 121
  126. #define IDM_MAKEWIDGET  122
  127. #define IDM_DELETEWIDGET 123
  128. #define IDM_CALLFUNC    124
  129.  
  130. #define IDM_TITLEON     125
  131. #define IDM_TITLEOFF    126
  132. #define IDM_BORDERON    127
  133. #define IDM_BORDEROFF   128
  134. #define IDM_PRINT       129
  135.  
  136. #define IDM_ECHO        130     /* Options Menu */
  137. #define IDM_SILENT      131
  138. #define IDM_DEBUG       132
  139.  
  140. /* More Development menu for SESSION */
  141. #define IDM_IMAGE_EDIT   140
  142. #define IDM_IMAGE_RENAME 141
  143. #define IDM_IMAGE_DELETE 142
  144. #define IDM_IMAGE_HIDE   143
  145. #define IDM_IMAGE_SHOWHIDDEN 144
  146.  
  147. #define IDM_BROWSER     150     /* KAPPA Windows menu */
  148. #define IDM_KTOOLS      151
  149. #define IDM_SESSION     152
  150. #define IDM_INFERENCE   153
  151. #define IDM_TRACE       154
  152. #define IDM_COMMENT     155
  153.  
  154. /* Items in KTOOLS window menu */
  155.     /* in addition to IDM_NEW and IDM_COPY defined above */
  156. #define IDM_DELETE      201
  157. #define IDM_EDIT        202
  158. #define IDM_RENAME      203
  159.  
  160. /* Extra Items in Editors */
  161. #define IDM_CHECK       210
  162.  
  163. /* Item in popup menu of browser */
  164. #define IDM_ADDINSTANCE         300
  165. #define IDM_ADDSUBCLASS         301
  166. #define IDM_SHOWINSTANCES       302
  167. #define IDM_SHOWSUBCLASSES      303
  168. #define IDM_FOCUS               304
  169. #define IDM_UNFOCUS             305
  170.  
  171. /* Items in browser window menu */
  172. #define IDM_FIT         400
  173. #define IDM_SCALE       401
  174.  
  175. /* Items in popup menu of Object/Class editor */
  176. #define IDM_NEWSLOT             501
  177. #define IDM_IMPORTSLOT          502
  178. #define IDM_EDITSLOT            503
  179. #define IDM_RENAMESLOT          504
  180. #define IDM_COPYSLOT            505
  181. #define IDM_DELETESLOT          506
  182. #define IDM_MAKELOCALSLOT       507
  183.  
  184. #define IDM_NEWMETHOD           510
  185. #define IDM_IMPORTMETHOD        511
  186. #define IDM_EDITMETHOD          512
  187. #define IDM_RENAMEMETHOD        513
  188. #define IDM_COPYMETHOD          514
  189. #define IDM_DELETEMETHOD        515
  190. #define IDM_MAKELOCALMETHOD     516
  191. #define IDM_MAKELOCAL           517             /* generic command */
  192.  
  193. /* Rule Trace Window Menus */
  194. #define IDM_RULETRACE           520
  195. #define IDM_SLOTTRACE           521
  196. #define IDM_RULEBREAK           522
  197. #define IDM_SLOTBREAK           523
  198.  
  199. #define IDM_BASE              1000     /* Menu IDs */
  200. #define IDM_FILEEXIT          (IDM_BASE + 100)
  201.  
  202. #define IDM_EDITCUT           (IDM_BASE + 200)
  203. #define IDM_EDITCOPY          (IDM_BASE + 201)
  204. #define IDM_EDITPASTE         (IDM_BASE + 202)
  205. #define IDM_EDITCLEAR         (IDM_BASE + 203)
  206. #define IDM_EDITSELECT        (IDM_BASE + 204)
  207.  
  208. #define IDM_WIDGETBUTTON      (IDM_BASE + 300)
  209. #define IDM_WIDGETTEXT        (IDM_BASE + 301)
  210. #define IDM_WIDGETEDIT        (IDM_BASE + 302)
  211. #define IDM_WIDGETTRANSCRIPT  (IDM_BASE + 303)
  212. #define IDM_WIDGETBITMAP      (IDM_BASE + 304)
  213. #define IDM_WIDGETDRAWING     (IDM_BASE + 305)
  214. #define IDM_WIDGETSTATEBOX    (IDM_BASE + 306)
  215. #define IDM_WIDGETMETER       (IDM_BASE + 307)
  216. #define IDM_WIDGETLINEPLOT    (IDM_BASE + 308)
  217. #define IDM_WIDGETSLIDER      (IDM_BASE + 309)  /*Set to IDM_WIDGETCLASSLAST*/
  218.  
  219. #define IDM_WIDGETCUSTOM      (IDM_BASE + 399)
  220.  
  221. #define IDM_WIDGETCLASSFIRST  IDM_WIDGETBUTTON
  222. #define IDM_WIDGETCLASSLAST   IDM_WIDGETSLIDER
  223. #define NONEXTWIDGETCLASS     -1
  224.  
  225. #define IDM_OPTIONSTOOLBOX    (IDM_BASE + 400)
  226. #define IDM_OPTIONSRULER      (IDM_BASE + 401)
  227. #define IDM_OPTIONSGUIDELINES (IDM_BASE + 402)
  228. #define IDM_OPTIONSSTATUSBOX  (IDM_BASE + 403)
  229. #define IDM_OPTIONSGRID       (IDM_BASE + 404)
  230. #define IDM_OPTIONSLAYOUTMODE   (IDM_BASE + 405)
  231.  
  232. /********************************************************/
  233. /* NOTE:                                                */
  234. /*      All menu numbers above IDM_WINDOWS              */
  235. /*      is reserved.  To add any menu item, make sure   */
  236. /*      you assign a number less than IDM_WINDOWS       */
  237. /********************************************************/
  238. #define IDM_WINDOW              5000
  239.  
  240. /***********************************************/
  241. /* FINALLY THE DIALOG BOXES AND THEIR CONTENTS */
  242. /***********************************************/
  243.  
  244.  /* Dialog box resource ids */
  245. #define IDD_ABOUT               1
  246. #define IDD_HELP                2
  247. #define IDD_HELPTOPIC           3
  248. #define IDD_EDITCLASS           11
  249. #define IDD_EDITOBJECT          12
  250. #define IDD_EDITSLOT            13
  251. #define IDD_EDITOPTIONS         14
  252. #define IDD_EDITMETHOD          15
  253. #define IDD_EDITFUNC            16
  254. #define IDD_EDITRULE            17
  255. #define IDD_EDITGOAL            18
  256. #define IDD_NAME                21
  257. #define IDD_NAMECLASS           22
  258. #define IDD_LBOXMENU            31
  259. #define IDD_QBOXDLG             32
  260. #define IDD_QUERYLISTDLG        33
  261. #define IDD_BrOptions           34
  262. #define IDD_CANCELPRINTDLG      35
  263. #define IDD_INPUTFORM           36
  264. #define IDD_EXPLAIN             37
  265. #define IDD_OBJECTSLOT          38
  266. #define IDD_SLOTLEVEL           39
  267. #define IDD_SINGLEMENU          40
  268. #define IDD_MULTILBOXMENU       41
  269. #define IDD_OPENFILE            42
  270. #define IDD_SAVEFILE            43
  271. #define IDD_BUSY                44
  272. #define IDD_LBMENUSELECTION     45
  273. #define IDD_POSTALERT           46
  274. #define IDD_POSTMESSAGE         47
  275. #define IDD_TRACERULE           48
  276. #define IDD_PASTECOMMAND        49
  277. #define IDD_QARGDLG             50
  278. #define IDD_OPENSAVEFILE        51
  279.  
  280.  /* general control definitions */
  281. #define IDNULL          -1
  282. #define IDDNULL         -1
  283.  
  284.  /* controls within Help dialog boxes */
  285. #define IDDTOPICS       1101
  286. #define IDDHELP         1102
  287. #define IDDNEXT         1103
  288. #define IDDPREVIOUS     1104
  289. #define IDDCONTENTS     1105
  290.  
  291.  /* controls within knowledge editors */
  292. #define IDDNAME         1101
  293. #define IDDCLASS        1102
  294. #define IDDVALUE        1103
  295. #define IDDEXPLAIN      1104
  296. #define IDDFIXED        1105
  297. #define IDDMODIFYABLE   1106
  298. #define IDDSLOTS        1121
  299. #define IDDPRIORITY     1122
  300. #define IDDMETHODS      1123
  301. #define IDDOPTIONS      1125
  302. #define IDDVARS         1126
  303. #define IDDIF           1127
  304. #define IDDTHEN         1128
  305. #define IDDLISTVALUE    1129
  306.  
  307.  /*id's for query box dialog*/
  308. #define IDDEDIT         1130
  309. #define IDDREAD         1131
  310. #define IDDUNKNOWN      1132
  311. #define IDDWHY          1133
  312. #define IDDINFO         1135
  313. #define IDDINHERIT      1136
  314.  
  315.  /* control ID's for browser options */
  316. #define IDDXSCALE       1150
  317. #define IDDYSCALE       1151
  318.  
  319.  /* control ID's for Options Dialog */
  320. #define IDDSLOT         1200
  321. #define IDDNEEDED       1201
  322. #define IDDBCHANGE      1202
  323. #define IDDACHANGE      1203
  324. #define IDDSINGLE       1204
  325. #define IDDLIST         1205
  326. #define IDDSTRINGTYPE   1206
  327. #define IDDNUMBERTYPE   1207
  328. #define IDDBOOLEANTYPE  1208
  329. #define IDDOBJECTTYPE   1209
  330. #define IDDCLASSTYPE    1210
  331. #define IDDPOSSTRINGSLABEL      1211
  332. #define IDDPOSVALUES    1212
  333. #define IDDNUMRANGE     1213
  334. #define IDDMINLABEL     1214
  335. #define IDDMAXLABEL     1215
  336. #define IDDSUBCLASSLABEL 1216
  337. #define IDDINSTANCELABEL 1217
  338. #define IDDMINVALUE     1218
  339. #define IDDMAXVALUE     1219
  340. #define IDDPROMPT       1220
  341. #define IDDENFORCESTRING 1221
  342. #define IDDENFORCENUM   1222
  343. #define IDDNEEDEDL      1223
  344. #define IDDBCHANGEL     1225
  345. #define IDDACHANGEL     1226
  346. #define IDDPROMPTL      1227
  347. #define IDDCARDL        1228
  348. #define IDDTYPEL        1229
  349. #define IDDHIERARC      1230
  350. #define IDDSUBCLASS     1231
  351. #define IDDINSTANCE     1232
  352.  
  353. /* Controls for ABOUT dialog box */
  354. #define IDDVERSION      1251
  355. #define IDDSERIALID     1252
  356. #define IDDCUSTOMER     1253
  357. #define IDDWAIT         1254
  358.  
  359. /* Additional control ID's for editor resources */
  360. #define IDDVALUEL               1260
  361.  
  362. /* Controls for PostAlert dialog box */
  363. #define IDDMESSAGE      1281
  364. #define IDDCALLSTACK    1282
  365. #define IDDSHOWARGS     1283
  366.  
  367. /* Controls for RULE TRACE SETUP dialog box */
  368. #define IDDTOTALTITLE   1301
  369. #define IDDSELECTTITLE  1302
  370. #define IDDTOTALLIST    1303
  371. #define IDDSELECTLIST   1304
  372. #define IDDADDLIST      1305
  373. #define IDDADDALL       1306
  374. #define IDDREMOVELIST   1307
  375. #define IDDREMOVEALL    1308
  376.  
  377. /*
  378.     Controls.
  379.     These are designed so that controls in different dialogue
  380. boxes which look the same (have the same labels) will have
  381. the same numbers.
  382. */
  383. #define IDDWIDGET_SHOW_BORDER           1401
  384. #define IDDWIDGET_TITLE                 1402
  385. #define IDDWIDGET_RIGHT_ACTION          1403
  386. #define IDDWIDGET_OWNER                 1404
  387. #define IDDWIDGET_OWNER_SLOT            1405
  388. #define IDDWIDGET_AUTO_UPDATE           1406
  389. #define IDDWIDGET_LENGTH                1407
  390. #define IDDWIDGET_ACTION                1408
  391. #define IDDWIDGET_MAX_VALUE             1409
  392. #define IDDWIDGET_MIN_VALUE             1410
  393. #define IDDWIDGET_ALLOWABLE_VALUES      1411
  394. /*
  395.     The 3 IDDWIDGET_JUST numbers must be sequential.
  396. */
  397. #define IDDWIDGET_JUST_LEFT             1412
  398. #define IDDWIDGET_JUST_RIGHT            1413
  399. #define IDDWIDGET_JUST_CENTER           1414
  400. #define IDDWIDGET_FILE_NAME             1415
  401. #define IDDWIDGET_FIT_TO_SCREEN         1416
  402. #define IDDWIDGET_X_LEFT                1417
  403. #define IDDWIDGET_X_RIGHT               1418
  404. #define IDDWIDGET_Y_BOTTOM              1419
  405. #define IDDWIDGET_Y_TOP                 1420
  406. #define IDDWIDGET_DRAW_FUNCTION         1421
  407. /*
  408.    The 6 IDDWIDGET_NUM_LINES numbers must be sequential.
  409. */
  410. #define IDDWIDGET_NUM_LINES_1           1422
  411. #define IDDWIDGET_NUM_LINES_2           1423
  412. #define IDDWIDGET_NUM_LINES_3           1424
  413. #define IDDWIDGET_NUM_LINES_4           1425
  414. #define IDDWIDGET_NUM_LINES_5           1426
  415. #define IDDWIDGET_NUM_LINES_6           1427
  416. #define IDDWIDGET_X_TITLE               1428
  417. #define IDDWIDGET_Y_TITLE               1429
  418. #define IDDWIDGET_LEGEND_ON             1430
  419. /*
  420.    The 6 IDDWIDGET_LINE numbers must be sequential.
  421. */
  422. #define IDDWIDGET_LINE_1                1431
  423. #define IDDWIDGET_LINE_2                1432
  424. #define IDDWIDGET_LINE_3                1433
  425. #define IDDWIDGET_LINE_4                1434
  426. #define IDDWIDGET_LINE_5                1435
  427. #define IDDWIDGET_LINE_6                1436
  428. #define IDDWIDGET_AUTO_SCALE            1437
  429. #define IDDWIDGET_X_MIN                 1438
  430. #define IDDWIDGET_X_MAX                 1439
  431. #define IDDWIDGET_Y_MIN                 1440
  432. #define IDDWIDGET_Y_MAX                 1441
  433. /*
  434.     Sub-dialog for XyPlot.
  435. */
  436. #define IDDWIDGET_XYPLOT_LINE_TITLE     1442
  437. #define IDDWIDGET_XYPLOT_X_OWNER        1443
  438. #define IDDWIDGET_XYPLOT_X_OWNER_SLOT   1444
  439. #define IDDWIDGET_XYPLOT_Y_OWNER        1445
  440. #define IDDWIDGET_XYPLOT_Y_OWNER_SLOT   1446
  441. #define IDDWIDGET_XYPLOT_LEGEND         1447
  442. #define IDDWIDGET_XYPLOT_LEGEND_LABEL   1448
  443.  
  444. #define IDW_BASE              1500     /* Window IDs */
  445. #define IDW_HRULER            (IDW_BASE + 1)
  446. #define IDW_VRULER            (IDW_BASE + 2)
  447. #define IDW_TOOLBOX           (IDW_BASE + 3)
  448. #define IDW_STATUSBOX         (IDW_BASE + 4)
  449.  
  450.  
  451.  /* Controls for the Input form Label controls */
  452. #define SH              5       /* Beginning height for LABEL 1 */
  453. #define LX              5       /* X-coord. of labels */
  454. #define VX              80      /* X-coordinates of value field */
  455. #define RX              165     /* X-coordinate of range field */
  456. #define LW              70      /* Label width */
  457. #define LH              12      /* Label height */
  458. #define VW              80      /* Value width */
  459. #define SVH             12      /* Single Value Height */
  460. #define LVH             21      /* List Value Height */
  461. #define RW              65      /* Range width */
  462. #define RH              12      /* Range height */
  463. #define DH              9       /* Height difference S vs. L */
  464. #define VGAP            3       /* Gap between vertical cells */
  465. #define HGAP            5       /* Gap between horiz. cells */
  466. #define OKX             130     /* X-coord. of OK button */
  467. #define OKW             32      /* Width of OK button */
  468. #define OKH             14      /* Height of OK button */
  469. #define CANCELX         165     /* X-Coord of CANCEL button */
  470. #define INFOW           224     /* Width of input form */
  471. #define INFOH           210     /* Height of input form */
  472.  
  473. #define IDDINPUTLABEL1   13000
  474. #define IDDINPUTLABEL2   IDDINPUTLABEL1+1
  475. #define IDDINPUTLABEL3   IDDINPUTLABEL1+2
  476. #define IDDINPUTLABEL4   IDDINPUTLABEL1+3
  477. #define IDDINPUTLABEL5   IDDINPUTLABEL1+4
  478. #define IDDINPUTLABEL6   IDDINPUTLABEL1+5
  479. #define IDDINPUTLABEL7   IDDINPUTLABEL1+6
  480. #define IDDINPUTLABEL8   IDDINPUTLABEL1+7
  481. #define IDDINPUTLABEL9   IDDINPUTLABEL1+8
  482. #define IDDINPUTLABEL10  IDDINPUTLABEL1+9
  483. #define IDDINPUTLABEL11  IDDINPUTLABEL1+10
  484. #define IDDINPUTLABEL12  IDDINPUTLABEL1+11
  485. #define IDDINPUTLABEL13  IDDINPUTLABEL1+12
  486. #define IDDINPUTLABEL14  IDDINPUTLABEL1+13
  487. #define IDDINPUTLABEL15  IDDINPUTLABEL1+14
  488.  
  489.  /* Input value controls */
  490. #define IDDINPUTVALUE1  IDDINPUTLABEL15+1
  491. #define IDDINPUTVALUE2  IDDINPUTVALUE1+1
  492. #define IDDINPUTVALUE3  IDDINPUTVALUE1+2
  493. #define IDDINPUTVALUE4  IDDINPUTVALUE1+3
  494. #define IDDINPUTVALUE5  IDDINPUTVALUE1+4
  495. #define IDDINPUTVALUE6  IDDINPUTVALUE1+5
  496. #define IDDINPUTVALUE7  IDDINPUTVALUE1+6
  497. #define IDDINPUTVALUE8  IDDINPUTVALUE1+7
  498. #define IDDINPUTVALUE9  IDDINPUTVALUE1+8
  499. #define IDDINPUTVALUE10 IDDINPUTVALUE1+9
  500.  
  501.  /* Input list values controls */
  502. #define IDDINPUTLISTVALUE1       IDDINPUTVALUE10+1
  503. #define IDDINPUTLISTVALUE2       IDDINPUTLISTVALUE1+1
  504. #define IDDINPUTLISTVALUE3       IDDINPUTLISTVALUE1+2
  505. #define IDDINPUTLISTVALUE4       IDDINPUTLISTVALUE1+3
  506. #define IDDINPUTLISTVALUE5       IDDINPUTLISTVALUE1+4
  507. #define IDDINPUTLISTVALUE6       IDDINPUTLISTVALUE1+5
  508. #define IDDINPUTLISTVALUE7       IDDINPUTLISTVALUE1+6
  509. #define IDDINPUTLISTVALUE8       IDDINPUTLISTVALUE1+7
  510. #define IDDINPUTLISTVALUE9       IDDINPUTLISTVALUE1+8
  511. #define IDDINPUTLISTVALUE10      IDDINPUTLISTVALUE1+9
  512.  
  513.  /* Input restriction controls */
  514. #define IDDINPUTRANGE1       IDDINPUTLISTVALUE10+1
  515. #define IDDINPUTRANGE2       IDDINPUTRANGE1+1
  516. #define IDDINPUTRANGE3       IDDINPUTRANGE1+2
  517. #define IDDINPUTRANGE4       IDDINPUTRANGE1+3
  518. #define IDDINPUTRANGE5       IDDINPUTRANGE1+4
  519. #define IDDINPUTRANGE6       IDDINPUTRANGE1+5
  520. #define IDDINPUTRANGE7       IDDINPUTRANGE1+6
  521. #define IDDINPUTRANGE8       IDDINPUTRANGE1+7
  522. #define IDDINPUTRANGE9       IDDINPUTRANGE1+8
  523. #define IDDINPUTRANGE10      IDDINPUTRANGE1+9
  524.  
  525. /* Choice Buttons */
  526. #define IDDINPUTCHOICE1      IDDINPUTRANGE10+1
  527. #define IDDINPUTCHOICE2      IDDINPUTCHOICE1+1
  528. #define IDDINPUTCHOICE3      IDDINPUTCHOICE1+2
  529. #define IDDINPUTCHOICE4      IDDINPUTCHOICE1+3
  530. #define IDDINPUTCHOICE5      IDDINPUTCHOICE1+4
  531. #define IDDINPUTCHOICE6      IDDINPUTCHOICE1+5
  532. #define IDDINPUTCHOICE7      IDDINPUTCHOICE1+6
  533. #define IDDINPUTCHOICE8      IDDINPUTCHOICE1+7
  534. #define IDDINPUTCHOICE9      IDDINPUTCHOICE1+8
  535. #define IDDINPUTCHOICE10     IDDINPUTCHOICE1+9
  536.  
  537. #define IDDVERTICALCHOICE     IDDINPUTCHOICE10+1
  538.  
  539.  /* Size of controls in Option dialogue */
  540. #define RTX     5               /* Read-text x-start */
  541. #define RTW     75              /* Read-text Width */
  542. #define TH      12              /* Text_Height */
  543. #define TW      125             /* Text Width */
  544. #define EX      95              /* Edit text x-start */
  545.  
  546.  /* controls for files.rc dialogs */
  547. #define     ID_FILENAME  400
  548. #define     ID_EDIT      401
  549. #define     ID_FILES     402
  550. #define     ID_PATH      403
  551. #define     ID_LISTBOX   404
  552. #define     ID_ECHO     405
  553. #define     ID_KAL   501
  554. #define     ID_BIN   502
  555.  
  556.  /* KAPPA specific message controls */
  557. #define IDG_AUTOOPEN    3001
  558. #define IDG_SETOWNER    3002
  559. #define IDG_CLOSESLOT   3003
  560. #define IDG_CLOSEMETHOD 3004
  561. #define IDG_PARENDETECT 3005
  562. #define IDG_UPDATEINDEX 3006
  563. #define IDG_HSCROLL     3007
  564. #define IDG_VSCROLL     3008
  565. #define IDG_UPDATEVALUEWINDOW 3009
  566. #define IDG_RESET       3010
  567. #define IDG_SELECTMENU  3011
  568. #define WG_SETMODE      3012
  569.  
  570. /* ReadOnlyText window support */
  571. #define ROT_APPEND_FILE  3013
  572. #define ROT_APPEND_BUFFER  3014
  573. #define ROT_SAVE         3015
  574. #define ROT_DELETE       3016
  575.  
  576. #define OSF_APPEND       3017   /* Open Save File Append command. */
  577. #define IDG_SETFIXEDFONT 3018
  578. #define IDG_ISFIXEDFONT  3019
  579.  
  580. /* ID's for userdefined names and type */
  581. #define IDR_NAME        10001
  582. #define IDR_TYPE        10002
  583.  
  584. /**************************************************
  585.            ATTENTION: Alert String IDS
  586.    ID's 10000-11000 are reserved for this purpose
  587. **************************************************/
  588.  
  589. /* error messages from kappa library functions */
  590. #define IDE_ERROR               10000
  591. #define IDE_MISSINGARGS         10001
  592. #define IDE_TOOMANYARGS         10002
  593. #define IDE_NOSUCCESS           10003
  594. #define IDE_ERRORINFUNC         10004
  595. #define IDE_NOTEXIST            10005
  596. #define IDE_NOARGLIST           10006
  597. #define IDE_BADARG              10007
  598. #define IDE_ILLEGALARG          10008
  599. #define IDE_FWRITEOK            10009
  600. #define IDE_FCANTOPEN           10010
  601. #define IDE_FNOTOPEN            10011
  602. #define IDE_FALREADYOPEN        10012
  603. #define IDE_FEOF                10013
  604. #define IDE_PAIRNOTFOUND        10014
  605. #define IDE_PAIRNOTATOMS        10015
  606. #define IDE_WRONGEXPFORMAT      10016
  607. #define IDE_FUNCNOTFOUND        10017
  608. #define IDE_FLOATERROR          10018
  609. #define IDE_EXPECTFOUND         10019
  610. #define IDE_ERRORUSER           10020
  611. #define IDE_NOTWIDGET           10021
  612. #define IDE_NOTTRANSWIDGET      10022
  613. #define IDE_INTERRUPTEVAL       10023
  614. #define IDE_PAIRNOTEXIST        10024
  615. #define IDE_NOTSUBCLASS         10025
  616. #define IDE_ERRORSYSTIME        10026
  617. #define IDE_TIMENOTSET          10027
  618. #define IDE_BADRANGEMARKER      10028
  619. #define IDE_MISSINGRANGE        10029
  620. #define IDE_BADRANGE            10030
  621. #define IDE_CLOSELABELRANGE     10031
  622. #define IDE_BADLABEL            10032
  623. #define IDE_RANGETYPE           10033
  624. #define IDE_BADNUMARG           10034
  625. #define IDE_IFFULL              10035
  626. #define IDE_IFDUPLICATEPAIR     10036
  627. #define IDE_IFDUPLICATENAME     10037
  628. #define IDE_BADWIDGETFORLINK    10038
  629. #define IDE_ALREADYLINKED       10039
  630. #define IDE_BADESCAPEFORMAT     10040
  631. #define IDE_BADFILLERTYPE       10041
  632. #define IDE_NOTLINKED           10042
  633. #define IDE_USEEXIT             10043
  634. #define IDE_BADDBOBJECT         10044
  635. #define IDE_MUSTBEOBJECT        10045
  636. #define IDE_NEEDQUERYFILENAME   10046
  637. #define IDE_NOQUERY             10047
  638. #define IDE_NODBTYPE            10048
  639. #define IDE_UNKNOWNDBTYPE       10049
  640. #define IDE_RULEERROR           10050
  641. #define IDE_MUSTBECLASS         10051
  642. #define IDE_POSTMENUZEROITEM    10052
  643. #define IDE_FITONAPAGE          10053
  644. #define IDE_NOOUTPUTFILE        10054
  645. #define IDE_DBFIELDS            10055
  646. #define IDE_OUTPUTNOTEXIST      10056
  647. #define IDE_NORENAMEROOT        10057
  648. #define IDE_NOBITMAP            10058
  649. #define IDE_FILETOOLARGE        10059
  650. #define IDE_NOBMONCLIPBOARD     10060
  651. #define IDE_FOUTOFDISK          10061
  652. #define IDE_BITMAPTOOLARGE      10062
  653. #define IDE_UNSUPPORTEDBM       10063
  654. #define IDE_EXPTOOBIG           10064
  655. #define IDE_BADOPTKEY           10065
  656. #define IDE_MUSTBENUMBER        10066
  657. #define IDE_MISSINGFILENAME     10067
  658. #define IDE_DIVIDEBYZERO        10068
  659. #define IDE_NEGATIVEVALUE       10069
  660. #define IDE_NOTOWNEDSLOT        10070
  661. #define IDE_DUPLICATESLOT       10071
  662. #define IDE_BEINGEDITED         10072
  663. #define IDE_UNCLOSEDQUOTE       10073
  664. #define IDE_ENDOFEXPINPAIR      10074
  665. #define IDE_CLOSEPARINPAIR      10075
  666. #define IDE_OPENPARINPAIR       10076
  667. #define IDE_DOUBLECOLON         10077
  668. #define IDE_TOOMANYCLOSEPAR     10078
  669. #define IDE_UNCLOSEDPAR         10079
  670. #define IDE_MORETHANONEEXP      10080
  671. #define IDE_EMPTYEXP            10081
  672. #define IDE_BADBITMAPFILE       10082
  673. #define IDE_OUTOFRANGE          10083
  674. #define IDE_MUSTBESINGLE        10084
  675. #define IDE_NULLCLAUSE          10085
  676.  
  677. #define IDE_DB_INVALIDFILE      10086
  678. #define IDE_BADINFERMODE        10087
  679. #define IDE_BADNAME             10088
  680. #define IDE_NOSUCHMETHOD        10089
  681.  
  682. #define IDE_DUMMY               10100
  683. #define IDE_FLOATERR            10101
  684. #define IDE_OUTOFMEMQUIT        10102
  685. #define IDE_NONAME              10103
  686. #define IDE_NOTVALNAME          10104
  687. #define IDE_NOWILDCRD           10105
  688. #define IDE_EDITFILE            10106
  689. #define IDE_SLOTSOPEN           10107
  690. #define IDE_YOUSURE             10108
  691. #define IDE_BLANKSTRING         10110
  692. #define IDE_OUTOFMEMSAVE        10113
  693. #define IDE_CONTACTUS           10114
  694. #define IDE_BADSCALE            10115
  695. #define IDE_NODUMP              10116
  696. #define IDE_CANCELPRINT         10117
  697. #define IDE_PRINTERROR          10118
  698. #define IDE_PRINTFAIL           10119
  699. #define IDE_NOCONTRP            10120
  700. #define IDE_TRPERROR            10121
  701. #define IDE_TOOLONG             10122
  702. #define IDE_SAVEDIREXISTS       10123
  703. #define IDE_SAVEFILEEXISTS      10124
  704. #define IDE_REACHEDMAXID        10125
  705. #define IDE_OUTOFLOCALMEMQUIT   10126
  706. #define IDE_OUTOFLOCALMEMSAVE   10127
  707. #define IDE_INTERRUPT           10128
  708. #define IDE_DUPLICATENAME       10129
  709. #define IDE_QUERYSAVE           10130
  710. #define IDE_MUSTBEANUMBER       10132
  711. #define IDE_PRINTWIDGETFAILED   10133
  712. #define IDE_NOPRINTFUNC         10134
  713. #define IDE_BADCLASS            10135
  714. #define IDE_CLOSEEDITORS        10136
  715. #define IDE_DUPLICATEEDITOR     10137
  716. #define IDE_BADOBJECT           10138
  717. #define IDE_BADSLOT             10139
  718. #define IDE_OUTSIDEMINMAX       10143
  719. #define IDE_OUTSIDEPOSSVALUES   10144
  720. #define IDE_NONNUMERIC          10145
  721. #define IDE_BADEXP              10146
  722. #define IDE_REALLOCBRTABLE      10147
  723. #define IDE_REACHEDMAXSTRINGLENGTH 10148
  724. #define IDE_NOMOVEPTOC          10149
  725. #define IDE_ITEMALREADYEXISTS   10150
  726. #define IDE_OBJECTALREADYEXISTS 10151
  727. #define IDE_CLASSALREADYEXISTS  10152
  728. #define IDE_NOOBJECTCLASSBYNAME 10153
  729. #define IDE_NOSYSDELETE         10154
  730. #define IDE_NOSYSRENAME         10155
  731. #define IDE_NOSYSMETHRENAME     10156
  732. #define IDE_NOSYSMETHDELETE     10157
  733. #define IDE_NOSYSSLOTRENAME     10158
  734. #define IDE_NOSYSSLOTDELETE     10159
  735. #define IDE_NOIMAGEOPTIONS     10160
  736.  
  737. #define IDE_RULEIFERROR         10170
  738. #define IDE_RULETHENERROR       10171
  739. #define IDE_RULEIFERROR1        10172
  740. #define IDE_RULETHENERROR1      10173
  741.  
  742. #define IDE_NORULES             10174
  743. #define IDE_NOSLOTS             10175
  744. #define IDE_NOTINFERING         10176
  745.  
  746. #define IDE_BCBADRETURN         10177
  747.  
  748. #define IDE_NOEXPLAIN           10200
  749. #define IDE_NOTAVAILBC          10201
  750. #define IDE_NOHELPFORQUERY      10202
  751.  
  752.  
  753. #define IDE_WRITEERROR          10300
  754. #define IDE_DBASEERROR          10301
  755.  
  756. /**********************************
  757. TK: SYNTAX ERROR CODES
  758.  **********************************/
  759. #define SYNTAX_ERROR_BASE       3350
  760. #define IDE_EXPECT_NAME         SYNTAX_ERROR_BASE+ 1
  761. #define IDE_INTERNAL1           SYNTAX_ERROR_BASE+ 2
  762. #define IDE_INTERNAL2           SYNTAX_ERROR_BASE+ 3
  763. #define IDE_INTERNAL3           SYNTAX_ERROR_BASE+ 4
  764. #define IDE_BLOCK_ERROR         SYNTAX_ERROR_BASE+ 5
  765. #define IDE_PARENT_ERROR        SYNTAX_ERROR_BASE+ 6
  766. #define IDE_EXPECT_OB           SYNTAX_ERROR_BASE+ 7
  767. #define IDE_EXPECT_CB           SYNTAX_ERROR_BASE+ 8
  768. #define IDE_EXP_ERROR           SYNTAX_ERROR_BASE+ 9
  769. #define IDE_EXPECT_VB           SYNTAX_ERROR_BASE+ 10
  770. #define IDE_EXPECT_NP           SYNTAX_ERROR_BASE+ 11
  771. #define IDE_EXPECT_THEN         SYNTAX_ERROR_BASE+ 12
  772. #define IDE_EXPECT_ELSE         SYNTAX_ERROR_BASE+ 13
  773. #define IDE_CONTROL_ERROR       SYNTAX_ERROR_BASE+ 14
  774. #define IDE_EXPECT_OPERATOR     SYNTAX_ERROR_BASE+ 15
  775. #define IDE_NOTEXPECT           SYNTAX_ERROR_BASE+ 16
  776. #define IDE_EXPECT_CP           SYNTAX_ERROR_BASE+ 17
  777. #define IDE_INFIX_ERROR         SYNTAX_ERROR_BASE+ 18
  778. #define IDE_TERMINATION_ERROR   SYNTAX_ERROR_BASE+ 19
  779. #define IDE_END_STRING          SYNTAX_ERROR_BASE+ 20
  780. #define IDE_LEFTOFASSIGNMENT    SYNTAX_ERROR_BASE+ 21
  781.  
  782.  
  783. /**********************************************************************
  784.         KAPPA resource include file, includes all stringtable 
  785.         constants for KAL functions.
  786. **********************************************************************/
  787.  
  788. /*
  789.     build_function names.
  790.     These are listed by the sections in libman.c.
  791. */
  792. #define IDF_FBASE       2200
  793. /*
  794.     Expanded memory.
  795. */
  796. /*
  797. #define IDF_INITEXPANDED        (IDF_FBASE + 0)
  798. #define IDF_CLEANUPEXPANDED     (IDF_FBASE + 1)
  799. #define IDF_ALLOCEXPANDED       (IDF_FBASE + 2)
  800. #define IDF_FREEEXPANDED        (IDF_FBASE + 3)
  801. #define IDF_LOCKEXPANDED        (IDF_FBASE + 4)
  802. #define IDF_UNLOCKEXPANDED      (IDF_FBASE + 5)
  803. #define IDF_PUTCHAR             (IDF_FBASE + 6)
  804. #define IDF_SHOWALLOCTABLE      (IDF_FBASE + 7)
  805. #define IDF_SHOWLOCKTABLE       (IDF_FBASE + 8)
  806. */
  807. /*
  808.     Knowledge.
  809. */
  810. #define IDF_MAKECLASS           (IDF_FBASE + 9)
  811. #define IDF_CLASSQUESTION       (IDF_FBASE + 10)
  812. #define IDF_DELETECLASS         (IDF_FBASE + 11)
  813. #define IDF_RENAMECLASS         (IDF_FBASE + 12)
  814. #define IDF_SETCLASSINFO        (IDF_FBASE + 13)
  815. #define IDF_GETCLASSINFO        (IDF_FBASE + 14)
  816. #define IDF_TOOBJECT            (IDF_FBASE + 15)
  817. #define IDF_MAKEOBJECT          (IDF_FBASE + 16)
  818. #define IDF_OBJECTQUESTION      (IDF_FBASE + 17)
  819. #define IDF_DELETEOBJECT        (IDF_FBASE + 18)
  820. #define IDF_RENAMEOBJECT        (IDF_FBASE + 19)
  821. #define IDF_SETOBJECTINFO       (IDF_FBASE + 20)
  822. #define IDF_GETOBJECTINFO       (IDF_FBASE + 21)
  823. #define IDF_TOCLASS             (IDF_FBASE + 22)
  824. #define IDF_GETPARENT           (IDF_FBASE + 23)
  825. #define IDF_ISAKINDOFQUESTION   (IDF_FBASE + 24)
  826. #define IDF_MOVEOBJECT          (IDF_FBASE + 25)
  827. #define IDF_CONVERTBROWSERDISPLAYTEXT   (IDF_FBASE + 26)
  828. #define IDF_COUNTOBJECTS        (IDF_FBASE + 27)
  829. #define IDF_COUNTALLOBJECTS     (IDF_FBASE + 28)
  830. #define IDF_COUNTSUBCLASSES     (IDF_FBASE + 29)
  831. #define IDF_COUNTALLSUBCLASSES  (IDF_FBASE + 30)
  832. #define IDF_GETOBJECTLIST       (IDF_FBASE + 31)
  833. #define IDF_GETSUBCLASSLIST     (IDF_FBASE + 32)
  834. #define IDF_MOVEHIERARCHY       (IDF_FBASE + 33)
  835. #define IDF_GETDEPTH            (IDF_FBASE + 34)
  836. #define IDF_PRINTHIERARCHY      (IDF_FBASE + 35)
  837.  
  838. #define IDF_GETSLOTLIST         (IDF_FBASE + 38)
  839. #define IDF_MAKEFUNCTION        (IDF_FBASE + 39)
  840. #define IDF_FUNCTIONQUESTION    (IDF_FBASE + 40)
  841. #define IDF_DELETEFUNCTION      (IDF_FBASE + 41)
  842. #define IDF_RENAMEFUNCTION      (IDF_FBASE + 42)
  843. #define IDF_SETFUNCTIONINFO     (IDF_FBASE + 43)
  844. #define IDF_GETFUNCTIONINFO     (IDF_FBASE + 44)
  845. #define IDF_SHOWFUNCTION        (IDF_FBASE + 45)
  846. #define IDF_MAKEGOAL            (IDF_FBASE + 46)
  847. #define IDF_GOALQUESTION        (IDF_FBASE + 47)
  848. #define IDF_DELETEGOAL          (IDF_FBASE + 48)
  849. #define IDF_RENAMEGOAL          (IDF_FBASE + 49)
  850. #define IDF_SETGOALINFO         (IDF_FBASE + 50)
  851. #define IDF_GETGOALINFO         (IDF_FBASE + 51)
  852. #define IDF_TESTGOAL            (IDF_FBASE + 52)
  853. #define IDF_MAKERULE            (IDF_FBASE + 53)
  854. #define IDF_RULEQUESTION        (IDF_FBASE + 54)
  855. #define IDF_SETRULEPRIORITY     (IDF_FBASE + 55)
  856. #define IDF_DELETERULE          (IDF_FBASE + 56)
  857. #define IDF_RENAMERULE          (IDF_FBASE + 57)
  858. #define IDF_SETRULEINFO         (IDF_FBASE + 58)
  859. #define IDF_GETRULEINFO         (IDF_FBASE + 59)
  860. #define IDF_TESTRULE            (IDF_FBASE + 60)
  861. #define IDF_EXECRULE            (IDF_FBASE + 61)
  862. #define IDF_EVALRULE            (IDF_FBASE + 62)
  863. /*
  864.     Inference.
  865. */
  866. #define IDF_ACTIVATERULE       (IDF_FBASE + 63)
  867. #define IDF_DEACTIVATERULE      (IDF_FBASE + 64)
  868. #define IDF_SETACTIVERULES      (IDF_FBASE + 65)
  869. #define IDF_BACKCHAIN           (IDF_FBASE + 66)
  870. #define IDF_EXPLAIN             (IDF_FBASE + 68)
  871. /*
  872.     Slots.
  873. */
  874. #define IDF_MAKESLOT            (IDF_FBASE + 69)
  875. #define IDF_GETOWNER            (IDF_FBASE + 70)
  876. #define IDF_DELETESLOT          (IDF_FBASE + 71)
  877. #define IDF_RENAMESLOT          (IDF_FBASE + 72)
  878. #define IDF_SETSLOTINFO         (IDF_FBASE + 73)
  879. #define IDF_GETSLOTINFO         (IDF_FBASE + 74)
  880. #define IDF_RESETVALUE          (IDF_FBASE + 75)
  881. #define IDF_ASKVALUE            (IDF_FBASE + 76)
  882. #define IDF_SETVALUE            (IDF_FBASE + 77)
  883. #define IDF_KNOWNVALUEQUESTION  (IDF_FBASE + 78)
  884. #define IDF_ASSERT              (IDF_FBASE + 79)
  885. #define IDF_GETVALUE            (IDF_FBASE + 80)
  886. #define IDF_SLOTQUESTION        (IDF_FBASE + 81)
  887. #define IDF_LOCALVALUEQUESTION  (IDF_FBASE + 82)
  888. #define IDF_SETSLOTOPTION       (IDF_FBASE + 83)
  889. #define IDF_GETSLOTOPTION       (IDF_FBASE + 84)
  890. #define IDF_RESETSLOTOPTION     (IDF_FBASE + 85)
  891. /*
  892.     Methods.
  893. */
  894. #define IDF_MAKEMETHOD          (IDF_FBASE + 86)
  895. #define IDF_DELETEMETHOD        (IDF_FBASE + 87)
  896. #define IDF_RENAMEMETHOD        (IDF_FBASE + 88)
  897. #define IDF_SETMETHODINFO       (IDF_FBASE + 89)
  898. #define IDF_GETMETHODINFO       (IDF_FBASE + 90)
  899. #define IDF_METHODQUESTION      (IDF_FBASE + 91)
  900. #define IDF_SENDMESSAGE         (IDF_FBASE + 92)
  901. #define IDF_MAILMESSAGE         (IDF_FBASE + 93)
  902. #define IDF_SHOWMETHOD          (IDF_FBASE + 94)
  903. /*
  904.     Numerical.
  905. */
  906. #define IDF_CALCULATE           (IDF_FBASE + 99)
  907. #define IDF_PLUS                (IDF_FBASE + 100)
  908. #define IDF_MINUS               (IDF_FBASE + 101)
  909. #define IDF_TIMES               (IDF_FBASE + 102)
  910. #define IDF_DIVIDE              (IDF_FBASE + 103)
  911. #define IDF_SQRT                (IDF_FBASE + 104)
  912. #define IDF_POWER               (IDF_FBASE + 105)
  913. #define IDF_FLOOR               (IDF_FBASE + 106)
  914. #define IDF_CEIL                (IDF_FBASE + 107)
  915. #define IDF_ABS                 (IDF_FBASE + 108)
  916. #define IDF_NEGATIVE            (IDF_FBASE + 109)
  917. /*
  918.     Strings.
  919. */
  920. #define IDF_APPEND              (IDF_FBASE + 118)
  921. #define IDF_SAMEQUESTION        (IDF_FBASE + 119)
  922. #define IDF_FORMATVALUE         (IDF_FBASE + 120)
  923. /*
  924.     Float array.
  925. */
  926. #define IDF_ALLOCFLOATARRAY     (IDF_FBASE + 121)
  927. #define IDF_REALLOCFLOATARRAY   (IDF_FBASE + 122)
  928. #define IDF_FREEFLOATARRAY      (IDF_FBASE + 123)
  929. #define IDF_SETFLOATARRAY       (IDF_FBASE + 124)
  930. #define IDF_GETFLOATARRAY       (IDF_FBASE + 125)
  931. #define IDF_LISTTOFLOATARRAY    (IDF_FBASE + 126)
  932. /*
  933.     Lists.
  934. */
  935. #define IDF_MAKELIST            (IDF_FBASE + 127)
  936. #define IDF_DELETELIST          (IDF_FBASE + 128)
  937. #define IDF_COPYLIST            (IDF_FBASE + 129)
  938. #define IDF_CLEARLIST           (IDF_FBASE + 130)
  939. #define IDF_LENGTHLIST          (IDF_FBASE + 131)
  940. #define IDF_MEMBERQUESTION      (IDF_FBASE + 132)
  941. #define IDF_APPENDTOLIST        (IDF_FBASE + 133)
  942. #define IDF_REMOVEFROMLIST      (IDF_FBASE + 134)
  943. #define IDF_INSERTNTHELEM       (IDF_FBASE + 135)
  944. #define IDF_SETNTHELEM          (IDF_FBASE + 136)
  945. #define IDF_GETNTHELEM          (IDF_FBASE + 137)
  946. #define IDF_GETELEMPOS          (IDF_FBASE + 138)
  947. #define IDF_REMOVENTHELEM       (IDF_FBASE + 139)
  948. /*
  949.     Item selection in lists.
  950. */
  951. #define IDF_ENUMLIST            (IDF_FBASE + 140)
  952. #define IDF_SELECTLIST          (IDF_FBASE + 141)
  953. /*
  954.     Item selection in classes.
  955. */
  956. #define IDF_ENUMSUBCLASSES      (IDF_FBASE + 142)
  957. #define IDF_SELECTSUBCLASS      (IDF_FBASE + 143)
  958. /*
  959.     List mathematics.
  960. */
  961. #define IDF_SUM                 (IDF_FBASE + 144)
  962. #define IDF_MULTIPLY            (IDF_FBASE + 145)
  963. #define IDF_AVERAGE             (IDF_FBASE + 146)
  964. #define IDF_MAX                 (IDF_FBASE + 147)
  965. #define IDF_MIN                 (IDF_FBASE + 148)
  966. /*
  967.     Lotus 1-2-3.
  968. */
  969. #define IDF_GET123CELL          (IDF_FBASE + 149)
  970. #define IDF_GET123RANGE         (IDF_FBASE + 150)
  971. /*
  972.     File i/o.
  973. */
  974. #define IDF_INTERPRETFILE       (IDF_FBASE + 151)
  975. #define IDF_OPENREADFILE        (IDF_FBASE + 152)
  976. #define IDF_OPENWRITEFILE       (IDF_FBASE + 153)
  977. #define IDF_CLOSEREADFILE       (IDF_FBASE + 154)
  978. #define IDF_CLOSEWRITEFILE      (IDF_FBASE + 155)
  979. #define IDF_READWORD            (IDF_FBASE + 156)
  980. #define IDF_WRITELINE           (IDF_FBASE + 157)
  981. #define IDF_WRITEQUOTED         (IDF_FBASE + 158)
  982. #define IDF_WRITEHIERARCHY      (IDF_FBASE + 159)
  983. #define IDF_WRITECLASS          (IDF_FBASE + 160)
  984. #define IDF_WRITEOBJECT         (IDF_FBASE + 161)
  985. #define IDF_WRITEFUNCTION       (IDF_FBASE + 162)
  986. #define IDF_WRITERULE           (IDF_FBASE + 163)
  987. #define IDF_WRITEGOAL           (IDF_FBASE + 164)
  988. #define IDF_WRITEALLCLASSES     (IDF_FBASE + 165)
  989. #define IDF_WRITEALLOBJECTS     (IDF_FBASE + 166)
  990. #define IDF_WRITEALLFUNCTIONS   (IDF_FBASE + 167)
  991. #define IDF_WRITEALLRULES       (IDF_FBASE + 168)
  992. #define IDF_WRITEALLGOALS       (IDF_FBASE + 169)
  993. #define IDF_WRITEALLKNOWLEDGE   (IDF_FBASE + 170)
  994. #define IDF_WRITEALL            (IDF_FBASE + 171)
  995. #define IDF_CLEARINTERPRETER    (IDF_FBASE + 172)
  996. #define IDF_SAVEINTERPRETER     (IDF_FBASE + 173)
  997. #define IDF_SAVETRACE           (IDF_FBASE + 174)
  998. #define IDF_SHOWWINDOW          (IDF_FBASE + 175)
  999. #define IDF_HIDEWINDOW          (IDF_FBASE + 176)
  1000. #define IDF_POSITIONWINDOW      (IDF_FBASE + 177)
  1001. #define IDF_ICONIFYWINDOW       (IDF_FBASE + 178)
  1002. #define IDF_MAXIMIZEWINDOW      (IDF_FBASE + 179)
  1003. #define IDF_SETWINDOWTITLE      (IDF_FBASE + 180)
  1004. #define IDF_FREEZEWINDOW        (IDF_FBASE + 181)
  1005. #define IDF_UNFREEZEWINDOW      (IDF_FBASE + 182)
  1006. #define IDF_REMOVEWINDOWMENU    (IDF_FBASE + 183)
  1007. #define IDF_RESETWINDOWMENU     (IDF_FBASE + 184)
  1008. #define IDF_SETFOCUS            (IDF_FBASE + 185)
  1009. #define IDF_GETFOCUS            (IDF_FBASE + 186)
  1010. #define IDF_SETPOSTMESSAGETITLE (IDF_FBASE + 187)
  1011. #define IDF_SHOWOBJECTS         (IDF_FBASE + 188)
  1012. #define IDF_SHOWSUBCLASSES      (IDF_FBASE + 189)
  1013. #define IDF_HIDEOBJECTS         (IDF_FBASE + 190)
  1014. #define IDF_HIDESUBCLASSES      (IDF_FBASE + 191)
  1015. #define IDF_SETWINDOWBACKGROUND (IDF_FBASE + 192)
  1016. /*
  1017.     Error functions.
  1018. */
  1019. #define IDF_CATCHERROR          (IDF_FBASE + 200)
  1020. #define IDF_POSTERROR           (IDF_FBASE + 201)
  1021. #define IDF_POSTMESSAGE         (IDF_FBASE + 202)
  1022. #define IDF_POSTBUSY            (IDF_FBASE + 203)
  1023. /*
  1024.     Meta-functions.
  1025. */
  1026. #define IDF_DO                  (IDF_FBASE + 204)
  1027. #define IDF_IF                  (IDF_FBASE + 205)
  1028. #define IDF_LET                 (IDF_FBASE + 206)
  1029. #define IDF_FOR                 (IDF_FBASE + 207)
  1030. #define IDF_WHILE               (IDF_FBASE + 208)
  1031. #define IDF_FORALL              (IDF_FBASE + 209)
  1032. #define IDF_ISTHEREANYQUESTION  (IDF_FBASE + 210)
  1033. #define IDF_AREALLQUESTION      (IDF_FBASE + 211)
  1034. /*
  1035.     System functions.
  1036. */
  1037. #define IDF_EXECUTE             (IDF_FBASE + 232)
  1038. #define IDF_BEEP                (IDF_FBASE + 233)
  1039. #define IDF_TIME                (IDF_FBASE + 234)
  1040. #define IDF_DATE                (IDF_FBASE + 235)
  1041. #define IDF_TIMEDIFF            (IDF_FBASE + 236)
  1042. #define IDF_RESETCLOCK          (IDF_FBASE + 237)
  1043. #define IDF_GETCLOCK            (IDF_FBASE + 238)
  1044. #define IDF_EXIT                (IDF_FBASE + 239)
  1045. #define IDF_WAIT                (IDF_FBASE + 240)
  1046. #define IDF_GETSCREENWIDTH      (IDF_FBASE + 241)
  1047. #define IDF_GETSCREENHEIGHT     (IDF_FBASE + 242)
  1048. #define IDF_PROT                (IDF_FBASE + 243)
  1049. /*
  1050.     Widgets.
  1051. */
  1052. #define IDF_MAKEWIDGET          (IDF_FBASE + 244)
  1053. #define IDF_POSITIONWIDGET      (IDF_FBASE + 245)
  1054. #define IDF_DRAWWIDGET          (IDF_FBASE + 246)
  1055. #define IDF_UPDATEWIDGET        (IDF_FBASE + 247)
  1056. #define IDF_INPUTWIDGET         (IDF_FBASE + 248)
  1057. #define IDF_PRINTWIDGET         (IDF_FBASE + 249)
  1058. #define IDF_RESETWIDGET         (IDF_FBASE + 250)
  1059. #define IDF_SELECTWIDGET        (IDF_FBASE + 251)
  1060. #define IDF_SETWIDGETLINK       (IDF_FBASE + 252)
  1061. #define IDF_CLEARWIDGETLINK     (IDF_FBASE + 253)
  1062. #define IDF_DELETEWIDGET        (IDF_FBASE + 254)
  1063. #define IDF_SHOWWIDGET          (IDF_FBASE + 255)
  1064. #define IDF_HIDEWIDGET          (IDF_FBASE + 256)
  1065. #define IDF_DISPLAYTEXT         (IDF_FBASE + 258)
  1066. #define IDF_CLEARTRANSCRIPTWIDGET       (IDF_FBASE + 259)
  1067. #define IDF_SAVETRANSCRIPTWIDGET        (IDF_FBASE + 260)
  1068. #define IDF_DISPLAYFILE         (IDF_FBASE + 261)
  1069. #define IDF_COPYBITMAPTOCLIPBOARD       (IDF_FBASE + 262)
  1070. #define IDF_SAVECLIPBOARDBITMAP (IDF_FBASE + 263)
  1071. #define IDF_DRAWT               (IDF_FBASE + 264)
  1072. /*
  1073.     Trigonometric functions.
  1074. */
  1075. #define IDF_LOG                 (IDF_FBASE + 275)
  1076. #define IDF_COS                 (IDF_FBASE + 276)
  1077. #define IDF_SIN                 (IDF_FBASE + 277)
  1078. #define IDF_TAN                 (IDF_FBASE + 278)
  1079. #define IDF_ACOS                (IDF_FBASE + 279)
  1080. #define IDF_ASIN                (IDF_FBASE + 280)
  1081. #define IDF_ATAN                (IDF_FBASE + 281)
  1082. /*
  1083.     More i/o.
  1084. */
  1085. #define IDF_POSTINPUTFORM       (IDF_FBASE + 282)
  1086. #define IDF_POSTMENU            (IDF_FBASE + 283)
  1087. #define IDF_POSTMULTIPLESELECTION       (IDF_FBASE + 284)
  1088. #define IDF_SETPOSTMENUPOSITION (IDF_FBASE + 285)
  1089. /*
  1090.     Graphics.
  1091. */
  1092. #define IDF_MOVETO              (IDF_FBASE + 295)
  1093. #define IDF_LINETO              (IDF_FBASE + 296)
  1094. #define IDF_MOVETOREL           (IDF_FBASE + 297)
  1095. #define IDF_LINETOREL           (IDF_FBASE + 298)
  1096. #define IDF_RECTANGLE           (IDF_FBASE + 299)
  1097. #define IDF_ELLIPSE             (IDF_FBASE + 300)
  1098. #define IDF_SETLINESTYLE        (IDF_FBASE + 301)
  1099. /*
  1100. #define IDF_INITIALIZEGRAPHICS  (IDF_FBASE + 302)
  1101. #define IDF_ENDGRAPHICS         (IDF_FBASE + 303)
  1102. */
  1103. #define IDF_DRAWTEXT            (IDF_FBASE + 304)
  1104.  
  1105. #define IDF_INITIALIZEDB        (IDF_FBASE + 305)
  1106.  
  1107. #define IDF_IMPORTDBDATA        (IDF_FBASE + 306)
  1108. #define IDF_EXPORTDBDATA        (IDF_FBASE + 307)
  1109. #define IDF_FORM_LIST           (IDF_FBASE + 308)
  1110.  
  1111. /*
  1112.     Tony's new functions
  1113. */
  1114. /*
  1115. #define IDF_COMPILERULENETWORK  (IDF_FBASE + 320)
  1116. #define IDF_PRINTRULENETWORK    (IDF_FBASE + 321)
  1117. #define IDF_INITFORWARDCHAIN    (IDF_FBASE + 322)
  1118. #define IDF_PRINTAGENDA         (IDF_FBASE + 326)
  1119. */
  1120. #define IDF_STOPFORWARDCHAIN    (IDF_FBASE + 323)
  1121. #define IDF_SETFORWARDCHAINMODE (IDF_FBASE + 324)
  1122. #define IDF_FORWARDCHAIN        (IDF_FBASE + 325)
  1123. /*
  1124.     Logic.
  1125. */
  1126. #define IDF_FIRSTVALUE          (IDF_FBASE + 350)
  1127. #define IDF_AND                 (IDF_FBASE + 351)
  1128. #define IDF_OR                  (IDF_FBASE + 352)
  1129. #define IDF_XOR                 (IDF_FBASE + 353)
  1130. #define IDF_NOT                 (IDF_FBASE + 354)
  1131. #define IDF_NULLQUESTION        (IDF_FBASE + 355)
  1132.  
  1133. /*
  1134.     Numerical test.
  1135. */
  1136. #define IDF_NUMBERQUESTION      (IDF_FBASE + 380)
  1137. #define IDF_INTEGERQUESTION     (IDF_FBASE + 381)
  1138. #define IDF_ALMOSTEQUAL         (IDF_FBASE + 382)
  1139. #define IDF_EQUAL               (IDF_FBASE + 383)
  1140. #define IDF_NOTEQUAL            (IDF_FBASE + 384)
  1141. #define IDF_LESSEQUAL           (IDF_FBASE + 385)
  1142. #define IDF_GREATEREQUAL        (IDF_FBASE + 386)
  1143. #define IDF_LESS                (IDF_FBASE + 387)
  1144. #define IDF_GREATER             (IDF_FBASE + 388)
  1145. #define IDF_PLUSEQUAL           (IDF_FBASE + 389)
  1146. #define IDF_MINUSEQUAL          (IDF_FBASE + 390)
  1147. #define IDF_SAMEEQUAL           (IDF_FBASE + 391)
  1148. #define IDF_INFIX               (IDF_FBASE + 392)
  1149. #define IDF_MAPESCAPEKEY        (IDF_FBASE + 393)
  1150.  
  1151. /*
  1152.     Database Interface Module
  1153. */
  1154. #define IDF_DB_OPENFILE         (IDF_FBASE + 500)
  1155. #define IDF_DB_CLOSEFILE        (IDF_FBASE + 501)
  1156. #define IDF_DB_OPENINDEX        (IDF_FBASE + 502)
  1157. #define IDF_DB_CLOSEINDEX       (IDF_FBASE + 503)
  1158. #define IDF_DB_SELECTFILE       (IDF_FBASE + 504)
  1159. #define IDF_DB_SELECTINDEXFILE  (IDF_FBASE + 505)
  1160. #define IDF_DB_SETROWPOSITION   (IDF_FBASE + 506)
  1161. #define IDF_DB_GETROWPOSITION   (IDF_FBASE + 507)
  1162. #define IDF_DB_GETNUMROWS       (IDF_FBASE + 508)
  1163. #define IDF_DB_SKIPROW          (IDF_FBASE + 509)
  1164. #define IDF_DB_READCELL         (IDF_FBASE + 510)
  1165. #define IDF_DB_WRITECELL        (IDF_FBASE + 511)
  1166. #define IDF_DB_GETNUMFIELDS     (IDF_FBASE + 512)
  1167. #define IDF_DB_GETFIELDNAMES    (IDF_FBASE + 513)
  1168. #define IDF_DB_READFIELD        (IDF_FBASE + 514)
  1169. #define IDF_DB_WRITEFIELD       (IDF_FBASE + 515)
  1170. #define IDF_DB_SETMAPPARAMETERS (IDF_FBASE + 516)
  1171. #define IDF_DB_MAPROWTOINSTANCE (IDF_FBASE + 517)
  1172. #define IDF_DB_MAPINSTANCETOROW (IDF_FBASE + 518)
  1173.  
  1174. #define IDF_DB_SETFILTER        (IDF_FBASE + 519)
  1175. #define IDF_DB_FINDRECORD       (IDF_FBASE + 520)
  1176. #define IDF_DB_SEEKRECORD       (IDF_FBASE + 521)
  1177.  
  1178. #define IDF_DB_INITDATABASE      (IDF_FBASE + 522)
  1179. #define IDF_DB_TERMINATEDATABASE (IDF_FBASE + 523)
  1180.  
  1181.  
  1182. /***********************************************************************
  1183. ** Declaration of KAPPA data structures
  1184. ***********************************************************************/
  1185.  
  1186. /*  DEFINING ITEM TYPE */
  1187.         /* bit 1 through bit 4 define the struct type */
  1188. #define LIST            0x0000          /* 0000 0000 0000 0000 */
  1189. #define CLASS           0x0001          /* 0000 0000 0000 0001 */
  1190. #define OBJECT          0x0002          /* 0000 0000 0000 0010 */
  1191. #define METHOD          0x0003          /* 0000 0000 0000 0011 */
  1192. #define FUNC            0x0004          /* 0000 0000 0000 0100 */
  1193. #define RULE            0x0005          /* 0000 0000 0000 0101 */
  1194. #define GOAL            0x0006          /* 0000 0000 0000 0110 */
  1195. #define SLOT            0x0007          /* 0000 0000 0000 0111 */
  1196. #define OPTIONS         0x0008          /* 0000 0000 0000 1000 */
  1197. #define CFUNC           0x0009          /* 0000 0000 0000 1001 */
  1198. #define EXP             0x000a          /* 0000 0000 0000 1010 */
  1199. #define ATOMADT         0x000b          /* 0000 0000 0000 1011 */
  1200. #define VAR             0x000c          /* 0000 0000 0000 1100 */
  1201.         /* bit 5 through bit 8 reserved for future use */
  1202.  
  1203. #define LISTID  ITEMID
  1204. #define CLASSID ITEMID
  1205. #define OBJECTID ITEMID
  1206. #define METHODID ITEMID
  1207. #define FUNCID  ITEMID
  1208. #define RULEID  ITEMID
  1209. #define GOALID  ITEMID
  1210. #define SLOTID  ITEMID
  1211. #define CFUNCID ITEMID
  1212. #define EXPID   ITEMID
  1213. #define VARID   ITEMID
  1214.  
  1215.  
  1216. #define ITEM_FLAGS BYTE         /* GENERIC BYTE bitmask to define attributes */
  1217. /* The ITEM_FLAGS bits */
  1218. #define ITEMOPEN        0x01            /* 0000 0001 */
  1219. #define UNDELETABLE     0x02            /* 0000 0010 */
  1220. #define UNMODIFYABLE    0x06            /* 0000 0110 */
  1221. #define UNREADABLE      0x0e            /* 0000 1110 */
  1222. #define HIDDEN          0x10            /* 0001 0000 */
  1223.         /* bits 6, 7, and 8 reserved for future use */
  1224.  
  1225.         /************************
  1226.          *      EXPRESSION      *
  1227.          ************************/
  1228.         struct s_exp
  1229.                 {
  1230.                 BYTE            expFlags;       /* CAR type, etc.       */
  1231.                 WORD            next;           /* rel. position of CDR */
  1232.                 ITEMID          car;            /* id of CAR element    */
  1233.         };
  1234.  
  1235. typedef struct s_exp FAR * LPEXP;
  1236. #define ARGLIST LPEXP
  1237.  
  1238. typedef short  (*KAPPROC) (ARGLIST);
  1239. #define NULLPROC (KAPPROC)0
  1240.  
  1241. #define CAR(X)          (((struct s_exp FAR *)(X))->car)
  1242. #define CDR(X)          (((struct s_exp FAR *)(X))->next)
  1243. #define NEXT(X)         (((struct s_exp FAR *)(X))->next)
  1244. #define EXPFLAGS(X)     (((struct s_exp FAR *)(X))->expFlags)
  1245.         /* EXPFLAGS are below */
  1246. #define EXPNULL         0x00            /* 0000 0000 */
  1247. #define EXPATOM         0x01            /* 0000 0001 */
  1248. #define EXPNUMBER       0x02            /* 0000 0010 */
  1249. #define EXPBOOL         0x03            /* 0000 0011 */
  1250. #define EXPEXP          0x04            /* 0000 0100 */
  1251. #define EXPOBJECT       0x05            /* 0000 0101 */
  1252. #define EXPFUNC         0x06            /* 0000 0110 */
  1253. #define EXPRULE         0x07            /* 0000 0111 */
  1254. #define EXPGOAL         0x08            /* 0000 1000 */
  1255. #define EXPCLASS        0x09            /* 0000 1001 */
  1256. #define EXPCFUNC        0x0a            /* 0000 1010 */
  1257. #define EXPPAIR         0x0b            /* 0000 1011 */
  1258. #define EXPLIST         0x0c            /* 0000 1100 */
  1259.  
  1260. /** Flags and corresponding test macros **/
  1261. #define kADDMODE        0x00
  1262. #define kPERMMODE       0x00
  1263. #define kCHECKMODE      0x01
  1264. #define kDELETEMODE     0x02
  1265. #define kGETMODE        0x03
  1266. #define kSELECTMODE     0x04
  1267. #define kENUMMODE       0x05
  1268. #define kTEMPMODE       0x06
  1269. #define kINSERTMODE     0x07
  1270. #define kCOUNTMODE      0x08
  1271. #define kINDEXMODE      0x09
  1272. #define kAPPENDMODE     0x0A
  1273. #define kPOSITIONMODE   0x0B
  1274. #define kRELEASEMODE    0x0C
  1275. #define kAPPENDUMODE    0x0D
  1276. #define kCLEARMODE      0x0E
  1277. #define kNAMEMODE       0x0F
  1278. #define kPAIRMODE       0x10
  1279.  
  1280. /** Macros checking mode of operation **/
  1281. #define IS_ADD_MODE(wFlag)      (!wFlag)
  1282. #define IS_CHECK_MODE(wFlag)    (!(wFlag ^ kCHECKMODE))
  1283. #define IS_DELETE_MODE(wFlag)   (!(wFlag ^ kDELETEMODE))
  1284. #define IS_CLEAR_MODE(wFlag)    (!(wFlag ^ kCLEARMODE))
  1285. #define IS_GET_MODE(wFlag)      (!(wFlag ^ kGETMODE))
  1286. #define IS_SELECT_MODE(wFlag)   (!(wFlag ^ kSELECTMODE))
  1287. #define IS_ENUM_MODE(wFlag)     (!(wFlag ^ kENUMMODE))
  1288. #define IS_TEMP_MODE(wFlag)     (!(wFlag ^ kTEMPMODE))
  1289. #define IS_INSERT_MODE(wFlag)   (!(wFlag ^ kINSERTMODE))
  1290. #define IS_COUNT_MODE(wFlag)    (!(wFlag ^ kCOUNTMODE))
  1291. #define IS_INDEX_MODE(wFlag)    (!(wFlag ^ kINDEXMODE))
  1292. #define IS_APPEND_MODE(wFlag)   (!(wFlag ^ kAPPENDMODE))
  1293. #define IS_APPENDU_MODE(wFlag)  (!(wFlag ^ kAPPENDUMODE))
  1294. #define IS_POSITION_MODE(wFlag) (!(wFlag ^ kPOSITIONMODE))
  1295. #define IS_RELEASE_MODE(wFlag)  (!(wFlag ^ kRELEASEMODE))
  1296. #define IS_NAME_MODE(wFlag)     (!(wFlag ^ kNAMEMODE))
  1297. #define IS_PAIR_MODE(wFlag)     (!(wFlag ^ kPAIRMODE))
  1298.  
  1299. /** Item status flags and corresponding macros **/
  1300. #define kDELETED                 0x01
  1301. #define IS_ITEM_DELETED(wFlag)   (wFlag & kDELETED)
  1302. #define MARK_ITEM_DELETED(wFlag) (wFlag = (wFlag | kDELETED))
  1303.  
  1304. /**********************************************************************
  1305.         Number of LISTS
  1306.  
  1307.         NUM_LISTS       number of lists in a chunks
  1308.         NUM_LISTELEM    number of liste items in a list
  1309. **********************************************************************/
  1310. #define NUM_LISTS               100
  1311. #define NUM_LISTELEM            10
  1312.  
  1313. /**********************************************************************
  1314.         Number of EXPS
  1315.  
  1316.         kEXPCHUNK       size of each expression chunk
  1317. **********************************************************************/
  1318. #define kEXPCHUNK               5000
  1319.  
  1320. /**********************************************************************
  1321.         Number of ATOMs
  1322.  
  1323.         kSTRINGHASH is the size of the hash table
  1324.         kSTRINGCHUNK size of each string
  1325. **********************************************************************/
  1326. #define kSTRINGHASH             100      /* size of hash table */
  1327. #define kSTRINGCHUNK            500     /* size of each string chunk */
  1328.  
  1329. /*********************************************************************
  1330.         Item Numbers
  1331.  
  1332.         Each item chunk is initialized to allow NUM_item of objects.
  1333.         When adding (NUM_item + 1) items, a new chunk of size
  1334.         NUM_item is created.
  1335. *********************************************************************/
  1336. #define NUM_OBJECT              100
  1337. #define NUM_CLASS               100
  1338. #define NUM_RULE                50
  1339. #define NUM_METHOD              50
  1340. #define NUM_FUNC                100
  1341. #define NUM_GOAL                50
  1342. #define NUM_SLOT                500
  1343. #define NUM_OPTIONS             100
  1344. #define NUM_CFUNC               100
  1345. #define NUM_VAR                 100
  1346.  
  1347. /**********************************************************************
  1348.         Additional TYPEDEF's
  1349. **********************************************************************/
  1350. typedef unsigned char           BITS;
  1351.  
  1352. /**********************************************************************
  1353.         L O O P I N G 
  1354. **********************************************************************/
  1355.  
  1356.         /*************************/
  1357.         /**     LIST_LOOP       **/
  1358.         /*************************/
  1359. typedef struct {
  1360.         ITEMID          listId;
  1361.         GLOBALHANDLE    hCurrentChunk;
  1362.         GLOBALHANDLE    hNextChunk;
  1363.         WORD            wIndex;
  1364.         ITEMID          FAR *lpList;
  1365.         BOOL            bFlags;
  1366.         } LIST_LOOP;
  1367.  
  1368. typedef LIST_LOOP       FAR *LISTLOOP;
  1369. #define SIZE_LISTLOOP   (sizeof (LIST_LOOP))
  1370. #define INUSE           0x01
  1371. #define WIRED           0x02
  1372.  
  1373. GLOBALHANDLE InitListLoop (ITEMID, LISTLOOP FAR *);
  1374. ITEMID NextElement (LISTLOOP);
  1375.  
  1376. /**********************************************************************
  1377.         L I S T         L O O P         Macros
  1378. **********************************************************************/
  1379. /******************************
  1380.  INIT_LIST_LOOP: initializes the list loop struct.  Need
  1381.         to call before starting loop on list.
  1382. ******************************/
  1383. #define INIT_LIST_LOOP(listId,hLoop,lpLoop)     \
  1384.                 hLoop = InitListLoop(listId, (LISTLOOP FAR *)&lpLoop)
  1385.  
  1386. /******************************
  1387.  NEXT_ELEMENT: returns the next list element.  Returns the next itemId.
  1388.         If itemId is zero, loop has terminated.
  1389. ******************************/
  1390. ITEMID NEXT_LIST_ELEMENT(LISTLOOP);
  1391.  
  1392. /******************************
  1393.  RELEASE_LIST_LOOP: Unlocks any locked chunks and frees loop struct.
  1394. ******************************/
  1395. int RELEASE_LIST_LOOP(GLOBALHANDLE,LISTLOOP);
  1396.  
  1397.  
  1398. /**********************************************************************
  1399.         Interface Functions
  1400. **********************************************************************/
  1401. /* initialize routines in kappa.c */
  1402. int FAR PASCAL WinMain (HANDLE, HANDLE, LPSTR, int);
  1403. void InitNewApplication (void);
  1404. void InitOpenApplication (void);
  1405. WORD KappaInit (WORD, HANDLE, HANDLE, LPSTR, int);
  1406. int  KappaLoad (WORD, LPSTR);
  1407.  
  1408. /**    item.c  **/
  1409. WORD    Init_Items (void);
  1410. short   Clear_Items (void);
  1411. ITEMID  Add_Item (WORD, LPSTR FAR *);
  1412. WORD    Check_Item (WORD, ITEMID);
  1413. LPSTR   Get_Item (WORD, ITEMID);
  1414. ITEMID  Copy_Item (WORD, ITEMID, LPSTR FAR *);
  1415. WORD    Delete_Item (WORD, ITEMID);
  1416. WORD    Release_Item (WORD, ITEMID);
  1417. ITEMID  Select_Item (WORD, LPSTR FAR *, WORD (FAR *)(), LPSTR);
  1418. void    Enum_Item (WORD, WORD (FAR *)(), LPSTR);
  1419. WORD    Count_Item (WORD);
  1420. ATOMID  _GetItemDesc (WORD, ITEMID);
  1421. ATOMID  _SetItemDesc (WORD, ITEMID, ATOMID);
  1422.  
  1423.  /**    exp.c   **/
  1424. WORD    Init_Exps (void);
  1425. short   Clear_Exps (void);
  1426. EXPID   Make_Exp (WORD, LPSTR FAR *, BITS);
  1427. LPSTR   Get_Exp (EXPID, WORD *);
  1428. WORD    Check_Exp (EXPID, WORD *);
  1429. WORD    Delete_Exp (EXPID);
  1430. WORD    Release_Exp (EXPID);
  1431. ITEMID  Copy_Exp (EXPID, LPSTR FAR *, BITS);
  1432. GLOBALHANDLE MakeTempExp( WORD, LPLPSTR );
  1433. WORD    ReleaseTempExp( GLOBALHANDLE, short );
  1434. WORD    ReleaseAllTempExp (void);
  1435.  
  1436. /********************************************
  1437.  *  Expression handling
  1438.  ********************************************/
  1439.  
  1440. #define TEMP_EXP_SIZE      900
  1441. #define GETCAR(X,A,L)      Get_AtomName(CAR(X),(LPSTR)A,L)
  1442. #define SETCAR(X,A)        CAR(X)=Add_Atom((LPSTR)A),EXPFLAGS(X)=EXPATOM
  1443.  
  1444. WORD _PrintSyntax( FILE *, HWND, LPSTR, LPWORD, WORD, LPEXP, WORD );
  1445.  
  1446. WORD FillExpNew  ( LPEXP, WORD, FILE *, LPSTR, LPWORD, WORD, LPWORD );
  1447. WORD _ExpToWndStr (LPSTR, LPEXP, WORD, WORD);
  1448. WORD ExpToWndStr (LPSTR, EXPID, WORD, WORD);
  1449. WORD _PrintExp (HWND, FILE *, LPEXP, WORD);
  1450. WORD _PrintExp1 (HWND, FILE *, LPEXP, WORD);
  1451. WORD PrintExp( HWND, FILE *, EXPID, WORD);
  1452. WORD PrintExp1( HWND, FILE *, EXPID, WORD);
  1453. void _PrintVarList (HWND, LISTID);
  1454. void SaveAllVars (HWND, FILE *, LISTID);
  1455.  
  1456. WORD CalculateExpSize( LPSTR, LPWORD );
  1457. WORD FillExp( LPEXP, LPSTR, LPWORD );
  1458. WORD CheckExp( LPSTR, LPWORD );
  1459. WORD Exp_Len (EXPID);
  1460. BOOL CatExp (EXPID, EXPID, WORD);
  1461. WORD SubExp_Len (LPEXP, WORD);
  1462. void _CopySubExp (LPEXP, WORD, WORD, LPEXP);
  1463. EXPID CopySubExp (LPEXP, WORD, WORD);
  1464. LPEXP CopyTempSubExp (LPEXP, WORD, WORD, GLOBALHANDLE FAR *);
  1465. LPEXP CopyTempExp (EXPID, GLOBALHANDLE FAR *);
  1466. short EvalExp (EXPID);
  1467. EXPID JoinIfThen (EXPID, EXPID);
  1468. BOOL ClearVarList (LISTID);
  1469. BOOL __BindVars (LISTID, LPEXP, WORD);
  1470. BOOL BindVars (LISTID, EXPID);
  1471. ITEMID __CopyVar (VARID, OBJECTID);
  1472. void ___LoadArgs (LPEXP, LISTID, LPEXP);
  1473. void __LoadArgs (LPEXP, LISTID, LISTID);
  1474. void _LoadArgs (EXPID, LISTID, LPEXP);
  1475. void LoadArgs (EXPID, LISTID, LISTID);
  1476.  
  1477. LISTID BuildList (LPSTR);
  1478. LISTID BuildVarList (LPSTR, LISTID FAR *);
  1479. EXPID BuildExp (LPSTR);
  1480. LPEXP _BuildTempExp (LPSTR, GLOBALHANDLE FAR *, BYTE);
  1481. LPEXP BuildTempExp (LPSTR, GLOBALHANDLE FAR *);
  1482. WORD CheckExp (LPSTR, LPWORD);
  1483. BOOL CheckSilentExp (LPSTR);
  1484. SHORT CheckParen (LPSTR, char);
  1485.  
  1486. /**    list.c  **/
  1487. WORD    Init_Lists (void);
  1488. short   Clear_Lists (void);
  1489. LISTID  Make_List (WORD);
  1490. WORD    Delete_List (LISTID);
  1491. WORD    Release_List (LISTID);
  1492. LISTID  Copy_List (LISTID, BITS);
  1493. WORD    Check_List (LISTID, WORD *);
  1494. WORD    Delete_Elem (LISTID, ITEMID, BITS);
  1495. WORD    Append_Elem (LISTID, ITEMID);
  1496. WORD    AppendU_Elem (LISTID, ITEMID);
  1497. WORD    Insert_Elem (LISTID, ITEMID, ITEMID, BITS);
  1498. ITEMID  Get_Elem (LISTID, WORD);
  1499. WORD    Get_ElemPos (LISTID, ITEMID);
  1500. WORD    Append_ElemPair (LISTID idList, ITEMID idKey, ITEMID idData);
  1501. WORD    Delete_ElemPair (LISTID idList, ITEMID idKey);
  1502. ITEMID  Get_ElemPair (LISTID idList, ITEMID idKey);
  1503. WORD    Replace_PairKey (LISTID idList, ITEMID idOldKey, ITEMID idNewKey);
  1504.  
  1505.  /**    atom.c  **/
  1506. WORD    Init_AtomTable (WORD);
  1507. short   Clear_AtomTable (void);
  1508. WORD    Get_AtomName (ITEMID, LPSTR, WORD);
  1509. ATOMID  Add_Atom (LPSTR);
  1510. ATOMID  Check_Atom (LPSTR);
  1511. WORD    Delete_Atom (ATOMID);
  1512. short   DumpAtomTable (HANDLE);
  1513. short   RestoreAtomTable (HANDLE);
  1514.  
  1515.  /**    adt.c  **/
  1516. WORD    Init_Adt (void);
  1517. LONG    WriteAdtSaveBuf (HANDLE, WORD, WORD, WORD);
  1518. WORD    ReadAdtSaveBuf (HANDLE, WORD *, WORD *, WORD *);
  1519. WORD    Clear_Adt (void);
  1520. WORD    Save_Adt (HANDLE);
  1521. WORD    Restore_Adt (HANDLE);
  1522.  
  1523.  
  1524.  
  1525. /* item */
  1526. WORD SelectByName (LPSTR, LPSTR);
  1527. ITEMID _GetItem (WORD, ATOMID);
  1528. ATOMID GetItemName (ITEM_FLAGS, ITEMID);
  1529. WORD   _RenameItem (ITEM_FLAGS, ITEMID, ITEMID);
  1530.  
  1531. /* Returns the product version in ATOMID form */
  1532. ATOMID GetKAPPAVersionID ();
  1533.  
  1534. /**********/
  1535. /* OBJECT */
  1536. /**********/
  1537. OBJECTID _MakeObject( ITEMID, CLASSID );
  1538. ATOMID   _DeleteCO (WORD, ITEMID);
  1539. #define MakeObject( ObjName, ClassName ) \
  1540.                 _MakeObject( ObjName, GetClass( ClassName ) )
  1541. #define GETOBJECT( ObjName )  _GetItem( OBJECT, ObjName )
  1542. #define DELETEOBJECT( ObjName )  _DeleteCO( OBJECT, GETOBJECT( ObjName ) )
  1543. #define SetObjectInfo( ObjectName, idDesc )     \
  1544.         _SetItemDesc ( OBJECT, GETOBJECT (ObjectName), idDesc )
  1545. #define GetObjectInfo( ObjectName )     \
  1546.         _GetItemDesc ( OBJECT, GETOBJECT (ObjectName) )
  1547. #define RenameObject( ObjectName, NewName )     \
  1548.         _RenameItem ( OBJECT, GETOBJECT (ObjectName), NewName )
  1549. WORD SaveAllObjects (FILE *);
  1550. #define WriteAllObjects(file)           SaveAllObjects (file)
  1551. WORD SaveObject (OBJECTID, FILE *);
  1552. #define WriteObject(idObjName,file)     SaveObject (GETOBJECT(idObjName),file)
  1553. ATOMID MakeIntoObject (ATOMID);
  1554.  
  1555. /*********/
  1556. /* CLASS */
  1557. /*********/
  1558. CLASSID _MakeClass( ITEMID, CLASSID );
  1559. #define GetClass( ClassName )  _GetItem( CLASS, ClassName )
  1560. #define MakeClass( ClassName, SuperName ) \
  1561.                 _MakeClass( ClassName, GetClass( SuperName ) )
  1562. #define DeleteClass( ClassName )  _DeleteCO( CLASS, GetClass( ClassName ) )
  1563. #define SetClassInfo( ClassName, idDesc )       \
  1564.         _SetItemDesc ( CLASS, GetClass (ClassName), idDesc )
  1565. #define GetClassInfo( ClassName ) _GetItemDesc ( CLASS, GetClass (ClassName) )
  1566. #define RenameClass( ClassName, NewName )      \
  1567.         _RenameItem ( CLASS, GetClass (ClassName), NewName )
  1568. WORD SaveAllClasses (FILE *, CLASSID);
  1569. #define WriteAllClasses(file,idClassName) SaveAllClasses (file,idClassName)
  1570. WORD SaveClass (CLASSID, FILE *);
  1571. #define WriteClass(idClassName,file)    SaveClass (GetClass(idClassName),file)
  1572. ATOMID MakeIntoClass (ATOMID);
  1573.  
  1574. /* inheritance */
  1575. WORD    IsAKindOf( ITEMID, ITEMID );
  1576. WORD    _Is_AKindOf( WORD, ITEMID, ITEMID );
  1577. #define _IsObjectAKindOf( Obj, Class )  _Is_AKindOf( OBJECT, Obj, Class )
  1578. #define _IsClassAKindOf( Obj, Class )  _Is_AKindOf( CLASS, Obj, Class )
  1579. ATOMID GetSuper (ATOMID);
  1580.  
  1581. /************/
  1582. /* FUNCTION */
  1583. /************/
  1584. FUNCID  _MakeFunc( ITEMID, LISTID, EXPID );
  1585. ATOMID  _DeleteFunc( FUNCID );
  1586. #define MakeFunc( FuncName, VarList, Body ) \
  1587.                 _MakeFunc( FuncName, VarList, Body )
  1588. #define MakeFunction( FuncName, VarList, Body ) \
  1589.                 _MakeFunc( FuncName, VarList, Body )
  1590. #define GetFunc( FuncName )  _GetItem( FUNC, FuncName )
  1591. #define GetFunction( FuncName )  _GetItem( FUNC, FuncName )
  1592. #define DeleteFunc( FuncName )  _DeleteFunc( GetFunc( FuncName ) )
  1593. #define DeleteFunction( FuncName )      _DeleteFunc( GetFunc( FuncName ) )
  1594. #define SetFunctionInfo( idName, idDesc ) \
  1595.                 _SetItemDesc ( FUNC, GetFunc (idName), idDesc )
  1596. #define GetFunctionInfo( idName ) \
  1597.                 _GetItemDesc ( FUNC, GetFunc (idName) )
  1598. #define RenameFunction( FuncName, NewName )    \
  1599.         _RenameItem ( FUNC, GetFunc (FuncName), NewName )
  1600. #define EvalFunction(idFuncName,idArgList)      \
  1601.         EvalFunc ( GetFunc (idFuncName), idArgList )
  1602. WORD SaveAllFuncs (FILE *);
  1603. #define WriteAllFunctions(file)         SaveAllFuncs (file)
  1604. WORD SaveFunc (FUNCID, FILE *);
  1605. #define WriteFunction(idFuncName,file)  SaveFunc(GetFunc(idFuncName),file)
  1606.  
  1607. /********/
  1608. /* RULE */
  1609. /********/
  1610. RULEID  _MakeRule( ITEMID, LISTID, LISTID, EXPID, EXPID );
  1611. BOOL    _SetRulePriority( RULEID, short );
  1612. BOOL    _DeleteRule( RULEID );
  1613. #define MakeRule( RuleName, VarList, ClassList, IfPart, ThenPart ) \
  1614.                 _MakeRule( RuleName, VarList, ClassList, IfPart, ThenPart )
  1615. #define SetRulePriority( RuleName, Priority ) \
  1616.                 _SetRulePriority( GetRule( RuleName ), (Priority) )
  1617. #define GetRule( RuleName )  _GetItem( RULE, RuleName )
  1618. #define DeleteRule( RuleName )  _DeleteRule( GetRule( RuleName ) )
  1619. #define SetRuleInfo( idName, idDesc ) \
  1620.                 _SetItemDesc ( RULE, GetRule (idName), idDesc )
  1621. #define GetRuleInfo( idName ) \
  1622.                 _GetItemDesc ( RULE, GetRule (idName) )
  1623. #define RenameRule( RuleName, NewName )        \
  1624.         _RenameItem ( RULE, GetRule (RuleName), NewName )
  1625. WORD SaveAllRules (FILE *);
  1626. #define WriteAllRules(file)             SaveAllRules (file)
  1627. WORD SaveRule (RULEID, FILE *);
  1628. #define WriteRule(idRuleName,file)      SaveRule (GetRule(idRuleName),file)
  1629. void SetValueInferenceHook (ATOMID, ATOMID, ATOMID, WORD);
  1630. ATOMID g_reset_forward_chain (LPEXP);
  1631.  
  1632. /********/
  1633. /* GOAL */
  1634. /********/
  1635. GOALID  _MakeGoal( ITEMID, EXPID );
  1636. ATOMID  _DeleteGoal( GOALID );
  1637. #define MakeGoal( GoalName, Body )  _MakeGoal( GoalName, Body )
  1638. #define SetGoalPriority( GoalName, Priority ) \
  1639.                 _SetGoalPriority( GetGoal( GoalName ), Priority )
  1640. #define GetGoal( GoalName )  _GetItem( GOAL, GoalName )
  1641. #define DeleteGoal( GoalName )  _DeleteGoal( GetGoal( GoalName ) )
  1642. #define SetGoalInfo( idName, idDesc ) \
  1643.                 _SetItemDesc ( GOAL, GetGoal (idName), idDesc )
  1644. #define GetGoalInfo( idName ) \
  1645.                 _GetItemDesc ( GOAL, GetGoal (idName) )
  1646. #define RenameGoal( GoalName, NewName )        \
  1647.         _RenameItem ( GOAL, GetGoal (GoalName), NewName )
  1648. WORD SaveAllGoals (FILE *);
  1649. #define WriteAllGoals(file)             SaveAllGoals (file)
  1650. WORD SaveGoal (GOALID, FILE *);
  1651. #define WriteGoal(idGoalName,file)      SaveGoal (GetGoal(idGoalName),file)
  1652. BOOL TestGoal (GOALID);
  1653.  
  1654. /* slot */
  1655. ITEMID  __CopySlot( ITEMID );
  1656. WORD    __DeleteSlot( ITEMID, LPSTR );
  1657. SLOTID  MakeSlot( ITEMID, ITEMID );
  1658. SLOTID  MakeSlotHidden( ITEMID, ITEMID );
  1659. SLOTID  _Make_Slot( WORD, ITEMID, ITEMID );
  1660. WORD    DeleteSlot( ITEMID, ITEMID );
  1661. WORD    _Delete_Slot( WORD, ITEMID, ITEMID );
  1662. SLOTID  CopySlot( ITEMID, ITEMID );
  1663. SLOTID  _Copy_Slot( WORD, ITEMID, ITEMID );
  1664. SLOTID  GetSlot( ITEMID, ITEMID );
  1665. SLOTID  _Get_Slot( WORD, ITEMID, ITEMID );
  1666. ITEMID  Get_InheritedSlotNames( LPSTR );
  1667. WORD RenameSlot( ITEMID, ITEMID, ITEMID );
  1668. ATOMID SetSlotDesc (ATOMID, ATOMID, ATOMID);
  1669. #define SetSlotInfo( idObjName, idSlotName, idDesc )   \
  1670.                 SetSlotDesc ( idObjName, idSlotName, idDesc )
  1671. ATOMID GetSlotDesc (ATOMID, ATOMID);
  1672. #define GetSlotInfo( idObjName, idSlotName )   \
  1673.                 GetSlotDesc ( idObjName, idSlotName )
  1674.  
  1675. /* value */
  1676. ITEMID  GetSlotValue( ITEMID, ITEMID );
  1677. ITEMID  _Get_SlotValue( WORD, ITEMID, ITEMID );
  1678. ITEMID  SetSlotValue( ITEMID, ITEMID, ITEMID, WORD );
  1679. ITEMID  _Set_SlotValue( WORD, ITEMID, ITEMID, ITEMID, ITEMID, WORD );
  1680.  
  1681. /**********/
  1682. /* METHOD */
  1683. /**********/
  1684. ITEMID  __CopyMethod( ITEMID, ITEMID );
  1685. WORD    __DeleteMethod( ITEMID, LPSTR );
  1686.  
  1687. METHODID  MakeMethod( ITEMID, ITEMID, ITEMID, ITEMID );
  1688. METHODID  _Make_Method( WORD, ITEMID, ITEMID, ITEMID, ITEMID );
  1689. ATOMID    DeleteMethod( ITEMID, ITEMID );
  1690. WORD      _Delete_Method( WORD, ITEMID, ITEMID );
  1691. METHODID  CopyMethod( ITEMID, ITEMID );
  1692. METHODID  _Copy_Method( WORD, ITEMID, ITEMID );
  1693. METHODID  GetMethod( ITEMID, ITEMID );
  1694. METHODID  _Get_Method( WORD, ITEMID, ITEMID );
  1695. WORD      EvalMethod( ITEMID, ITEMID, ITEMID );
  1696. WORD      _Eval_Method( WORD, ITEMID, ITEMID, ITEMID );
  1697. ITEMID    Get_InheritedMethodNames ( LPSTR );
  1698. ATOMID    SetMethodDesc (ATOMID, ATOMID, ATOMID);
  1699. #define SetMethodInfo(idObjName,idMethodName,idInfo)    \
  1700.                 SetMethodDesc ( idObjName, idMethodName, idInfo )
  1701. ATOMID GetMethodDesc (ATOMID, ATOMID);
  1702. #define GetMethodInfo(idObjName,idMethodName)           \
  1703.                 GetMethodDesc ( idObjName, idMethodName )
  1704. WORD RenameMethod (ITEMID, ITEMID, ITEMID);
  1705.  
  1706.  
  1707. /********/
  1708. /* LIST */
  1709. /********/
  1710. WORD List_Len( LISTID );
  1711. BOOL ClearList( LISTID, WORD );
  1712. LISTID DeepListCopy( LISTID, ITEMID (FAR *)(), ITEMID );
  1713. void EnumList( LISTID, WORD (FAR *)(), LPSTR );
  1714. ITEMID SelectElem( LISTID, WORD (FAR *)(), LPSTR );
  1715. #define _CopyList(OldListID) Copy_List(OldListID, kPERMMODE)
  1716.  
  1717. /************/
  1718. /* UI Stuff */
  1719. /************/
  1720. ATOMID AfromT (WORD);
  1721. void AskUser (ATOMID, ATOMID, LPSTR, WORD, LPSTR);
  1722. short ExplainPair (ATOMID, ATOMID, WORD);
  1723. BOOL IsNumber (PSTR);
  1724. ATOMID KappaPostInputForm (WORD wOpt, ATOMID idTitle, WORD wLen, ...);
  1725. ATOMID KappaPostMenu (ATOMID idTitle, WORD wLen, ...);
  1726. ATOMID KappaPostMultipleSelection (ATOMID idTitle, ATOMID idObjName,
  1727.                                    ATOMID idSlotName, WORD wLen, ...);
  1728. ATOMID PrintHierarchy (ATOMID);
  1729. WORD GetWordFromFile (FILE *, LPSTR, WORD);
  1730. ATOMID SetPostMessageTitle (ATOMID);
  1731. int WriteTreeOnFile (ATOMID, FILE *);
  1732.  
  1733. /* Constants for mode of argument evaluation */
  1734. #define NO_EVAL_ARGS    1
  1735. #define EVAL_ARGS       0
  1736.  
  1737. /*
  1738. **      registering and posting errors
  1739. */
  1740. void PostKappaErrorMessage (void);
  1741. void ClearTraceStack (void);
  1742. WORD RegisterKappaMessage (WORD, ATOMID, ATOMID, ATOMID);
  1743.  
  1744. /**********************************************************************
  1745.        Macros for ShowSubNodes of Browser
  1746. **********************************************************************/
  1747. #define BR_MAKEVISIBLE          1
  1748. #define BR_MAKEINVISIBLE        2
  1749. #define BR_TOGGLE               3
  1750.  
  1751. /*********************************************************************/
  1752. /* KAL function definitions                                          */
  1753. /*********************************************************************/
  1754. KAPPROC GetKappaFunction (ITEMID, WORD *);
  1755. void    build_function (LPSTR, KAPPROC, BYTE, BYTE);
  1756. #define Register_Function(name,fcn,eval,type)        \
  1757.     build_function ( (LPSTR)name, (KAPPROC)fcn, (BYTE)eval, (BYTE)type )
  1758.  
  1759. /**********************************************************************
  1760.         Macros for different function categories
  1761. **********************************************************************/
  1762. #define CAT_KNOW        0x01
  1763. #define CAT_MATH        0x02
  1764. #define CAT_STR         0x03
  1765. #define CAT_LST         0x04
  1766. #define CAT_LOG         0x05
  1767. #define CAT_FILE        0x06
  1768. #define CAT_CONS        0x07
  1769. #define CAT_USER        0x08
  1770. #define CAT_WND         0x09
  1771. #define CAT_MISC        0x0b
  1772. #define CAT_NONE        0x0e
  1773. #define CAT_ALL         0x0f
  1774.  
  1775. /**********************************************************************
  1776.         Macros for return types
  1777. **********************************************************************/
  1778. #define RET_STR         0x10
  1779. #define RET_NUM         0x20
  1780. #define RET_BOOL        0x30
  1781. #define RET_OBJ         0x40
  1782. #define RET_CLA         0x50
  1783. #define RET_FUN         0x60
  1784. #define RET_LST         0x70            /* returns a list */
  1785. #define RET_ATM         0x80            /* returns an atom */
  1786. #define RET_NONE        0xe0
  1787. #define RET_ALL         0xf0
  1788.  
  1789. /**********************************************************************
  1790.         Macros for making catagories
  1791. **********************************************************************/
  1792. #define CAT_TYPE                        0x0f
  1793. #define RET_TYPE                        0xf0
  1794. #define GET_CATEGORY(x)                 (BYTE) (((BYTE)(x)) & CAT_TYPE)
  1795. #define GET_RETURN(x)                   (BYTE) (((BYTE)(x)) & RET_TYPE)
  1796. #define MAKE_WORD(a,b)  ((WORD) ( (((WORD) (b)) << 8) | ((BYTE) (a)) ))
  1797.  
  1798.  
  1799. /**********************************************************************
  1800.         Mark as System functions.
  1801. **********************************************************************/
  1802. WORD _Mark_SystemItem (WORD, ITEMID, BOOL);
  1803. WORD MarkSystemSlot (ATOMID, ATOMID);
  1804. WORD MarkSystemMethod (ATOMID, ATOMID);
  1805. #define KappaMarkSystemClass(idClassName)    \
  1806. (_Mark_SystemItem (CLASS, GetClass(idClassName), TRUE) ? idClassName : NULLID)
  1807. #define KappaMarkSystemRule(idRuleName)      \
  1808. (_Mark_SystemItem (RULE, GetRule(idRuleName), TRUE) ? idRuleName : NULLID)
  1809. #define KappaMarkSystemGoal(idGoalName)      \
  1810. (_Mark_SystemItem (GOAL, GetGoal(idGoalName), TRUE) ? idGoalName : NULLID)
  1811. #define KappaMarkSystemFunc(idFuncName)      \
  1812. (_Mark_SystemItem (FUNC, GetFunc(idFuncName), TRUE) ? idFuncName : NULLID)
  1813. #define KappaMarkSystemInstance(idObjName)   \
  1814. (_Mark_SystemItem (OBJECT, GETOBJECT(idObjName), TRUE) ? idObjName : NULLID)
  1815. #define KappaMarkSystemSlot(idObjName,idSlotName) \
  1816.   MarkSystemSlot (idObjName, idSlotName)    
  1817. #define KappaMarkSystemMethod(idObjName,idMethName) \
  1818.   MarkSystemMethod (idObjName, idMethName)
  1819.  
  1820. /*************************************************************************/
  1821. /* Conversion functions                                                  */
  1822. /*************************************************************************/
  1823. #define KAPPA_ATOMTYPE          1
  1824. #define KAPPA_LISTTYPE          2
  1825. #define KAPPA_EXPTYPE           3
  1826. #define KAPPA_STRINGTYPE        4
  1827. #define KAPPA_DOUBLETYPE        5
  1828. #define KAPPA_FLOATTYPE         6
  1829. #define KAPPA_INTTYPE           7
  1830. #define KAPPA_LONGTYPE          8
  1831.  
  1832. /* ATOMID to C-variables */
  1833. WORD _KappaGetAtom (ATOMID, BYTE, LPSTR, WORD);
  1834.  
  1835. /* Temp declaration */
  1836. short    sKappaTmpShort;
  1837. WORD     wKappaTmpWord;
  1838. LISTID   idKappaTmpList;
  1839.  
  1840. /**************************************
  1841. WORD KappaGetString (IdString, Buffer, BufferSize);
  1842. ***************************************/
  1843. #define KappaGetString(atm,x,y)                 \
  1844.         _KappaGetAtom (atm, KAPPA_STRINGTYPE, (LPSTR)(x), (WORD) y)
  1845. /**************************************
  1846. WORD KappaGetDouble (IdDouble, DoubleVar);
  1847. ***************************************/
  1848. #define KappaGetDouble(atm,x)                   \
  1849.         _KappaGetAtom (atm, KAPPA_DOUBLETYPE, (LPSTR)&(x), 0)
  1850. /**************************************
  1851. WORD KappaGetFloat (IdFloat, FloatVar);
  1852. ***************************************/
  1853. #define KappaGetFloat(atm,x)                    \
  1854.         _KappaGetAtom (atm, KAPPA_FLOATTYPE, (LPSTR)&(x), 0)
  1855. /**************************************
  1856. WORD KappaGetInt (IdInt, IntVar);
  1857. ***************************************/
  1858. #define KappaGetInt(atm,x)                      \
  1859.         _KappaGetAtom (atm, KAPPA_INTTYPE, (LPSTR)&(x), 0)
  1860. /**************************************
  1861. WORD KappaGetLong (IdLong, LongVar);
  1862. ***************************************/
  1863. #define KappaGetLong(atm,x)                      \
  1864.         _KappaGetAtom (atm, KAPPA_LONGTYPE, (LPSTR)&(x), 0)
  1865.  
  1866. /* C-variables to ATOMID */
  1867. ATOMID _KappaMakeAtom (BYTE, LPSTR, LONG, double);
  1868.  
  1869. /*************************************
  1870. WORD KappaMakeString (null_terminated_string);
  1871. **************************************/
  1872. #define KappaMakeString(x)                      \
  1873.         _KappaMakeAtom (KAPPA_STRINGTYPE, (LPSTR)x, 0L, (double)0.0 )
  1874. /*************************************
  1875. WORD KappaMakeDouble (DoubleVar);
  1876. **************************************/
  1877. #define KappaMakeDouble(x)                      \
  1878.         _KappaMakeAtom (KAPPA_DOUBLETYPE, LPNULL, 0L, (double)x)
  1879. /*************************************
  1880. WORD KappaMakeFloat (FloatVar);
  1881. **************************************/
  1882. #define KappaMakeFloat(x)                       \
  1883.         _KappaMakeAtom (KAPPA_FLOATTYPE, LPNULL, 0L, (double)x )
  1884. /*************************************
  1885. WORD KappaMakeInt (IntVar);
  1886. **************************************/
  1887. #define KappaMakeInt(x)                 \
  1888.         _KappaMakeAtom (KAPPA_INTTYPE, LPNULL, (LONG)x, (double)0.0 )
  1889. /*************************************
  1890. WORD KappaMakeLong (LongVar);
  1891. **************************************/
  1892. #define KappaMakeLong(x)                 \
  1893.         _KappaMakeAtom (KAPPA_LONGTYPE, LPNULL, (LONG)x, (double)0.0 )
  1894.  
  1895. /* SLOTS to C variables */
  1896. ATOMID  GetValue (ATOMID, ATOMID);
  1897. LISTID  GetListValue (ATOMID, ATOMID);
  1898.  
  1899. /*************************************
  1900. WORD KappaGetSlotString (idObjName, idSlotName, Buffer, BufferSize);
  1901. **************************************/
  1902. #define KappaGetSlotString(obj,slot,x,y)        \
  1903.         KappaGetString (GetValue (obj, slot), x, y)
  1904. /*************************************
  1905. WORD KappaGetSlotDouble (idObjName, idSlotName, DoubleVar);
  1906. **************************************/
  1907. #define KappaGetSlotDouble(obj,slot,x)          \
  1908.         KappaGetDouble (GetValue (obj, slot), x)
  1909. /*************************************
  1910. WORD KappaGetSlotFloat (idObjName, idSlotName, FloatVar);
  1911. **************************************/
  1912. #define KappaGetSlotFloat(obj,slot,x)           \
  1913.         KappaGetFloat (GetValue (obj, slot), x)
  1914. /*************************************
  1915. WORD KappaGetSlotInt (idObjName, idSlotName, IntVar);
  1916. **************************************/
  1917. #define KappaGetSlotInt(obj,slot,x)             \
  1918.         KappaGetInt (GetValue (obj, slot), x)
  1919. /*************************************
  1920. WORD KappaGetSlotLong (idObjName, idSlotName, LongVar);
  1921. **************************************/
  1922. #define KappaGetSlotLong(obj,slot,x)             \
  1923.         KappaGetLong( GetValue( obj, slot ), x)
  1924.  
  1925. /* Set Slot from C variables */
  1926. WORD    SetValue (ATOMID, ATOMID, ATOMID);
  1927. WORD    SetListValue (ATOMID, ATOMID, LISTID);
  1928.  
  1929. /*************************************
  1930. WORD KappaSetSlotString (idObjName, idSlotName, Null_Terminated_String);
  1931. **************************************/
  1932. #define KappaSetSlotString(obj,slot,x)  \
  1933.         SetValue (obj, slot, KappaMakeString (x))
  1934. /*************************************
  1935. WORD KappaSetSlotDouble (idObjName, idSlotName, DoubleVar);
  1936. **************************************/
  1937. #define KappaSetSlotDouble(obj,slot,x)          \
  1938.         SetValue (obj, slot, KappaMakeDouble (x))
  1939. /*************************************
  1940. WORD KappaSetSlotFloat (idObjName, idSlotName, FloatVar);
  1941. **************************************/
  1942. #define KappaSetSlotFloat(obj,slot,x)           \
  1943.         SetValue (obj, slot, KappaMakeFloat (x))
  1944. /*************************************
  1945. WORD KappaSetSlotInt (idObjName, idSlotName, IntVar);
  1946. **************************************/
  1947. #define KappaSetSlotInt(obj,slot,x)             \
  1948.         SetValue (obj, slot, KappaMakeInt(x))
  1949. /*************************************
  1950. WORD KappaSetSlotLong( idObjName, idSlotName, LongVar );
  1951. **************************************/
  1952. #define KappaSetSlotLong(obj,slot,x)             \
  1953.         SetValue( obj, slot, KappaMakeLong( x ))
  1954.  
  1955. /* Get C-Kappa variables from argument list (LPEXP) */
  1956. WORD    KappaArgCount (ARGLIST);
  1957. ATOMID  KappaGetNthArg (ARGLIST, WORD, BYTE);
  1958.  
  1959. /*************************************
  1960. LPEXP KappaGetArgExp (ArgList, pos);
  1961. **************************************/
  1962. LPEXP   KappaGetArgExp (ARGLIST, WORD);
  1963.  
  1964. /*************************************
  1965. WORD KappaGetArgAtom (ArgList, pos, AtomIdVar);
  1966. **************************************/
  1967. #define KappaGetArgAtom(exp,n,x)        \
  1968.         (x = (ATOMID) KappaGetNthArg (exp, n, KAPPA_ATOMTYPE))
  1969. /*************************************
  1970. WORD KappaGetArgList (ArgList, pos, ListIdVar);
  1971. **************************************/
  1972. #define KappaGetArgList(exp,n,x)        \
  1973.         (x = (LISTID) KappaGetNthArg (exp, n, KAPPA_LISTTYPE))
  1974. /*************************************
  1975. WORD KappaGetArgString (ArgList, pos, Buffer, BufferSize);
  1976. **************************************/
  1977. #define KappaGetArgString(exp,n,x,y)            \
  1978.         KappaGetString (KappaGetNthArg (exp, n, KAPPA_ATOMTYPE), x, y)
  1979. /*************************************
  1980. WORD KappaGetArgDouble (ArgList, pos, DoubleVar);
  1981. **************************************/
  1982. #define KappaGetArgDouble(exp,n,x)              \
  1983.         KappaGetDouble (KappaGetNthArg (exp, n, KAPPA_ATOMTYPE), x)
  1984. /*************************************
  1985. WORD KappaGetArgFloat (ArgList, pos, FloatVar);
  1986. **************************************/
  1987. #define KappaGetArgFloat(exp,n,x)               \
  1988.         KappaGetFloat (KappaGetNthArg (exp, n, KAPPA_ATOMTYPE), x)
  1989. /*************************************
  1990. WORD KappaGetArgInt (ArgList, pos, IntVar);
  1991. **************************************/
  1992. #define KappaGetArgInt(exp,n,x)                 \
  1993.         KappaGetInt (KappaGetNthArg (exp, n, KAPPA_ATOMTYPE), x)
  1994. /*************************************
  1995. WORD KappaGetArgLong (ArgList, pos, LongVar);
  1996. **************************************/
  1997. #define KappaGetArgLong(exp,n,x)                 \
  1998.         KappaGetLong( KappaGetNthArg( exp, n, KAPPA_ATOMTYPE ), x)
  1999.  
  2000. /*********************************************************************
  2001. ** Definition of Macros for returning values                        **
  2002. ** extern LONG    KappaReturnSet;                                   **
  2003. ** extern ATOMID  idOk, idFalse, idTrue, idNull;                    **
  2004. **********************************************************************/
  2005. #define RETURNVALUE HIWORD( KappaReturnSet )
  2006. #define RETURNFLAGS LOWORD( KappaReturnSet )
  2007. short _KappaReturn (WORD, WORD);
  2008. #define KappaReturnError return (KappaReturnSet=MAKELONG(EXPNULL,NULL), ERROR)
  2009. #define KappaReturn(x,y) return _KappaReturn (x, y)
  2010.  
  2011. #define KappaReturnOk        KappaReturn( EXPATOM, idOk )
  2012. #define KappaReturnTrue      KappaReturn( EXPATOM, idTrue )
  2013. #define KappaReturnFalse     KappaReturn( EXPATOM, idFalse )
  2014.  
  2015. #define KappaReturnAtom(x)   KappaReturn (EXPATOM, x)
  2016. #define KappaReturnString(x) KappaReturnAtom (KappaMakeString (x))
  2017. #define KappaReturnDouble(x) KappaReturnAtom (KappaMakeDouble (x))
  2018. #define KappaReturnFloat(x)  KappaReturnAtom (KappaMakeFloat  (x))
  2019. #define KappaReturnInt(x)    KappaReturnAtom (KappaMakeInt    (x))
  2020. #define KappaReturnLong(x)   KappaReturnAtom (KappaMakeLong   (x))
  2021. #define KappaReturnList(x)   KappaReturn (EXPLIST, x)
  2022.  
  2023. /********************************************************************
  2024. KAL Function equivalants
  2025. *********************************************************************/
  2026. /* ApplyKALStatement takes string representing a KAL expression,
  2027.    and then parses it and evaluates it
  2028. */
  2029. ATOMID ApplyKALStatement (LPSTR);
  2030.  
  2031. /* ApplyFunction takes a variable number of arguments!
  2032.         1st arg = function name id,
  2033.         2nd arg = number of arguments,
  2034.         3rd ... = argument atom ids
  2035.   Example:
  2036.      ...
  2037.      if (ApplyFunction (idSetValue, 3, idObj, idSlot, idValue) == ERROR)
  2038.        return ERROR;
  2039.      ...
  2040. */
  2041. ATOMID ApplyFunction (ATOMID, WORD, ...);
  2042.  
  2043. /* ApplyListFunction takes a variable number of arguments!
  2044.         1st arg = function name id,
  2045.         2nd arg = number of arguments,
  2046.         3rd arg = argument list id is always first,
  2047.         4th ... = argumeet atom ids
  2048.   Example:
  2049.      ...
  2050.      if (ApplyListFunction (idGetNthElem, 3, idList, idN) == ERROR)
  2051.        return ERROR;
  2052.      ...
  2053. */
  2054. ATOMID ApplyListFunction (ATOMID, WORD, ...);
  2055.  
  2056. /* ApplyQueryFunction takes a pointer to a function
  2057.         1st arg = function name id,
  2058.         2nd arg = ATOMID argument,
  2059.         3rd arg = lpFunction
  2060.   Example:
  2061.      ...
  2062.      if (ApplyQueryFunction (idForAll, idClass, lpFunction) == ERROR)
  2063.        return ERROR;
  2064.      ...
  2065. */
  2066. ATOMID ApplyQueryFunction (ATOMID, ATOMID, short (FAR *)() );
  2067.  
  2068. /* ApplyQueryListFunction, returns a list
  2069.         1st arg = function name id,
  2070.         2nd arg = ATOMID argument
  2071.   Example:
  2072.      ...
  2073.      if ((idList=ApplyQueryListFunction (idGetSlotList, idObjName)) == ERROR)
  2074.        return ERROR;
  2075.      ...
  2076. */
  2077. LISTID ApplyQueryListFunction (ATOMID, ATOMID);
  2078.  
  2079. /* ApplyInferenceFunction, invokes I.E.
  2080.         1st arg = function name id, (idForwardChain or idBackwardChain)
  2081.         2nd arg = Goal Name,
  2082.         3rd arg = Rule List
  2083.   Example:
  2084.      ...
  2085.      if (ApplyInferenceFunction (idForwardChain,NULLID,NULLID) == ERROR)
  2086.        return ERROR;
  2087.      ...
  2088. */
  2089. LISTID ApplyInferenceFunction( ATOMID, ATOMID, LISTID );
  2090.  
  2091. short Kpp_SaveTranscriptImage( ATOMID, FILE * );
  2092.  
  2093. /********************************************************
  2094. **
  2095. **      DEFINITIONS FOR THE 'C' REPRESENTATIONS
  2096. **      OF THE KAL FUNCTIONS IN KAPPA.
  2097. **
  2098. **      All functions start with the Kappa prefix, followed by
  2099. **      the actual name of the function in KAL.  All ? are
  2100. **      replaced by Q.
  2101. **
  2102. ********************************************************/
  2103.  
  2104. WORD    wDummy1;
  2105. char    kappa_c_buffer[RET_BUFFER_LEN];
  2106.  
  2107. #define KappaRegisterMessage( idAtom1 ) \
  2108.    RegisterKappaMessage( IDE_USER, idAtom1, NULLID, NULLID );
  2109.  
  2110. /* ATOMID KappaActivateRule (ATOMID idRuleName); */
  2111. #define KappaActivateRule(idRuleName) \
  2112.    ApplyFunction(AfromT(IDF_ACTIVATERULE),1,idRuleName)
  2113.  
  2114. /* LISTID _KappaAppendToList (LISTID idList, ATOMID idElem); */
  2115. #define _KappaAppendToList(idList,idElem) \
  2116.    (Append_Elem (idList,idElem) ? idList : NULLID)
  2117.  
  2118. /* LISTID KappaAppendToList (ATOMID idObjName, ATOMID idSlotName,
  2119.                              ATOMID idElem); */
  2120. #define KappaAppendToList(idObjName,idSlotName,idElem) \
  2121.    ApplyFunction (AfromT(IDF_APPENDTOLIST),3,idObjName,idSlotName,idElem)
  2122.  
  2123. /* ATOMID KappaAreAllQ (ATOMID idClassName,
  2124.                         short (FAR * lpFunction) (ATOMID)); */
  2125. #define KappaAreAllQ(idClass,lpFunction) \
  2126.    ApplyQueryFunction(AfromT(IDF_AREALLQUESTION),idClass,lpFunction)
  2127.  
  2128. #define KappaAskValue(idObjName,idSlotName) \
  2129.   ApplyFunction(AfromT(IDF_ASKVALUE),2,idObjName,idSlotName)
  2130.  
  2131. #define KappaAssert(idObjName,idSlotName) \
  2132.    SetValueInferenceHook(idObjName,idSlotName,NULL,EXPATOM)
  2133.  
  2134. #define _KappaAverage(idList) \
  2135.    ApplyListFunction(AfromT(IDF_AVERAGE),1,idList)
  2136.  
  2137. #define KappaAverage(idObjName,idSlotName) \
  2138.    _KappaAverage(GetListValue(idObjName,idSlotName))
  2139.  
  2140. #define KappaBackwardChain(idGoalName,idRuleList) \
  2141.    ApplyInferenceFunction(AfromT(IDF_BACKCHAIN),idGoalName,idRuleList)
  2142.  
  2143. #define KappaBeep() \
  2144.    ApplyFunction(AfromT(IDF_BEEP),0)
  2145.  
  2146. #define KappaClassQ(idClassName) \
  2147.    ((GetClass(idClassName)==NULLID)?idFalse:idTrue)
  2148.  
  2149. #define KappaClearImageLink(idImageName) \
  2150.    ApplyFunction(AfromT(IDF_CLEARWIDGETLINK),1,idImageName)
  2151.  
  2152. #define KappaClearTranscriptImage(idImageName) \
  2153.    ApplyFunction(AfromT(IDF_CLEARTRANSCRIPTWIDGET),1,idImageName)
  2154.  
  2155. #define _KappaClearList(idList) \
  2156.    (Clear_List(idList) ? idList : NULLID)
  2157.  
  2158. #define KappaClearList(idObjName,idSlotName) \
  2159.    ApplyFunction(AfromT(IDF_CLEARLIST),2,idObjName,idSlotName)
  2160.  
  2161. #define KappaConvertBrowserDisplayText(idClassName) \
  2162.    ApplyFunction(AfromT(IDF_CONVERTBROWSERDISPLAYTEXT),1,idClassName)
  2163.  
  2164. #define KappaCopyBitmapToClipboard(idBitmapImage) \
  2165.    (ApplyFunction(AfromT(IDF_COPYBITMAPTOCLIPBOARD),1,idBitmapImage) \
  2166.              ? idTrue : FALSE)
  2167.  
  2168. #define KappaCountAllInstances(idClassName) \
  2169.    ApplyFunction(AfromT(IDF_COUNTALLOBJECTS),1,idClassName)
  2170.  
  2171. #define KappaCountAllSubClasses(idClassName) \
  2172.    ApplyFunction(AfromT(IDF_COUNTALLSUBCLASSES),1,idClassName)
  2173.  
  2174. #define KappaCountInstances(idClassName) \
  2175.    ApplyFunction(AfromT(IDF_COUNTOBJECTS),1,idClassName)
  2176.  
  2177. #define KappaCountSubClasses(idClassName) \
  2178.    ApplyFunction(AfromT(IDF_COUNTSUBCLASSES),1,idClassName)
  2179.  
  2180. #define KappaDate() \
  2181.    ApplyFunction(AfromT(IDF_DATE),0)
  2182.  
  2183. #define KappaDeactivateRule(idRuleName) \
  2184.    ApplyFunction(AfromT(IDF_DEACTIVATERULE),1,idRuleName)
  2185.  
  2186. #define KappaDeleteClass(idClassName) \
  2187.    (DeleteClass(idClassName) ? idClassName : ERROR)
  2188.  
  2189. #define KappaDeleteFunction(idFuncName) \
  2190.    (DeleteFunction(idFuncName) ? idFuncName : ERROR)
  2191.  
  2192. #define KappaDeleteGoal(idGoalName) \
  2193.    (DeleteGoal(idGoalName) ? idGoalName : ERROR)
  2194.  
  2195. #define KappaDeleteMethod(idObjName,idMethodName) \
  2196.    DeleteMethod(idObjName,idMethodName)
  2197.  
  2198. #define KappaDeleteImage(idImageName) \
  2199.    (DELETEOBJECT(idImageName) ? idTrue : ERROR)
  2200.  
  2201. #define KappaDeleteInstance(idInstanceName) \
  2202.    (DELETEOBJECT(idInstanceName) ? idTrue : ERROR)
  2203.  
  2204. /* FSC: This is a dangerous function. The user may delete a list that
  2205.         is refered to by someone else. */
  2206. #define KappaDeleteList(idList) \
  2207.    (Delete_List(idList)?idTrue:NULLID)
  2208.  
  2209. #define KappaDeleteRule(idRuleName) \
  2210.    DeleteRule(idRuleName)
  2211.  
  2212. #define KappaDeleteSlot(idObjName,idSlotName) \
  2213.    DeleteSlot(idObjName,idSlotName)
  2214.  
  2215. #define KappaDisplayFile(idTransImage,idFileName) \
  2216.    ApplyFunction(AfromT(IDF_DISPLAYFILE),2,idTransImage,idFileName)
  2217.  
  2218. #define KappaDisplayText(idTransImage,idText) \
  2219.    ApplyFunction(AfromT(IDF_DISPLAYTEXT),2,idTransImage,idText)
  2220.  
  2221. #define KappaDrawImage(idImageName) \
  2222.    ApplyFunction(AfromT(IDF_DRAWWIDGET),1,idImageName)
  2223.  
  2224. #define KappaDrawText(idText) \
  2225.    ApplyFunction(AfromT(IDF_DRAWTEXT),1,idText)
  2226.  
  2227. #define KappaEllipse(iX,iY) \
  2228.    ApplyFunction(AfromT(IDF_ELLIPSE),2,KappaMakeInt(iX),KappaMakeInt(iY))
  2229.  
  2230. #define KappaEnumList(idList,lpFunction) \
  2231.    ApplyQueryFunction(AfromT(IDF_ENUMLIST),idList,lpFunction)
  2232.  
  2233. #define KappaEnumSubClasses(idClass,lpFunction) \
  2234.    ApplyQueryFunction(AfromT(IDF_ENUMSUBCLASSES),idClass,lpFunction)
  2235.  
  2236. #define KappaExecute(idProgName,idArg1,idArg2,idArg3) \
  2237.    ApplyFunction(AfromT(IDF_EXECUTE),4,idProgName,idArg1,idArg2,idArg3)
  2238.  
  2239. #define KappaExit() \
  2240.    ApplyFunction(AfromT(IDF_EXIT),0)
  2241.  
  2242. #define KappaExplain(idObjName,idSlotName) \
  2243.    (ExplainPair(idObjName,idSlotName,0) ? idTrue : FALSE)
  2244.  
  2245. #define KappaForAll(idClass,lpFunction) \
  2246.    ApplyQueryFunction(AfromT(IDF_FORALL),idClass,lpFunction)
  2247.  
  2248. #define KappaForwardChain(idGoalName,idRuleList) \
  2249.    ApplyInferenceFunction(AfromT(IDF_FORWARDCHAIN),idGoalName,idRuleList)
  2250.  
  2251. #define KappaFreezeWindow(idKappaWindowCode) \
  2252.    ApplyFunction(AfromT(IDF_FREEZEWINDOW),1,idKappaWindowCode)
  2253.  
  2254. #define KappaFunctionQ(idFuncName) \
  2255.    ((GetKappaFunction(idFuncName,&wDummy1)==(KAPPROC)NULL)?idFalse:idTrue)
  2256.  
  2257. #define KappaGetBrowserFocus() \
  2258.    ApplyFunction(AfromT(IDF_GETFOCUS),0)
  2259.  
  2260. #define KappaGetClassComment(idClassName) \
  2261.    GetClassInfo(idClassName)
  2262.  
  2263. #define KappaGetClock() \
  2264.    ApplyFunction(AfromT(IDF_GETCLOCK),0)
  2265.  
  2266. #define KappaGetDepth(idClassName) \
  2267.    ApplyFunction(AfromT(IDF_GETDEPTH),1,idClassName)
  2268.  
  2269. #define _KappaGetElemPos(idList,idElem) \
  2270.       ((wKappaTmpWord = Get_ElemPos(idList,idElem)) ? \
  2271.                KappaMakeInt (wKappaTmpWord) : ERROR)
  2272.  
  2273. #define KappaGetElemPos(idObjName,idSlotName,idElem) \
  2274.    _KappaGetElemPos(GetListValue(idObjName,idSlotName),idElem)
  2275.  
  2276. #define KappaGetFunctionComment(idFuncName) \
  2277.    GetFunctionInfo(idFuncName)
  2278.  
  2279. #define KappaGetGoalComment(idGoalName) \
  2280.    GetGoalInfo(idGoalName)
  2281.  
  2282. #define KappaGetMethodComment(idObjName,idMethodName) \
  2283.    GetMethodInfo(idObjName,idMethodName)
  2284.  
  2285. #define _KappaGetNthElem(idList,nth) \
  2286.    Get_Elem(idList,nth)
  2287.  
  2288. #define KappaGetNthElem(idObjName,idSlotName,nth) \
  2289.    _KappaGetNthElem(GetListValue(idObjName,idSlotName),nth)
  2290.  
  2291. #define KappaGetInstanceComment(idInstanceName) \
  2292.    GetObjectInfo(idInstanceName)
  2293.  
  2294. /* FSC: This is a dangerous function. The user has to delete this
  2295.         list after being done with it. */
  2296. #define _KappaGetInstanceList(idClassName) \
  2297.    ApplyQueryListFunction(AfromT(IDF_GETOBJECTLIST),idClassName)
  2298.  
  2299. #define KappaGetInstanceList(idClassName,idObjName,idSlotName) \
  2300.      ((idKappaTmpList = _KappaGetInstanceList(idClassName)) ? \
  2301.        (KappaSetListValue(idObjName,idSlotName,idKappaTmpList) ? \
  2302.             idKappaTmpList : FALSE) : FALSE)
  2303.  
  2304. #define KappaGetOwner(idObjName,idSlotName) \
  2305.    ApplyFunction(AfromT(IDF_GETOWNER),2,idObjName,idSlotName)
  2306.  
  2307. #define KappaGetParent(idObjName) \
  2308.    GetSuper(idObjName)
  2309.  
  2310. #define KappaGetRuleComment(idRuleName) \
  2311.    GetRuleInfo(idRuleName)
  2312.  
  2313. #define KappaGetScreenWidth() \
  2314.    ApplyFunction(AfromT(IDF_GETSCREENWIDTH),0)
  2315.  
  2316. #define KappaGetScreenHeight() \
  2317.    ApplyFunction(AfromT(IDF_GETSCREENHEIGHT),0)
  2318.  
  2319. #define KappaGetSlotComment(idObjName,idSlotName) \
  2320.    GetSlotInfo(idObjName,idSlotName)
  2321.  
  2322. /* FSC: This is a dangerous function. The user has to delete this
  2323.         list after being done with it. */
  2324. #define _KappaGetSlotList(idObjName) \
  2325.    ApplyQueryListFunction(AfromT(IDF_GETSLOTLIST),idObjName)
  2326.  
  2327. #define KappaGetSlotList(idSlotObjName,idObjName,idSlotName) \
  2328.    KappaSetListValue(idObjName,idSlotName,_KappaGetSlotList(idSlotObjName))
  2329.  
  2330. #define KappaGetSlotOption(idObjName,idSlotName,idOptionCode) \
  2331.    ApplyFunction(AfromT(IDF_GETSLOTOPTION),3,idObjName,idSlotName,idOptionCode)
  2332.  
  2333. /* FSC: This is a dangerous function. The user has to delete this
  2334.         list after being done with it. */
  2335. #define _KappaGetSubClassList(idClassName) \
  2336.    ApplyQueryListFunction(AfromT(IDF_GETSUBCLASSLIST),idClassName)
  2337.  
  2338. #define KappaGetSubClassList(idClassName,idObjName,idSlotName) \
  2339.    KappaSetListValue(idObjName,idSlotName,_KappaGetSubClassList(idClassName))
  2340.  
  2341. #define KappaGetValue(idObjName,idSlotName) \
  2342.    GetValue(idObjName,idSlotName)
  2343.  
  2344. #define KappaGetListValue(idObjName,idSlotName) \
  2345.    GetListValue(idObjName,idSlotName)
  2346.  
  2347. #define KappaGoalQ(idGoalName) \
  2348.    ((GetGoal(idGoalName)==NULLID)?idFalse:idTrue)
  2349.  
  2350. #define KappaHideBrowserInstances(idClassName) \
  2351.    ApplyFunction(AfromT(IDF_HIDEOBJECTS),1,idClassName)
  2352.  
  2353. #define KappaHideBrowserSubClasses(idClassName) \
  2354.    ApplyFunction(AfromT(IDF_HIDESUBCLASSES),1,idClassName)
  2355.  
  2356. #define KappaHideImage(idImageName) \
  2357.    ApplyFunction(AfromT(IDF_HIDEWIDGET),1,idImageName)
  2358.  
  2359. #define KappaHideWindow(idKappaWindowCode) \
  2360.    ApplyFunction(AfromT(IDF_HIDEWINDOW),1,idKappaWindowCode)
  2361.  
  2362. #define KappaIconifyWindow(idKappaWindowCode) \
  2363.    ApplyFunction(AfromT(IDF_ICONIFYWINDOW),1,idKappaWindowCode)
  2364.  
  2365. #define _KappaInsertNthElem(idList,nth,idElem) \
  2366.    (Check_List (idList, &wKappaTmpWord) ? \
  2367.      (Insert_Elem((idList),nth,idElem,kPOSITIONMODE) ? idTrue : FALSE) \
  2368.      : ERROR)
  2369.  
  2370. #define KappaInsertNthElem(idObjName,idSlotName,nth,idElem) \
  2371.    (ApplyFunction (AfromT(IDF_INSERTNTHELEM),4,idObjName,idSlotName,KappaMakeInt(nth),idElem) ? idTrue : FALSE)
  2372.  
  2373. #define KappaIntegerQ(idAtom) \
  2374.    ApplyFunction(AfromT(IDF_INTEGERQUESTION),1,idAtom)
  2375.  
  2376. #define KappaInterpretFile(idKALFileName) \
  2377.    ApplyFunction(AfromT(IDF_INTERPRETFILE),1,idKALFileName)
  2378.  
  2379. #define KappaIsAKindOfQ(idObjName,idClassName) \
  2380.    ApplyFunction(AfromT(IDF_ISAKINDOFQUESTION),2,idObjName,idClassName)
  2381.  
  2382. #define KappaIsThereAnyQ(idClass,lpFunction) \
  2383.    ApplyQueryFunction(AfromT(IDF_ISTHEREANYQUESTION),idClass,lpFunction)
  2384.  
  2385. #define KappaKnownValueQ(idObjName,idSlotName) \
  2386.    ApplyFunction(AfromT(IDF_KNOWNVALUEQUESTION),2,idObjName,idSlotName)
  2387.  
  2388. #define _KappaLengthList(idList) \
  2389.    (Check_List (idList, &wKappaTmpWord) ? \
  2390.                KappaMakeInt (wKappaTmpWord) : ERROR)
  2391.  
  2392. #define KappaLengthList(idObjName,idSlotName) \
  2393.      ((idKappaTmpList = GetListValue (idObjName, idSlotName)) \
  2394.                        ? _KappaLengthList(idKappaTmpList) : ERROR)
  2395.    
  2396. #define KappaLineTo(iX,iY) \
  2397.    ApplyFunction(AfromT(IDF_LINETO),2,KappaMakeInt(iX),KappaMakeInt(iY))
  2398.  
  2399. #define KappaLineToRel(iX,iY) \
  2400.    ApplyFunction(AfromT(IDF_LINETOREL),2,KappaMakeInt(iX),KappaMakeInt(iY))
  2401.  
  2402. #define KappaLocalValueQ(idObjName,idSlotName) \
  2403.    ApplyFunction(AfromT(IDF_LOCALVALUEQUESTION),2,idObjName,idSlotName)
  2404.  
  2405. #define KappaMakeClass(idClassName,idSuperClassName) \
  2406.    (MakeClass(idClassName,idSuperClassName) ? idClassName : NULLID)
  2407.  
  2408. #define KappaMakeFunction(idFuncName,idArgList,idExp) \
  2409.    MakeFunction(idFuncName,idArgList,idExp)
  2410. /* you may make the idExp through Build_Exp(LPSTR), or from KappaGetArgExp */
  2411.  
  2412. #define KappaMakeGoal(idGoalName,idExp) \
  2413.    (MakeGoal(idGoalName,idExp) ? idGoalName : NULLID)
  2414. /* you may make the idExp through Build_Exp(LPSTR), or from KappaGetArgExp */
  2415.  
  2416. #define KappaMakeImage(idImageName,idImageClass) \
  2417.    ApplyFunction(AfromT(IDF_MAKEWIDGET),2,idImageName,idImageClass)
  2418.                                                                  
  2419. /* FSC: This is a dangerous function. The user has to delete this
  2420.         list after being done with it. */
  2421. #define KappaMakeList() Make_List(0)
  2422.  
  2423. #define KappaMakeMethod(idObjName,idMethodName,idArgList,idExp) \
  2424.    MakeMethod(idObjName,idMethodName,idArgList,idExp)
  2425. /* you may make the idExp through Build_Exp(LPSTR), or from KappaGetArgExp */
  2426.  
  2427. #define KappaMakeInstance(idInstanceName,idClassName) \
  2428.    (MakeObject(idInstanceName,idClassName) ? idInstanceName : NULLID)
  2429.  
  2430. #define KappaMakeRule(idRuleName,idMatchList,idClassList,idIfExp,idThenExp) \
  2431.    MakeRule(idRuleName,idMatchList,idClassList,idIfExp,idThenExp)
  2432. /* you may make the idExp's through Build_Exp(LPSTR), or from KappaGetArgExp */
  2433.                                     
  2434. #define KappaMakeSlot(idObjName,idSlotName) \
  2435.    (MakeSlot(idObjName,idSlotName) ? idSlotName : NULLID)
  2436.  
  2437. #define KappaMapEscapeKey(idKeyCode) \
  2438.    ApplyFunction(AfromT(IDF_MAPESCAPEKEY),1,idKeyCode)
  2439.  
  2440. #define _KappaMax(idList) \
  2441.    ApplyListFunction(AfromT(IDF_MAX),1,idList)
  2442.  
  2443. #define KappaMax(idObjName,idSlotName) \
  2444.    _KappaMax(KappaGetListValue(idObjName,idSlotName))
  2445.  
  2446. #define KappaMaximizeWindow(idKappaWindowCode) \
  2447.    ApplyFunction(AfromT(IDF_MAXIMIZEWINDOW),1,idKappaWindowCode)
  2448.  
  2449. #define _KappaMemberQ(idList,idElem) \
  2450.    (Get_ElemPos(idList,idElem) ? idTrue : idFalse)
  2451.  
  2452. #define KappaMemberQ(idObjName,idSlotName,idElem) \
  2453.    _KappaMemberQ(GetListValue(idObjName,idSlotName),idElem)
  2454.  
  2455. #define KappaMethodQ(idObjName,idMethodName) \
  2456.    ((GetMethod(idObjName,idMethodName)==NULLID)?idFalse:idTrue)
  2457.  
  2458. #define _KappaMin(idList) \
  2459.    ApplyListFunction(AfromT(IDF_MIN),1,idList)
  2460.  
  2461. #define KappaMin(idObjName,idSlotName) \
  2462.    _KappaMin(KappaGetListValue(idObjName,idSlotName))
  2463.  
  2464. #define KappaMoveHierarchy(idClassName,idNewParent) \
  2465.    ApplyFunction(AfromT(IDF_MOVEHIERARCHY),2,idClassName,idNewParent)
  2466.  
  2467. #define KappaMoveInstance(idInstanceName,idClassName) \
  2468.    (ApplyFunction(AfromT(IDF_MOVEOBJECT),2,idInstanceName,idClassName) \
  2469.               ? idTrue : FALSE )
  2470.  
  2471. #define KappaMoveTo(iX,iY) \
  2472.    ApplyFunction(AfromT(IDF_MOVETO),2,KappaMakeInt(iX),KappaMakeInt(iY))
  2473.  
  2474. #define KappaMoveToRel(iX,iY) \
  2475.    ApplyFunction(AfromT(IDF_MOVETOREL),2,KappaMakeInt(iX),KappaMakeInt(iY))
  2476.  
  2477. #define _KappaMultiply(idList) \
  2478.    ApplyListFunction(AfromT(IDF_MULTIPLY),1,idList)
  2479.  
  2480. #define KappaMultiply(idObjName,idSlotName) \
  2481.    _KappaMultiply(KappaGetListValue(idObjName,idSlotName))
  2482.  
  2483. #define KappaNullQ(idAtom) \
  2484.    ((idAtom==idNull)?idTrue:idFalse)
  2485.  
  2486. #define KappaNumberQ(idAtom) \
  2487.    (KappaGetString(idAtom,kappa_c_buffer,RET_BUFFER_LEN),\
  2488.     (IsNumber(kappa_c_buffer) ? idTrue : idFalse))
  2489.  
  2490. #define KappaInstanceQ(idInstanceName) \
  2491.    ((GETOBJECT(idInstanceName)==NULLID)?idFalse:idTrue)
  2492.  
  2493. #define KappaPositionImage(idImageName,x,y,width,height) \
  2494.    ApplyFunction(AfromT(IDF_POSITIONWIDGET),5,idImageName, \
  2495.       KappaMakeInt(x),KappaMakeInt(y),KappaMakeInt(width),KappaMakeInt(height))
  2496.  
  2497. #define KappaPositionWindow(idWindowCode,x,y,width,height) \
  2498.    ApplyFunction(AfromT(IDF_POSITIONWINDOW),5,idWindowCode, \
  2499.       KappaMakeInt(x),KappaMakeInt(y),KappaMakeInt(width),KappaMakeInt(height))
  2500.  
  2501. #define KappaPostBusy(idToggle,idMessage) \
  2502.    ApplyFunction(AfromT(IDF_POSTBUSY),2,idToggle,idMessage)
  2503.  
  2504. #define KappaPostError(idErrorMessage) \
  2505.    return RegisterKappaMessage(IDE_ERRORUSER,idErrorMessage,NULLID,NULLID)
  2506.  
  2507.  
  2508. #define KappaPostMessage(idMessageText) \
  2509.    ApplyFunction(AfromT(IDF_POSTMESSAGE),1,idMessageText)
  2510.  
  2511. #define KappaPrintHierarchy(idClass) \
  2512.    (PrintHierarchy(idClass) ? idTrue : FALSE)
  2513.  
  2514. #define KappaPrintImage(idImageName) \
  2515.    ApplyFunction(AfromT(IDF_PRINTWIDGET),1,idImageName)
  2516.  
  2517. #define KappaReadWord(file) \
  2518.    (GetWordFromFile(file,kappa_c_buffer,RET_BUFFER_LEN),Add_Atom(kappa_c_buffer))
  2519.  
  2520. #define KappaRectangle(iX,iY) \
  2521.    ApplyFunction(AfromT(IDF_RECTANGLE),2,KappaMakeInt(iX),KappaMakeInt(iY))
  2522.  
  2523. #define _KappaRemoveFromList(idList,idElem) \
  2524.    (Delete_Elem(idList,idElem,kDELETEMODE) ? idList : FALSE)
  2525.  
  2526. #define KappaRemoveFromList(idObjName,idSlotName,idElem) \
  2527.    ApplyFunction (AfromT(IDF_REMOVEFROMLIST),3,idObjName,idSlotName,idElem)
  2528.  
  2529. #define _KappaRemoveNthElem(idList,nth) \
  2530.    (Delete_Elem(idList,nth,kPOSITIONMODE) ? idList : FALSE)
  2531.  
  2532. #define KappaRemoveNthElem(idObjName,idSlotName,nth) \
  2533.    ApplyFunction (AfromT(IDF_REMOVENTHELEM),3,idObjName,idSlotName,KappaMakeInt(nth))
  2534.  
  2535. #define KappaRemoveWindowMenu(idKappaWindowCode) \
  2536.    ApplyFunction(AfromT(IDF_REMOVEWINDOWMENU),1,idKappaWindowCode)
  2537.  
  2538. #define KappaRenameClass(idClassName,idNewName) \
  2539.    (RenameClass(idClassName,idNewName) ? idTrue : FALSE)
  2540.  
  2541. #define KappaRenameFunction(idFuncName,idNewName) \
  2542.    (RenameFunction(idFuncName,idNewName) ? idTrue : FALSE)
  2543.  
  2544. #define KappaRenameGoal(idGoalName,idNewName) \
  2545.    (RenameGoal(idGoalName,idNewName) ? idTrue : FALSE)
  2546.  
  2547. #define KappaRenameMethod(idObjName,idMethodName,idNewName) \
  2548.    (RenameMethod(idObjName,idMethodName,idNewName) ? idTrue : FALSE)
  2549.  
  2550. #define KappaRenameInstance(idInstanceName,idNewName) \
  2551.    (RenameObject(idInstanceName,idNewName) ? idTrue : FALSE)
  2552.  
  2553. #define KappaRenameRule(idRuleName,idNewName) \
  2554.    (RenameRule(idRuleName,idNewName) ? idTrue : FALSE)
  2555.  
  2556. #define KappaRenameSlot(idObjName,idSlotName,idNewName) \
  2557.    (RenameSlot(idObjName,idSlotName,idNewName) ? idTrue : FALSE)
  2558.  
  2559. #define KappaResetClock() \
  2560.    ApplyFunction(AfromT(IDF_RESETCLOCK),0)
  2561.  
  2562. #define KappaResetForwardChain() \
  2563.    (g_reset_forward_chain(LPNULL), RETURNVALUE)
  2564.  
  2565. #define KappaResetImage(idImageName) \
  2566.    ApplyFunction(AfromT(IDF_RESETWIDGET),1,idImageName)
  2567.  
  2568. #define KappaResetSlotOption(idObjName,idSlotName,idOptionCode) \
  2569.    (ApplyFunction(AfromT(IDF_RESETSLOTOPTION),3, \
  2570.                  idObjName,idSlotName,idOptionCode) ? idTrue : FALSE)
  2571.  
  2572. #define KappaResetValue(idObjName,idSlotName) \
  2573.    ApplyFunction(AfromT(IDF_RESETVALUE),2,idObjName,idSlotName)
  2574.  
  2575. #define KappaResetWindowMenu(idKappaWindowCode) \
  2576.    ApplyFunction(AfromT(IDF_RESETWINDOWMENU),1,idKappaWindowCode)
  2577.  
  2578. #define KappaRuleQ(idRuleName) \
  2579.    ((GetRule(idRuleName)==NULLID)?idFalse:idTrue)
  2580.  
  2581. #define KappaSaveClipboardBitmap(idFileName) \
  2582.    (ApplyFunction(AfromT(IDF_SAVECLIPBOARDBITMAP),1,idFileName)?idTrue:FALSE)
  2583.  
  2584. #define KappaSaveTranscriptImage(idTranscriptName,file) \
  2585.    Kpp_SaveTranscriptImage(idTranscriptName,file)
  2586.  
  2587. #define KappaSelectList(idList,lpFunction) \
  2588.    ApplyQueryFunction(AfromT(IDF_SELECTLIST),idList,lpFunction)
  2589.  
  2590. #define KappaSelectSubClass(idClass,lpFunction) \
  2591.    ApplyQueryFunction(AfromT(IDF_SELECTSUBCLASS),idClass,lpFunction)
  2592.  
  2593. #define KappaSendMessage(idObjName,idMethod,idArgList) \
  2594.    ((EvalMethod(idObjName,idMethod,idArgList)==ERROR)?NULLID:RETURNVALUE)
  2595.  
  2596. #define _KappaSetActiveRules(idList) \
  2597.    ApplyListFunction(AfromT(IDF_SETACTIVERULES),1,idList)
  2598.  
  2599. #define KappaSetActiveRules(idObjName,idSlotName) \
  2600.    _KappaSetActiveRules(GetListValue(idObjName,idSlotName))
  2601.  
  2602. #define KappaSetBrowserFocus(idClassName) \
  2603.    ApplyFunction(AfromT(IDF_SETFOCUS),1,idClassName)
  2604.  
  2605. #define KappaSetClassComment(idClassName,idComment) \
  2606.    SetClassInfo(idClassName,idComment)
  2607.  
  2608. #define KappaSetForwardChainMode(idRuleConflict,idAgendaConflict) \
  2609.    ApplyFunction(AfromT(IDF_SETFORWARDCHAINMODE),2, \
  2610.                  idRuleConflict,idAgendaConflict)
  2611.  
  2612. #define KappaSetFunctionComment(idFuncName,idComment) \
  2613.    SetFunctionInfo(idFuncName,idComment)
  2614.  
  2615. #define KappaSetGoalComment(idGoalName,idComment) \
  2616.    SetGoalInfo(idGoalName,idComment)
  2617.  
  2618. #define KappaSetImageLink(idImageName,idObjName,idSlotName) \
  2619.    ApplyFunction(AfromT(IDF_SETWIDGETLINK),3,idImageName,idObjName,idSlotName)
  2620.  
  2621. #define KappaSetLineStyle(iThickness,iStyle) \
  2622.    ApplyFunction(AfromT(IDF_SETLINESTYLE),2,KappaMakeInt(iThickness),\
  2623.        KappaMakeInt(iStyle))
  2624.  
  2625. #define KappaSetMethodComment(idObjName,idMethodName,idComment) \
  2626.    (SetMethodInfo(idObjName,idMethodName,idComment) ? idComment : FALSE)
  2627.  
  2628. #define _KappaSetNthElem(idList,nth,idElem) \
  2629.    (!Delete_Elem(idList,nth,kPOSITIONMODE) ? FALSE :  \
  2630.         (Insert_Elem(idList,nth,idElem,kPOSITIONMODE) ? idList : FALSE))
  2631.  
  2632. #define KappaSetNthElem(idObjName,idSlotName,nth,idElem) \
  2633.    ApplyFunction(AfromT(IDF_SETNTHELEM),4,idObjName,idSlotName,KappaMakeInt(nth),idElem)
  2634.  
  2635. #define KappaSetPostMenuPosition(iX,iY) \
  2636.    ApplyFunction(AfromT(IDF_SETPOSTMENUPOSITION),2, \
  2637.                  KappaMakeInt(iX),KappaMakeInt(iY))
  2638.  
  2639. #define KappaSetPostMessageTitle(idTitle) \
  2640.    (SetPostMessageTitle(idTitle) ? idTrue : FALSE)
  2641.  
  2642. #define KappaSetInstanceComment(idInstanceName,idComment) \
  2643.    SetObjectInfo(idInstanceName,idComment)
  2644.  
  2645. #define KappaSetRuleComment(idRuleName,idComment) \
  2646.    SetRuleInfo(idRuleName,idComment)
  2647.  
  2648. #define KappaSetRulePriority(idRuleName,iPriority) \
  2649.     (SetRulePriority(idRuleName, iPriority) ? iPriority : FALSE)
  2650.  
  2651. #define KappaSetSlotComment(idObjName,idSlotName,idComment) \
  2652.    (SetSlotInfo(idObjName,idSlotName,idComment) ? idComment : FALSE )
  2653.  
  2654. #define KappaSetSlotOption(idObjName,idSlotName,idOptionCode,idValue) \
  2655.    ((idOptionCode == idMultiple || idOptionCode == idSingle) ? \
  2656.      ApplyFunction(AfromT(IDF_SETSLOTOPTION), \
  2657.                    3,idObjName,idSlotName,idOptionCode) : \
  2658.      ApplyFunction(AfromT(IDF_SETSLOTOPTION),4, \
  2659.                  idObjName,idSlotName,idOptionCode,idValue))
  2660.  
  2661. #define KappaSetValue(idObjName,idSlotName,idValue) \
  2662.    SetSlotValue(idObjName,idSlotName,idValue,EXPATOM)
  2663.  
  2664. /* TK: This is a dangerous function. The user may have two references to
  2665.    this list. */
  2666. #define KappaSetListValue(idObjName,idSlotName,idListValue) \
  2667.    SetSlotValue(idObjName,idSlotName,idListValue,EXPLIST)
  2668.  
  2669. #define KappaSetWindowTitle(idKappaWindowCode,idTitle) \
  2670.    ApplyFunction(AfromT(IDF_SETWINDOWTITLE),2,idKappaWindowCode,idTitle)
  2671.  
  2672. #define KappaShowBrowserInstances(idClassName) \
  2673.    ApplyFunction(AfromT(IDF_SHOWOBJECTS),1,idClassName)
  2674.  
  2675. #define KappaShowBrowserSubClasses(idClassName) \
  2676.    ApplyFunction(AfromT(IDF_SHOWSUBCLASSES),1,idClassName)
  2677.  
  2678. #define KappaShowImage(idImageName) \
  2679.    ApplyFunction(AfromT(IDF_SHOWWIDGET),1,idImageName)
  2680.  
  2681. #define KappaShowWindow(idKappaWindowCode) \
  2682.    ApplyFunction(AfromT(IDF_SHOWWINDOW),1,idKappaWindowCode)
  2683.  
  2684. #define KappaSlotQ(idObjName,idSlotName) \
  2685.    ((GetSlot(idObjName,idSlotName)==NULLID)?idFalse:idTrue)
  2686.  
  2687. #define _KappaSum(idList) \
  2688.    ApplyListFunction(AfromT(IDF_SUM),1,idList)
  2689.  
  2690. #define KappaSum(idObjName,idSlotName) \
  2691.    _KappaSum(KappaGetListValue(idObjName,idSlotName))
  2692.  
  2693. #define KappaTestGoal(idGoalName) \
  2694.    (TestGoal(GetGoal(idGoalName)) ? idTrue : idFalse)
  2695.  
  2696. #define KappaTime() \
  2697.    ApplyFunction(AfromT(IDF_TIME),0)
  2698.  
  2699. #define KappaToClass(idInstanceName) \
  2700.    (MakeIntoClass(idInstanceName) ? idInstanceName : FALSE)
  2701.  
  2702. #define KappaToInstance(idClassName) \
  2703.    (MakeIntoObject(idClassName) ? idClassName : FALSE)
  2704.  
  2705. #define KappaUnfreezeWindow(idKappaWindowCode) \
  2706.    ApplyFunction(AfromT(IDF_UNFREEZEWINDOW),1,idKappaWindowCode)
  2707.  
  2708. #define KappaUpdateImage(idImageName,idValue) \
  2709.    ApplyFunction(AfromT(IDF_UPDATEWIDGET),2,idImageName,idValue)
  2710.  
  2711. #define KappaWait(seconds) \
  2712.    ApplyFunction(AfromT(IDF_WAIT),1,seconds)
  2713.  
  2714. #define KappaWriteAllClasses(file) \
  2715.    (ferror(file)!=0 ? NULLID : \
  2716.     (WriteAllClasses(file,idRootClass),idTrue))
  2717.  
  2718. #define KappaWriteAllFunctions(file) \
  2719.    (ferror(file)!=0 ? NULLID : \
  2720.     (WriteAllFunctions(file),idTrue))
  2721.  
  2722. #define KappaWriteAllGoals(file) \
  2723.    (ferror(file)!=0 ? NULLID : \
  2724.     (WriteAllGoals(file),idTrue))
  2725.  
  2726. #define KappaWriteAllInstances(file) \
  2727.    (ferror(file)!=0)?NULLID: \
  2728.     (WriteAllObjects(file),idTrue)
  2729.  
  2730. #define KappaWriteAllRules(file) \
  2731.    (ferror(file)!=0 ? NULLID : \
  2732.     (WriteAllRules(file),idTrue))
  2733.  
  2734. #define KappaWriteAll(file) \
  2735.    (ferror(file)!=0 ? NULLID : \
  2736.     (WriteAllFunctions(file),WriteAllClasses(file,idRootClass), \
  2737.      WriteAllObjects(file),WriteAllRules(file), \
  2738.      WriteAllGoals(file),idTrue))
  2739.  
  2740. #define KappaWriteAllKnowledge(file) \
  2741.    KappaWriteAll(file)
  2742.  
  2743. #define KappaWriteClass(file,idClassName) \
  2744.    (ferror(file)!=0 ? NULLID : \
  2745.     (WriteClass(idClassName,file),idTrue))
  2746.  
  2747. #define KappaWriteFunction(file,idFuncName) \
  2748.    (ferror(file)!=0 ? NULLID : \
  2749.     (WriteFunction(idFuncName,file),idTrue))
  2750.  
  2751. #define KappaWriteGoal(file,idGoalName) \
  2752.    (ferror(file)!=0 ? NULLID : \
  2753.     (WriteGoal(idGoalName,file),idTrue))
  2754.  
  2755. #define KappaWriteHierarchy(file,idClassName) \
  2756.    (ferror(file)!=0 ? NULLID : \
  2757.     (WriteTreeOnFile(idClassName,file),idTrue))
  2758.  
  2759. #define KappaWriteInstance(file,idInstanceName) \
  2760.    (ferror(file)!=0 ? NULLID: \
  2761.     (WriteObject(idInstanceName,file),idTrue))
  2762.  
  2763. #define KappaWriteRule(file,idRuleName) \
  2764.    (ferror(file)!=0 ? NULLID : \
  2765.     (WriteRule(idRuleName,file),idTrue))
  2766.  
  2767. #define KappaGetVersion() GetKAPPAVersionID ()
  2768.  
  2769. /**************************************************************
  2770. ** GLOBAL VARIABLES
  2771.  
  2772. ** some windows related variables
  2773. ***************************************************************/
  2774. extern  HANDLE  hInstKappa;             /* Instance of Kappa window */
  2775. extern  HWND    hWndKappa,              /* Kappa Window */
  2776.                 hWndKAL,                /* KAL Window -- [mlm]  2/15/90 */
  2777.                 hWndInterpret,          /* Interpreter Text Window */
  2778.                 hWndTrace,              /* Trace Debugger Window */
  2779.                 hWndTraceText,          /* Trace Debugger Text */
  2780.                 hWndKTools,             /* Knowledge Tools Popup Window */
  2781.                 hWndBrowser,            /* Graphics Browser Window */
  2782.                 hWndInference,          /* Graphics Rule Browser Window */
  2783.                 hWndSession,            /* Inference Session Window */
  2784.                 hWndComment ;           /* Comment Window -- [mlm]  2/15/90 */
  2785. extern  HWND    hWndRuleRel ;
  2786. extern  HMENU   hMenuKappa;             /* handle to Kappa menu bar */
  2787. extern  HBRUSH  hbrWhite, hbrBlack,     /* handle to white and black brushes */
  2788.                 hbrColor;               /* handle to system color brush */
  2789. extern  HCURSOR arrowCursor,            /* Arrow Cursor Handle */
  2790.                 handCursor,             /* Hand Cursor Handle */
  2791.                 ibeamCursor,            /* Ibeam Cursor Handle */
  2792.                 hHourGlass;             /* Busy cursor */
  2793. extern  HANDLE  hAccelTable;            /* handle to accelerator table */
  2794. extern  HICON   kappaIcon, objectIcon, ruleIcon, funcIcon, classIcon,
  2795.                 goalIcon, slotIcon, toolsIcon, browserIcon, helpIcon,
  2796.                 interpIcon, sessionIcon, thumbIcon, methodIcon, inferenceIcon,
  2797.                 kalIcon,  /* [mlm] 2/15/90 */
  2798.                 rulerelIcon ;
  2799. extern  char    szAppName[], szTitle[], szKTools[], szUntitled[],
  2800.                 szInterpret[], szTrace[], szDebugger[], szBrowser[],
  2801.                 szInference[], szSession[], sztools[], szError[],
  2802.                 szRootWidget[], szRuleRel [] ;
  2803. extern  char    szClassIcon[], szObjectIcon[], szSlotIcon[], szFuncIcon[],
  2804.                 szRuleIcon[], szGoalIcon[], szToolsIcon[], szBrowserIcon[],
  2805.                 szInferenceIcon[], szHelpIcon[], szInterpIcon[],
  2806.                 szSessionIcon[], szThumbIcon[], szMethodIcon[],
  2807.                 szKALIcon [], szRuleRelIcon [] ; /* [mlm] 2/15/90 */
  2808.  
  2809. /**************************************************************
  2810. ** for interpreter's text
  2811. ***************************************************************/
  2812. extern  char    return_buffer[];
  2813. extern  SHORT   par_count;
  2814.  
  2815. /**************************************************************
  2816. ** switches for selected knowledge item, or interface mode
  2817. ***************************************************************/
  2818. extern  ITEM_FLAGS      SelectedItemType;
  2819. extern  BOOL            bEchoMode, bBrowserMode, bInferenceMode, bKToolsMode, bSessionMode;
  2820. extern  BOOL            bDebugMode, bTraceMode, bSilentMode;
  2821. extern  BOOL            bInterpMode ;  /* [mlm]  2/15/90 */
  2822. extern  BOOL            bRuleRelMode ;  /* [mlm]  3/1/90 */
  2823.  
  2824. extern   BOOL     bCommentShown ;
  2825.  
  2826. /**************************************************************
  2827. ** Inference Engine Modes and Information
  2828. ***************************************************************/
  2829. extern  SHORT   max_pass;
  2830. extern  char    source_type;
  2831. extern  char    source_name[];
  2832.  
  2833. /*********************************************************************
  2834. **  Remembers whether application has changed
  2835. **********************************************************************/
  2836. extern BOOL     bAppChanged;
  2837.  
  2838. /*********************************************************************
  2839. **  ID of root Class, and Object containing global variables
  2840. **********************************************************************/
  2841. extern ITEMID   idRootClass;
  2842. extern ITEMID   idGlobalVars;
  2843.  
  2844. /*********************************************************************
  2845. **  ID's of atoms used often in the system, defined here globally
  2846. **********************************************************************/
  2847. extern ITEMID   idSelf, idTheParent, idTheSlot, idOpenBracket, idVerticalBar,
  2848.                 idCloseBracket, idOk, idTrue, idFalse, idError, idNull,
  2849.                 idPrompt, idCardinality, idSingle, idMultiple, idStart,
  2850.                 idRootWidgetName, idBChange, idAChange, idEcho, idPossValue,
  2851.                 idIfNeeded, idValueType, idMinValue, idMaxValue,
  2852.                 idObjStr, idStrStr, idBoolStr, idNumberStr, idPossClass,
  2853.                 idDot, idDotDot, idSpace, idWidgets, idEndOfFile,
  2854.                 idPlus, idMinus, idTimes, idDivide, idPower, idAlmost,
  2855.                 idSetEqual, idEqual, idNotEqual, idLessEqual, idGreaterEqual,
  2856.                 idGreater, idLess, idPound, idAtSign, idBackSlash,
  2857.                 idExclamation, idQuestionMark, idComma, idColon,
  2858.                 idSemiColon, idOpenCurly, idCloseCurly, idPercent,
  2859.                 idKnownValue, idAssert, idKappa, idSession, idTrace,
  2860.                 idKAL, idRuleRel, /* [mlm] 2/15/90 */
  2861.                 idKTools, idBrowser, idInference, idDbaseIII, idDbaseIV,
  2862.                 idMakeObject, idMakeClass, idDeleteObject, idDeleteClass,
  2863.                 idShowClassMenu, idShowObjectMenu, idWriteObject,
  2864.                 idWriteClass, idCancel, idSetBrowserDisplayText,
  2865.                 idSetBrowserNodeHeight, idNameKey, idDbData, idOn, idOff,
  2866.                 idSendMessage, idSetValue, idGetValue, idDDEFunc,idRootDBName,
  2867.                 idSelective, idBreadthFirst, idDepthFirst, idBestFirst,
  2868.                 idIgnore, idNoIgnore, idMinusEqual, idPlusEqual, idAnd,
  2869.                 idOr, idXor, idAlmostEqual, idSameEqual, idAppend,
  2870.                 idOpenParent, idCloseParent, idFor, idForAll, idDo, idLet,
  2871.                 idIf, idWhile, idInfix, idThen, idElse, idRight, idLeft,
  2872.                 idCenter, idMeterWN, idButtonWN, idTranscriptWN, idEditWN,
  2873.                 idDrawWN, idBitmapWN, idStaticWN, idSliderWN, idStateWN,
  2874.                 idLinePlotWN, idShowWidgetOptions, idMakeFunction,
  2875.                 idMakeRule, idMakeMethod, idEscapeFunc;
  2876.  
  2877. /*********************************************************************
  2878. **  ID and type of value returned by KAPPA function calls
  2879. **********************************************************************/
  2880. extern DWORD    KappaReturnSet;
  2881.  
  2882. /*********************************************************************
  2883. **  Screen size in pixels initialized to the Display terminal
  2884. **********************************************************************/
  2885. extern short    sXPixels, sYPixels;
  2886. extern short    IconXPixels, IconYPixels ;   /*  [mlm]  1/22/90 */
  2887.  
  2888. /*********************************************************************
  2889. **  Font for text display in dialog windows
  2890. **********************************************************************/
  2891. extern HFONT    hDlgTextFont;
  2892. extern HFONT    hDlgTitleFont;
  2893.  
  2894. /*********************************************************************
  2895. **  List of active rules for forward chaining
  2896. **********************************************************************/
  2897. extern  LISTID  idActiveRules;
  2898.  
  2899. /*********************************************************************
  2900. **  List of editor windows and menu ids in WINDOWS menu
  2901. **********************************************************************/
  2902. extern LISTID   idWindowsList;
  2903. extern LISTID   idMenuIdsList;
  2904.  
  2905. extern LISTID   idObjectEditors;
  2906. extern LISTID   idClassEditors;
  2907. extern LISTID   idFuncEditors;
  2908. extern LISTID   idRuleEditors;
  2909. extern LISTID   idGoalEditors;
  2910.  
  2911. /**********************************************************************
  2912. ** Version information
  2913. **********************************************************************/
  2914. #define VERSION_LEN     9               /* if modified, modify extern.h */
  2915. #define CUSTOMER_LEN    30              /* if modified, modify extern.h */
  2916. #define SERIALID_LEN    8               /* if modified, modify extern.h */
  2917. extern char    szVersion [];
  2918. extern char    szCustomer [];
  2919. extern char    szSerialID [];
  2920.  
  2921. /**********************************************************************
  2922. **      Extended Memory Flag
  2923. **********************************************************************/
  2924. extern WORD    wExtended;
  2925.  
  2926. /**********************************************************************
  2927. **      Number of Items, always updated on the KTOOLS window
  2928. **********************************************************************/
  2929. extern WORD    wNumObjects, wNumClasses, wNumFunctions;
  2930. extern WORD    wNumRules, wNumGoals;
  2931.  
  2932. /* ADDED BY TONY FOR NEW SYNTAX */
  2933. extern WORD wInputLineNumber;
  2934.  
  2935. extern HWND hDlgAbout ;
  2936.  
  2937. /********************************************
  2938. **  Window positioning
  2939. *********************************************/
  2940. extern BOOL     nFirstKAL, nFirstSession, nFirstRuleRel, nFirstInference,
  2941.                 nFirstTrace;
  2942.