home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 September / CHIP_CD_1997_09_PL.iso / software / testsoft / labwind / demo.6 / main / include / cmdsrvr.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-02  |  22.8 KB  |  313 lines

  1. /*============================================================================*/
  2. /*                        L a b W i n d o w s / C V I                         */
  3. /*----------------------------------------------------------------------------*/
  4. /*    Copyright (c) National Instruments 1993-1996.  All Rights Reserved.     */
  5. /*----------------------------------------------------------------------------*/
  6. /*                                                                            */
  7. /* Title:       cmdsrvr.h                                                     */
  8. /*                                                                            */
  9. /* Purpose:     Include file for LabWindows/CVI command server.               */
  10. /*              The command server allows a DDE client to execute a subset    */
  11. /*              of the commands that can be executed via the menus in the     */
  12. /*              LabWindows/CVI environment.                                   */
  13. /*                                                                            */
  14. /* Remarks:     The CVI command server accepts strings via DDE.               */
  15. /*              Each string contains a command name followed optionally       */
  16. /*              by a parameter.  The command name and the parameter are       */
  17. /*              separated by a comma.                                         */
  18. /*                                                                            */
  19. /*              CVI sends a string via DDE back to the client indicating      */
  20. /*              whether it could execute the command.  The string contains    */
  21. /*              an ASCII representation of an integer status value.           */
  22. /*              This integer is a negative number if an error prevented       */
  23. /*              CVI from starting the execution the command.                  */
  24. /*                                                                            */
  25. /*              NOTE:  Just because "0" is returned does not mean that        */
  26. /*                     the command was successful.  If CVI encounters an      */
  27. /*                     error in the process of executing the command, an      */
  28. /*                     error will be reported to the user interactively,      */
  29. /*                     just as if the command had been executed from a menu.  */
  30. /*                                                                            */
  31. /*              For some commands, the string also includes additional        */
  32. /*              information.  More details are included in this file.         */
  33. /*                                                                            */
  34. /*              The response string is sent via a warm or hot link.           */
  35. /*              The client receives it in its DDE client callback routine,    */
  36. /*              as the hData parameter in the XTYP_ADVDATA transaction.       */
  37. /*                                                                            */
  38. /*              To connect to the command server, the server name must be     */
  39. /*              "cvi", and the topic name must be "system".                   */
  40. /*                                                                            */
  41. /*              To set up a warm or hot link for the response, the item       */
  42. /*              name must be "status".                                        */
  43. /*                                                                            */
  44. /*============================================================================*/
  45.  
  46.  
  47. /*========================*/    /*========================*/   /*========================*/
  48. /* command name constants */    /* command name strings   */   /* parameters required    */
  49. /*========================*/    /*========================*/   /*========================*/
  50. #define NEW_PROJECT             "New Project"
  51. #define NEW_PROJECT_NO_SAVE     "New Project (no save)"
  52. #define OPEN_PROJECT            "Open Project"                 /* absolute path for an existing file */
  53. #define OPEN_PROJECT_NO_SAVE    "Open Project (no save)"       /* absolute path for an existing file;  user not prompted to save changed files */
  54. #define SAVE_PROJECT            "Save Project"                 /* optional:  absolute path under which to save project */
  55. #define ADD_TO_PROJECT          "Add To Project"               /* absolute path for an existing file */
  56. #define REMOVE_FROM_PROJECT     "Remove From Project"          /* absolute path or simple name for a file in the project */
  57. #define EXCLUDE_FROM_BUILD      "Exclude From Build"           /* absolute path or simple name for a file in the project */
  58. #define INCLUDE_IN_BUILD        "Include In Build"             /* absolute path or simple name for a file in the project */
  59. #define GET_EXCLUSION_STATE     "Get Exclusion State"          /* absolute path or simple name for a file in the project */
  60. #define UPDATE_FILE_FROM_DISK   "Update File From Disk"        /* absolute path for a file (has no effect unless file is a .h, .c, .obj, .lib, .dll, or .pth) */
  61. #define LOAD_INSTRUMENT         "Load Instrument"              /* absolute path for an existing file */
  62. #define UNLOAD_INSTRUMENT       "Unload Instrument"            /* absolute path for a loaded instrument .fp file */
  63. #define OPEN_SOURCE_FILE        "Open Source File"             /* absolute path for an existing text file */
  64. #define CLOSE_SOURCE_FILE       "Close Source File"            /* absolute path for file in a source window */
  65. #define OPEN_UIR_FILE           "Open UIR File"                /* absolute path for an existing UIR file */
  66. #define OPEN_FP_FILE            "Open FP File"                 /* absolute path for an existing function panel file */
  67. #define DOES_FILE_HAVE_CHANGES  "Does File Have Changes"       /* absolute path for an existing text or UIR file */
  68. #define PRINT_SOURCE_FILE       "Print Source File"            /* absolute pathname for a text file */
  69. #define PRINT_UIR_FILE          "Print UIR File"               /* absolute pathname for a UIR file */
  70. #define PRINT_FILES_IN_PROJECT  "Print Files In Project"       /* absolute pathname for a project file */
  71.  
  72. /***************************************************************************************/
  73. /* The next three commands take an absolute pathname to the file,                      */
  74. /* a printer name, drive name, and port name in the following format:                  */
  75. /*                                                                                     */
  76. /* <Command name>, "<file name>" "<printer name>" "<driver name>" "<port name>"        */
  77. /*                                                                                     */
  78. /* For example: Print Source File To, "c:\my file.c" "My Printer" "hppcl5.drv" "lpt1:" */
  79. /***************************************************************************************/
  80. #define PRINT_SOURCE_FILE_TO        "Print Source File To"
  81. #define PRINT_UIR_FILE_TO           "Print UIR File To"
  82. #define PRINT_FILES_IN_PROJECT_TO   "Print Files In Project To"
  83.  
  84. #define SAVE_FILE               "Save File"                    /* absolute path for a loaded file */
  85. #define SAVE_ALL                "Save All"
  86. #define SET_COMPILER_DEFINES    "Set Compiler Defines"         /* the desired compiler defines contents */
  87. #define COMPILE_FILE            "Compile File"                 /* absolute path or simple name for a C source file in the project */
  88. #define BUILD_PROJECT           "Build Project"
  89. #define SET_COMMAND_LINE        "Set Command Line"             /* the desired command line contents */
  90. #define RUN_PROJECT             "Run Project"                  
  91. #define RUN_PROJECT_NO_SAVE     "Run Project (no save)"        /* user not prompted to save files */
  92. #define APPEND_LINE_TO_IW       "Append Line To IW"            /* contents of line to add;  if leading white space needed, mark beginning with a percent (%) */
  93. #define CLEAR_IW                "Clear IW"
  94. #define BUILD_IW_PROGRAM        "Build IW Program"
  95. #define RUN_IW                  "Run IW"            
  96. #define RUN_IW_NO_SAVE          "Run IW (no save)"             /* user not prompted to save files */
  97. #define SUSPEND_EXECUTION       "Suspend Execution"
  98. #define CONTINUE_EXECUTION      "Continue Execution"
  99. #define TERMINATE_EXECUTION     "Terminate Execution"          /* if "atexit", functions registered with atexit() will be called */
  100. #define GET_NUM_PROJECT_FILES   "Get Num Project Files"
  101. #define GET_FILE_NAME           "Get File Name"                /* 0-based index of project file of which to return the simple file name */
  102. #define CREATE_OBJECT_FILE      "Create Object File"               /* absolute path for a loaded .c file, or simple name for a .c file in the project */
  103. #define CREATE_OBJS_ALL_CMPLRS  "Create Objects For All Compilers" /* absolute path for a loaded .c file, or simple name for a .c file in the project */
  104. #define SET_EXECUTABLE_PATH     "Set Executable Path"          /* absolute path for the executable file */
  105. #define CREATE_EXECUTABLE       "Create Executable"            
  106. #define IDENTIFY_FP_FILE        "Identify FP File"             /* absolute path for a loaded .fp file */
  107. #define GET_NEXT_FP_FUNCTION    "Get Next FP Function"
  108. #define GET_FP_PARAM_DATATYPE   "Get FP Param Datatype"        /* -1 for return value, 0 for first parameter, etc. */
  109. #define GET_FP_PARAM_NAME       "Get FP Param Name"            /* -1 for return value, 0 for first parameter, etc. */
  110. #define GET_FP_PARAM_PROTO_NAME "Get FP Param Proto Name"      /* -1 for return value, 0 for first parameter, etc. */
  111. #define SHOW_FUNCTION_PANEL     "Show Function Panel"          /* name of function in function panel file */
  112. #define CLOSE_FUNCTION_PANEL    "Close Function Panel"         /* name of function in function panel file */
  113. #define IDENTIFY_FP_FUNCTION    "Identify FP Function"         /* name of function in function panel file */
  114. #define GET_FP_PARAM_VALUE      "Get FP Param Value"           /* -1 for return value, 0 for first parameter, etc. */
  115. #define SET_FP_PARAM_VALUE      "Set FP Param Value"           /* -1 for return value, 0 for first parameter, etc. */
  116. #define COPY_FP_FUNCTION        "Copy FP Function"             /* name of function in function panel file */
  117. #define CUT_FP_FUNCTION         "Cut FP Function"              /* name of function in function panel file */
  118. #define PASTE_FP_FUNCTION       "Paste FP Function"           
  119. #define RENAME_FP_FUNCTION      "Rename FP Function"           /* new function name */ 
  120. #define CHANGE_INSTR_NAME       "Change Instr Name"            /* new instrument name */
  121. #define SET_WARNING_BOXES       "Set Warning Boxes"            /* 0 for disable, 1 for enable */
  122. #define SET_UNLOAD_DLLS         "Set Unload DLLs"              /* 0 for disable, 1 for enable */
  123. #define FAKE_KEYSTROKES         "Fake Keystrokes"              /* up to 64 blank-separated ASCII representations  */
  124.                                                                /* of keystroke values (in hexadecimal format);    */
  125. #define SET_KEYSTROKE_INTERVAL  "Set Keystroke Interval"       /* number of milliseconds to wait between processing keystrokes */
  126. #define GET_NUM_KEYSTROKES      "Get Num Keystrokes"
  127. #define GET_CVI_STATE           "Get CVI State"
  128. #define EXIT_CVI                "Exit CVI"
  129. #define EXIT_CVI_NO_SAVE        "Exit CVI (no save)"           /* user not prompted to save files */
  130.  
  131. /*=====================================================================*/
  132. /* NOTE:  Most commands complete execution before the command server   */
  133. /*        sends the response string.  The following commands           */
  134. /*        are exceptions and are executed after the command server     */
  135. /*        sends the response string:                                   */
  136. /*              RUN_PROJECT                                            */
  137. /*              RUN_INT_WIN                                            */
  138. /*              SUSPEND_PROGRAM_EXEC                                   */
  139. /*              CONTINUE_PROGRAM_EXEC                                  */
  140. /*              TERMINATE_PROGRAM_EXEC                                 */
  141. /*              EXIT_CVI                                               */
  142. /*=====================================================================*/
  143.  
  144.  
  145. /*=====================================================================*/
  146. /* The following enum specifies the absolute value of the negative     */
  147. /* error codes that can be returned by the command server.             */
  148. /* Examples:                                                           */
  149. /*    If the command contained no errors, the string "0" is returned.  */
  150. /*    If the command name was invalid, the string "-2" is returned     */
  151. /*    (the ASCII representation of -kCmdErr_BadCommandName).           */
  152. /* Remember that "0" indicates only that the command was executed,     */
  153. /* not that it succeeded.                                              */
  154. /*=====================================================================*/
  155. enum {
  156.     kCmdErr_None=0,     /* no error */
  157.     kCmdErr_CommandNameMissing,
  158.     kCmdErr_BadCommandName,
  159.     kCmdErr_PathnameMissing,
  160.     kCmdErr_BadPathname,              /* invalid pathname syntax */
  161.     kCmdErr_PathnameNotAbsolute,      /* example:  "c:\x\y.c" is an absolute path,  "x\y.c" is not */
  162.     kCmdErr_PathnameNotAbsOrSimple,   /* example:  "y.c" is a simple file name,  "x\y.c" is not */
  163.     kCmdErr_PathnameNotInProject,
  164.     kCmdErr_FileDoesNotExist,
  165.     kCmdErr_FileIsNotLoaded,
  166.     kCmdErr_RunningUserProgram,
  167.     kCmdErr_ExecutionIsSuspended,
  168.     kCmdErr_NoProgramRunning,
  169.     kCmdErr_NoExecutionSuspended,
  170.     kCmdErr_NotRunningOrSuspended,
  171.     kCmdErr_FileNotExcludable,
  172.     kCmdErr_NotAnInstrument,
  173.     kCmdErr_NotASourceOrTextFile,
  174.     kCmdErr_NotACSourceFile,
  175.     kCmdErr_WindowMustRemainOpen,    /* if execution is suspended in that window, and the project window is not visible */
  176.     kCmdErr_LineTooLong,             /* lines in source windows are limited to 254 characters */
  177.     kCmdErr_OutOfMemory,
  178.     kCmdErr_WaitingForUserResponse,  /* CVI is waiting for user response to a dialog box */
  179.     kCmdErr_NotAnFPFile,
  180.     kCmdErr_NoFPFileIdentified,      /* need to send IDENTIFY_FP_FILE command */
  181.     kCmdErr_NoFPFunctionIdentified,  /* need to send IDENTIFY_FP_FUNCTION command */
  182.     kCmdErr_FunctionNameMissing,
  183.     kCmdErr_FunctionNameNotInFPFile,
  184.     kCmdErr_ParamIndexMissing,
  185.     kCmdErr_NotAValidParamIndex,     /* must be integer greater than or equal to -1 */
  186.     kCmdErr_UnableToReadFPFile,
  187.     kCmdErr_NewInstrumentNameMissing,
  188.     kCmdErr_NewFunctionNameMissing,
  189.     kCmdErr_MiscErrReportedToUser,   /* action-specific error reported to end-user via dialog box */
  190.     kCmdErr_InvalidIntegerValue,
  191.     kCmdErr_NotAValidProjectFileIndex,
  192.     kCmdErr_ProjectIsUntitled,
  193.     kCmdErr_NotASourceFile,
  194.     kCmdErr_NotAUIRFile,
  195.     kCmdErr_NotAProjectFile,
  196.     kCmdErr_KeystrokeQueueOverflow,     /* maximum unprocessed fake keystrokes is 256 */
  197.     kCmdErr_InvalidKeystrokeInterval,
  198.     kCmdErr_NewProjectFailed,
  199.     kCmdErr_OpenProjectFailed,
  200.     kCmdErr_FileNotIncludable
  201. };
  202.  
  203. /*======================================================================*/
  204. /* Commands that return information in addition to the error code       */
  205. /* do so by appending them after the error code and at least one        */
  206. /* white space character.   In general, the additional information      */
  207. /* is present only if the error code is 0.                              */
  208. /*                                                                      */
  209. /* The following describes the additional information returned by       */
  210. /* the commands that do so:                                             */
  211. /*                                                                      */
  212. /*    DOES_FILE_HAVE_CHANGES:                                           */
  213. /*                     1 if file has unsaved changes, 0 otherwise.      */
  214. /*                                                                      */
  215. /*    GET_CVI_STATE:   a.  Whether the project is compiled and linked   */
  216. /*                         (1 for yes, 0 for no).                       */
  217. /*                     b.  The execution state for the project          */
  218. /*                         (2 for suspended, 1 for executing,           */
  219. /*                          0 otherwise).                               */
  220. /*                     c.  Whether the interactive window is compiled   */
  221. /*                         and linked.                                  */
  222. /*                     d.  The execution state of the interactive       */
  223. /*                         window (2 for suspended, 1 for executing,    */
  224. /*                         0 otherwise).                                */
  225. /*                     e.  Whether CVI is waiting for user response     */
  226. /*                         to a dialog box.                             */
  227. /*                     f.  The number of unprocessed keystrokes from    */
  228. /*                         FAKE_KEYSTROKE commands.                     */
  229. /*                                                                      */
  230. /*      Example:  "0 1 2 1 1 0"                                         */
  231. /*                 0 - the GET_CVI_STATE command was accepted as        */
  232. /*                     valid by the CVI command server.                 */
  233. /*                 1 - the project is compiled and linked.              */
  234. /*                 2 - project execution is suspended.                  */
  235. /*                 1 - the interactive window program is compiled       */
  236. /*                     and linked.                                      */
  237. /*                 1 - the interactive window program execution is      */
  238. /*                     suspended.                                       */
  239. /*                 0 - CVI is not waiting for user response to a        */
  240. /*                     dialog box                                       */
  241. /*                                                                      */
  242. /*    GET_NEXT_FP_FUNCTION:                                             */
  243. /*                 If no more functions, "0".                           */
  244. /*                 Otherwise, "1" followed by function name.            */
  245. /*                 Examples:  "0 0"  or "0 1 MyFunction"                */
  246. /*                                                                      */
  247. /*    GET_FP_PARAM_DATATYPE:                                            */
  248. /*                 If no control with that parameter index, "0".        */
  249. /*                 Otherwise, "1" followed by the C data type of the    */
  250. /*                 parameter.  For example, if the function panel       */
  251. /*                 control is an input control of type 'int',           */
  252. /*                 then "0 1 int" would be returned.  If the function   */
  253. /*                 panel control is an output control of type 'int',    */
  254. /*                 "0 1 int *" would be returned.                       */
  255. /*                 If the function panel control is an input or output  */
  256. /*                 control of type 'int []', "0 1 int []" would be      */
  257. /*                 returned.                                            */
  258. /*                                                                      */
  259. /*    GET_FP_PARAM_NAME:                                                */
  260. /*                 If no control with that parameter index, "0".        */
  261. /*                 Otherwise, "1" followed by the control label.        */
  262. /*                                                                      */
  263. /*    GET_FP_PARAM_PROTO_NAME:                                          */
  264. /*                 If no control with that parameter index, "0".        */
  265. /*                 Otherwise, "1" followed by the name would appear     */
  266. /*                 in the function prototype if you selected            */
  267. /*                 the Generate Function Prototypes command from the    */
  268. /*                 Options menu of the Function Tree Editor.            */
  269. /*                                                                      */
  270. /*    GET_FP_PARAM_VALUE:                                               */
  271. /*                 If no control with that parameter index, "0".        */
  272. /*                 Otherwise, "1" followed by the string that           */
  273. /*                 is in the function panel control.                    */
  274. /*                 More precisely, the string which appears for the     */
  275. /*                 control in the generated code at the bottom of the   */
  276. /*                 function panel window.                               */
  277. /*                 Note:  The string may be empty.                      */
  278. /*                                                                      */
  279. /*    SET_FP_PARAM_VALUE:                                               */
  280. /*                 If no control with that parameter index, "0".        */
  281. /*                 Otherwise, "1".                                      */
  282. /*                                                                      */
  283. /*    GET_NUM_PROJECT_FILES:                                            */
  284. /*                 The number of files in the project.                  */
  285. /*                                                                      */
  286. /*    GET_FILE_NAME:                                                    */
  287. /*                 The file name (excluding the directory path)         */
  288. /*                 of the file in the project identified by the         */
  289. /*                 zero-based index.                                    */
  290. /*                                                                      */
  291. /*    GET_EXCLUSION_STATE:                                              */
  292. /*                 "1" if file is excluded, "0" if not                  */
  293. /*                                                                      */
  294. /*    CREATE_OBJECT_FILE:                                               */
  295. /*                 "1" if object file was successfully created,         */
  296. /*                 "0" if not                                           */
  297. /*                                                                      */
  298. /*    CREATE_EXECUTABLE:                                                */
  299. /*                 "1" if executable file successfully created,         */
  300. /*                 "0" if not                                           */
  301. /*                                                                      */
  302. /*    GET_NUM_KEYSTROKES:                                               */
  303. /*                 The number of fake keystrokes sent in previous       */
  304. /*                 commands but not yet processed.                      */
  305. /*                                                                      */
  306. /*======================================================================*/
  307.  
  308. enum {
  309.     kExecution_No,
  310.     kExecution_Running,
  311.     kExecution_Suspended
  312. };
  313.