home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 24 / CD_ASCQ_24_0995.iso / vrac / vbos201.zip / VBOSSAPI.BAS < prev    next >
BASIC Source File  |  1995-03-20  |  28KB  |  515 lines

  1. Option Explicit
  2.  
  3. ' ===============================================================
  4. ' = VBossAPI.DLL v01.01.70 Interface Declarations               =
  5. ' ===============================================================
  6. '
  7. '  @@    @@ @@@@@@                             @    @@@@@@  @@@@
  8. '  @@    @@  @@  @@                           @@@    @@  @@  @@
  9. '  @@    @@  @@  @@  @@@@@   @@@@@   @@@@@   @@ @@   @@  @@  @@
  10. '  @@    @@  @@@@@  @@   @@ @@   @@ @@   @@ @@   @@  @@  @@  @@
  11. '  @@    @@  @@  @@ @@   @@  @@@     @@@    @@@@@@@  @@@@@   @@
  12. '   @@  @@   @@  @@ @@   @@    @@@     @@@  @@   @@  @@      @@
  13. '    @@@@    @@  @@ @@   @@ @@   @@ @@   @@ @@   @@  @@      @@
  14. '     @@    @@@@@@   @@@@@   @@@@@   @@@@@  @@   @@ @@@@    @@@@
  15. '
  16. ' ...............................................................
  17. ' . V isual                                                     .
  18. ' . B asic                                                      .
  19. ' . O ptimized                                                  .
  20. ' . S cript                                                     .
  21. ' . S upport                                                    .
  22. ' . A pplication                                                .
  23. ' . P rogramming                                                .
  24. ' . I nterface                                                  .
  25. ' ===============================================================
  26. ' = Copyright ⌐ 1994,95 Greg Truesdell                          =
  27. ' ===============================================================
  28.  
  29. ' ===============================================================
  30. ' = RegisterVBossAPI()                                          =
  31. ' =     Used to register the DLL                                =
  32. ' ===============================================================
  33. '
  34. Declare Function RegisterVBossAPI Lib "VBossAPI.DLL" (ByVal UserID As String, ByVal RegID As String) As Integer
  35. Declare Function CreateScrObject Lib "VBossAPI.DLL" () As Integer
  36. Declare Sub DestroyScrObject Lib "VBossAPI.DLL" (ByVal idx As Integer)
  37.  
  38. '
  39. ' VBossAPI Limits Constants
  40. '
  41. Global Const OSS_MAX_WORD_LEN = 255         '{ maximum word length }
  42.  
  43. ' ***************************************************************************************
  44. ' * Expression Evaluation Routines                                                      *
  45. ' *                                                                                     *
  46. ' *     Evaluate, Test and return Error information.                                    *
  47. ' *                                                                                     *
  48. ' ***************************************************************************************
  49.  
  50. ' ===============================================================
  51. ' = EvalExpression()                                            =
  52. ' =     Evaluates REAL & INT expressions in infix notation and  =
  53. ' =     supports */+- and ABS, ARCTAN, COS, EXP, LN, SQR and    =
  54. ' =     SQRT.                                                   =
  55. ' =                                                             =
  56. ' =     Evaluates the text formula in ExprStr and returns the   =
  57. ' =     text representation of the answer.  Supports the        =
  58. ' =     dynamic allocation of variables and can use variables   =
  59. ' =     already declared.                                       =
  60. ' ===============================================================
  61. '
  62. Declare Function EvalExpression Lib "VBossAPI.DLL" (ByVal ExprStr As String, rc As Integer) As String
  63.  
  64. ' ===============================================================
  65. ' = TestNumExpr()                                               =
  66. ' =     Test the relation between two numeric expressions.      =
  67. ' ===============================================================
  68. '
  69. Declare Function TestNumExpr Lib "VBOSSAPI.DLL" (ByVal LExpr As String, ByVal Op As String, ByVal RExpr As String, Success As Integer) As Integer
  70.  
  71. ' ===============================================================
  72. ' = EvalErrorString()                                           =
  73. ' =     Returns the error string describing the last error in   =
  74. ' =     the evaluation of an expression by EvalExpression. If   =
  75. ' =     EvalExpression returns FALSE in <rc>, then use this     =
  76. ' =     call to determine the cause of the error.  The          =
  77. ' =     internal error code is RETURNED in <errcode>            =
  78. ' =                                                             =
  79. ' = Note:   The error code and error string are reset after     =
  80. ' =         a call to this function.                            =
  81. ' ===============================================================
  82. '
  83. Declare Function EvalErrorString Lib "VBossAPI.DLL" (errcode As Integer) As String
  84.  
  85.     '
  86.     '  EvalExpression Error Codes (returned by EvalErrorString())
  87.     '
  88.     Global Const EXPR_SYNTAX_ERROR = 1
  89.     Global Const EXPR_PARAMETER_MISSING = 2
  90.     Global Const EXPR_PARAMETER_COUNT_ERROR = 3
  91.     Global Const EXPR_INVALID_PARAMETER = 4
  92.     Global Const EXPR_OVERFLOW = 5
  93.     Global Const EXPR_COMMA_MISSING = 6
  94.     Global Const EXPR_MISSING_RPAREN = 7
  95.     Global Const EXPR_TYPE_MISMATCH = 8
  96.     Global Const EXPR_INVALID_IDENTIFIER = 9
  97.     Global Const EXPR_PARAMETERS_NOT_ALLOWED = 10
  98.     Global Const EXPR_EXPECTED_FACTOR = 11
  99.     Global Const EXPR_EXPECTED_TERM = 12
  100.     Global Const EXPR_EXPECTED_EXPRESSION = 13
  101.     Global Const EXPR_ZERO_DIVIDE = 14
  102.     Global Const EXPR_OUT_OF_MEMORY = 15
  103.     Global Const EXPR_GARBAGE_FOLLOWS = 16
  104.     Global Const EXPR_VARIABLE_EQUATE_ERROR = 17
  105.     Global Const EXPR_INVALID_FUNCTION = 18
  106.  
  107. ' ***************************************************************************************
  108. ' * Token Parsing Support Routines                                                      *
  109. ' *                                                                                     *
  110. ' *     This section defines the Token Parsing Routines.  Token parsing uses a number   *
  111. ' *     of internal defaults.  These include:                                           *
  112. ' *                                                                                     *
  113. ' *         Word Delimiters:    All characters from Chr(1) to Chr(32)                   *
  114. ' *         Operator Tokens:    +-*/"';:[]{}()!@#$%^&=<>,                               *
  115. ' *                                                                                     *
  116. ' *             Operator tokens reserve the first 32 token codes (0..31), so your       *
  117. ' *             token codes must start at 32+                                           *
  118. ' *                                                                                     *
  119. ' ***************************************************************************************
  120.  
  121. ' ===============================================================
  122. ' = AddKeyword()                                                =
  123. ' =     Adds a keyword and related keycode to the keyword list  =
  124. ' ===============================================================
  125. Declare Function AddKeyword Lib "VBossAPI.DLL" (ByVal kw As String, ByVal kc As Integer) As Integer
  126.     '
  127.     '   AddKeyword() Return Codes
  128.     '
  129.     Global Const AKW_NO_MORE_ROOM = -1      '{ no more keyword space }
  130.     Global Const AKW_INVALID_CHAR = -2      '{ invalid character in keyword }
  131.     Global Const AKW_DUPLICATE_KEYWORD = -3 '{ duplicate keyword }
  132.     Global Const AKW_KEYWORD_TOO_LONG = -4  '{ keyword too long }
  133.     Global Const AKW_INVALID_TOKEN = -5     '{ invalid token (keycode) value }
  134.                         '{ - negative numbers not allowed }
  135.     Global Const AKW_TYPE_MISMATCH = -6     '{ AddVariable() type mismatch }
  136.     Global Const AKW_OVERFLOW = -7          '{ AddVariable() overflow }
  137.     '
  138.     '   AddKeyword() Limits
  139.     '
  140.     Global Const AKW_MAX_KEYWORD_LEN = 16   '{ maximum keyword length }
  141.     Global Const AKW_MAX_KEYWORDS = 256     '{ maximum number of keywords }
  142.  
  143. ' ===============================================================
  144. ' = NextToken()                                                 =
  145. ' =     Starting at <start> returns the next token code found   =
  146. ' =     in <st> in <token>. <start> is returned with the next   =
  147. ' =     character index in the string. The function returns     =
  148. ' =     the token text.                                         =
  149. ' =                                                             =
  150. ' = Note:                                                       =
  151. ' =         The <token> parameter must be an integer variable   =
  152. ' =         since this function returns the token value         =
  153. ' =         associated with the token found. See constant       =
  154. ' =         declarations below.                                 =
  155. ' ===============================================================
  156. ' = PeekNextToken() gets the next token without updating the    =
  157. ' = <start> (character index) variable                          =
  158. ' ===============================================================
  159. '
  160. Declare Function NextToken Lib "VBossAPI.DLL" (start As Integer, ByVal st As String, Token As Integer) As String
  161. Declare Function PeekNextToken Lib "VBossAPI.DLL" (ByVal start As Integer, ByVal st As String, Token As Integer) As String
  162.     '
  163.     '   NextToken Return Codes (in <token>)
  164.     '
  165.     '   Note: Positive numbers >= NT_MAX_OPERATORS are valid tokens
  166.     '
  167.     Global Const NT_MAX_OPERATORS = 32      ' reserved operator tokens
  168.     Global Const NT_PAST_EOL = -1           '{ end of the line }
  169.     Global Const NT_NO_KEYWORDS = -2        '{ no keywords in keyword DB }
  170.     Global Const NT_TOKEN_NOTFOUND = -3     '{ next word can not be tokenized }
  171.     Global Const NT_NO_FREE_MEMORY = -4     '{ no heap available for buffer }
  172.     Global Const NT_VARIABLE_FOUND = -5     '{ keyword found was a variable }
  173.     Global Const NT_USER_ERROR = -99        '{ added as a convience, not used internally }
  174.     Global Const NT_LABEL_FOUND = -6        '{ keyword parsed was a label name }
  175.     Global Const NT_FUNCTION = -7           '{ keyword parsed was a function name }
  176.     Global Const NT_PROCEDURE = -8          '{ keyword parsed was a procedure name }
  177.  
  178.  
  179.     '
  180.     '  Operator Constants - Tokens returned by NextToken() for operators
  181.     '
  182.     '  + - * / " ' ; : [ ] { } ( ) ! @ # $ % ^ & = < > ,
  183.     '
  184.     Global Const NT_PLUS = 1
  185.     Global Const NT_MINUS = 2
  186.     Global Const NT_TIMES = 3
  187.     Global Const NT_DIVIDE = 4
  188.     Global Const NT_DBL_QUOTE = 5
  189.     Global Const NT_SNG_QUOTE = 6
  190.     Global Const NT_SEMICOLON = 7
  191.     Global Const NT_COLON = 8
  192.     Global Const NT_LEFTBRACKET = 9
  193.     Global Const NT_RIGHTBRACKET = 10
  194.     Global Const NT_LEFTBRACE = 11
  195.     Global Const NT_RIGHTBRACE = 12
  196.     Global Const NT_LEFTPAREN = 13
  197.     Global Const NT_RIGHTPAREN = 14
  198.     Global Const NT_EXCLAMATION = 15
  199.     Global Const NT_AT = 16
  200.     Global Const NT_POUND = 17
  201.     Global Const NT_DOLLAR = 18
  202.     Global Const NT_PERCENT = 19
  203.     Global Const NT_CARET = 20
  204.     Global Const NT_AMPERSAND = 21
  205.     Global Const NT_EQUAL = 22
  206.     Global Const NT_LESSTHAN = 23
  207.     Global Const NT_GREATERTHAN = 24
  208.     Global Const NT_COMMA = 25
  209.  
  210. ' ===============================================================
  211. ' = KeywordCount()                                              =
  212. ' =     Returns the number of keywords in the keyword DB.       =
  213. ' ===============================================================
  214. '
  215. Declare Function KeywordCount% Lib "VBossAPI.DLL" ()
  216.  
  217. ' ===============================================================
  218. ' = GetKeyword()                                                =
  219. ' =     Return the keyword text for keyword #<idx>.             =
  220. ' =                                                             =
  221. ' = Note:                                                       =
  222. ' =         This function returns the keyword text for the      =
  223. ' =         <idx>-th entry in the keyword list, NOT by the      =
  224. ' =         keyword's token value.  Operators are not included  =
  225. ' =         in the keyword list.                                =
  226. ' =                                                             =
  227. ' =         Use with KeywordCount() to locate all keywords      =
  228. ' =         in the keyword list.                                =
  229. ' =                                                             =
  230. ' =         The keyword list is zero based (0 to MAX_KEYWORDS-1)=
  231. ' ===============================================================
  232. '
  233. Declare Function GetKeyword Lib "VBossAPI.DLL" (ByVal idx As Integer) As String
  234.  
  235. ' ===============================================================
  236. ' = GetKeywordToken()                                           =
  237. ' =     Return the keyword token for keyword <kw>.              =
  238. ' =                                                             =
  239. ' = Note:                                                       =
  240. ' =         This function returns the token value of a keyword. =
  241. ' =         The token value is the value you passed in the      =
  242. ' =         AddKeyword() function <kc> parameter                =
  243. ' ===============================================================
  244. '
  245. Declare Function GetKeywordToken Lib "VBossAPI.DLL" (ByVal kw As String) As Integer
  246.  
  247. ' ===============================================================
  248. ' = GetTokenKeyword()                                           =
  249. ' =     Returns the text Keyword for the token code passed.     =
  250. ' =                                                             =
  251. ' = Note:                                                       =
  252. ' =         This function recalls the text Keyword based on the =
  253. ' =         token value you passed in the AddKeyword()          =
  254. ' =         function                                            =
  255. ' ===============================================================
  256. '
  257. Declare Function GetTokenKeyword Lib "VBossAPI.DLL" (ByVal Token As Integer) As String
  258.  
  259.  
  260. ' ===============================================================
  261. ' = SaveKeywords()                                              =
  262. ' =     Save the keyword list to file                           =
  263. ' =     Returns 0 if successful, -1 if not                      =
  264. ' ===============================================================
  265. '
  266. ' Keyword file Record type
  267. '
  268. Type KeywordRecord
  269.  
  270.     KeywordLen  As String * 1   ' byte value 0..16
  271.     KeywordStr  As String * 16
  272.     KeyToken    As Integer
  273.     Reserved1   As Integer
  274.     Reserved2   As Long
  275.  
  276. End Type
  277. '
  278. Declare Function SaveKeywords Lib "VBossAPI.DLL" (ByVal filename As String) As Integer
  279.  
  280. ' ===============================================================
  281. ' = LoadKeywords()                                              =
  282. ' =     Load the keyword list from file                         =
  283. ' =     Returns 0 if successful, -1 if not                      =
  284. ' ===============================================================
  285. '
  286. Declare Function LoadKeywords Lib "VBossAPI.DLL" (ByVal filename As String) As Integer
  287.  
  288. ' ===============================================================
  289. ' = ZapKeywords()                                               =
  290. ' =     Erases all keywords.                                    =
  291. ' ===============================================================
  292. '
  293. Declare Sub ZapKeywords Lib "VBossAPI.DLL" ()
  294.  
  295. ' ===============================================================
  296. ' = NT_CodeString()                                             =
  297. ' =     Decode the context of a token code                      =
  298. ' ===============================================================
  299. '
  300. Declare Function NT_CodeString Lib "VBossAPI.DLL" (ByVal Token As Integer) As String
  301.  
  302. ' ===============================================================
  303. ' = NT_Operators()                                              =
  304. ' =     Returns a string containing the operators list.         =
  305. ' ===============================================================
  306. Declare Function NT_Operators Lib "VBossAPI.DLL" () As String
  307.  
  308. ' ===============================================================
  309. ' = DefTokenDelims()                                            =
  310. ' =     Returns a VBStr with the default token delimiters.      =
  311. ' ===============================================================
  312. '
  313. Declare Function DefTokenDelims Lib "VBassAPI.DLL" () As String
  314.  
  315. ' ***************************************************************************************
  316. ' * Variable Related Functions                                                          *
  317. ' ***************************************************************************************
  318.  
  319. ' ===============================================================
  320. ' = AddVariable()                                               =
  321. ' =     Adds a new variable to the variable DB. The data type   =
  322. ' =     is determined by the value of <vtype>. The data to be   =
  323. ' =     stored is provided as a string. <vdata>                 =
  324. ' =                                                             =
  325. ' = Note:                                                       =
  326. ' =         See AKW_* return codes. This function returns the   =
  327. ' =         same error return codes as AddKeyword()             =
  328. ' =
  329. ' ===============================================================
  330. '
  331. Declare Function AddVariable Lib "VBossAPI.DLL" (ByVal vname As String, ByVal vtype As Integer, ByVal vdata As String) As Integer
  332.     '
  333.     ' Variable Type Constants
  334.     '
  335.     Global Const VTNONE = 0
  336.     Global Const VTSTRING = 1
  337.     Global Const VTINTEGER = 2
  338.     Global Const VTFLOAT = 3
  339.     Global Const VTPROCEDURE = 4    ' defined to help implement procedures by name
  340.     Global Const VTFUNCTION = 5     ' defined to help implement functions by name
  341.     Global Const VTLABEL = 6        ' defined to help implement labels
  342.  
  343. ' ===============================================================
  344. ' = VariableCount()                                             =
  345. ' =     Returns the number of variables in the variable DB.     =
  346. ' ===============================================================
  347. '
  348. Declare Function VariableCount% Lib "VBossAPI.DLL" ()
  349.  
  350. ' ===============================================================
  351. ' = GetVariable()                                               =
  352. ' =     Searches the variable list for <vname>.                 =
  353. ' =                                                             =
  354. ' =     If found returns the variable type in <vtype> and a     =
  355. ' =     string containing a text representation of the variable =
  356. ' =     contents.                                               =
  357. ' =                                                             =
  358. ' =     if NOT found, returns -1 in vartype and a null string.  =
  359. ' =                                                             =
  360. ' ===============================================================
  361. '
  362. Declare Function GetVariable Lib "VBossAPI.DLL" (ByVal vname As String, vtype As Integer) As String
  363.  
  364. ' ===============================================================
  365. ' = SetVariable()                                               =
  366. ' =     Sets the variable <vname> to the new value in <vdata>.  =
  367. ' =     <vdata> is a string, so the variable contents are       =
  368. ' =     checked for consistancy with the variable type.         =
  369. ' =                                                             =
  370. ' =     Returns an error code if the variable type is a         =
  371. ' =     mismatch or if the variable doesnot exist.              =
  372. ' =                                                             =
  373. ' =     Otherwise returns the variable type on success.         =
  374. ' ===============================================================
  375. '
  376. Declare Function SetVariable Lib "VBossAPI.DLL" (ByVal vname As String, ByVal vdata As String) As Integer
  377.  
  378. ' ===============================================================
  379. ' = ZapVariables()                                              =
  380. ' =     Erases all variables.                                   =
  381. ' ===============================================================
  382. '
  383. Declare Sub ZapVariables Lib "VBossAPI.DLL" ()
  384.  
  385. ' ***************************************************************************************
  386. ' * Word Parsing Support Routines                                                       *
  387. ' *                                                                                     *
  388. ' *     This section defines the Word Parsing Routines.  Word parsing differs from      *
  389. ' *     token parsing in that no default assumptions are made as to what delimits       *
  390. ' *     a word.  Most functions require a string containing the delimiters you want     *
  391. ' *     to use.                                                                         *
  392. ' *                                                                                     *
  393. ' * Note:                                                                               *
  394. ' *         A word is defined as up to 255 characters delimited by the delimiter        *
  395. ' *         set.  Any set of characters located that is > 255 will be truncated.        *
  396. ' ***************************************************************************************
  397.  
  398. ' ===============================================================
  399. ' = ParseStr()                                                  =
  400. ' =     Parse string <st> starting at zero-based character      =
  401. ' =     <start> using <delims> as a string of word delimiters.  =
  402. ' =                                                             =
  403. ' = Returns integer <start> with index to next word or -1 if no =
  404. ' =     more.                                                   =
  405. ' ===============================================================
  406. '
  407. Declare Function ParseStr Lib "VBossAPI.DLL" (start As Integer, ByVal st As String, ByVal delims As String) As String
  408.  
  409. ' ===============================================================
  410. ' = ParseUntil()                                                =
  411. ' =     Parse string st starting at zero-based character start  =
  412. ' =     using cset as a string of word delimiters.  Stop at     =
  413. ' =     the first occurance of any character in the cset.       =
  414. ' =                                                             =
  415. ' = Returns integer <start> with index to next word or -1 if no =
  416. ' =     more.                                                   =
  417. ' ===============================================================
  418. '
  419. Declare Function ParseUntil Lib "VBossAPI.DLL" (start As Integer, ByVal st As String, ByVal cset As String) As String
  420.  
  421. ' ===============================================================
  422. ' = WordCount()                                                 =
  423. ' =     Count the number of words in string <st> using the      =
  424. ' =     string <delims> as word delimiters                      =
  425. ' ===============================================================
  426. '
  427. Declare Function WordCount Lib "VBossAPI.DLL" (ByVal st As String, ByVal delims As String) As Integer
  428.  
  429. ' ===============================================================
  430. ' = GetWordAt()                                                 =
  431. ' =     Return word number <idx> in string <st> using <delims>  =
  432. ' =     as a set of word delimiters                             =
  433. ' ===============================================================
  434. '
  435. Declare Function GetWordAt Lib "VBossAPI.DLL" (ByVal idx As Integer, ByVal st As String, ByVal delims As String) As String
  436.  
  437. ' ===============================================================
  438. ' = LocateWord()                                                =
  439. ' =     Return the character index in <str> of the <idx>th word =
  440. ' =     (in <str>).                                             =
  441. ' ===============================================================
  442. '
  443. Declare Function LocateWord Lib "VBossAPI.DLL" (ByVal idx As Integer, ByVal st As String, ByVal delims As String) As Integer
  444.  
  445.  
  446. ' ***************************************************************************************
  447. ' * Misc. String Functions                                                              *
  448. ' ***************************************************************************************
  449.  
  450. ' =======================================================================
  451. ' = LPGetVBStr()                                                        =
  452. ' =     Convert the zero-terminated string (by pointer) to a VB String. =
  453. ' =======================================================================
  454. '
  455. Declare Function LPGetVBStr Lib "VBossAPI" (ByVal pStr As Long) As String
  456.  
  457. ' =======================================================================
  458. ' = VBStrGetLP()                                                        =
  459. ' =     Return a pointer to the lpsz string in a VB String.             =
  460. ' =======================================================================
  461. '
  462. Declare Function VBStrGetLP Lib "VBossAPI" (ByVal pStr As String) As Long
  463.  
  464. ' ===============================================================
  465. ' = PackSpaces()                                                =
  466. ' =     Pack multiple spaces into one space in string <st>      =
  467. ' =                                                             =
  468. ' = Note: Tabs are packed as well (single space)                =
  469. ' ===============================================================
  470. '
  471. Declare Function PackSpaces Lib "VBossAPI.DLL" (ByVal st As String) As String
  472.  
  473.  
  474. ' ===============================================================
  475. ' = FullPath()                                                  =
  476. ' =     Returns the expanded file path for the filename <fn>    =
  477. ' ===============================================================
  478. '
  479. Declare Function FullPath Lib "VBossAPI.DLL" (ByVal fn As String) As String
  480.  
  481. ' ===============================================================
  482. ' = NameOnly()                                                  =
  483. ' =     Returns the name part of the filename <fn>              =
  484. ' ===============================================================
  485. '
  486. Declare Function NameOnly Lib "VBossAPI.DLL" (ByVal fn As String) As String
  487.  
  488. ' ===============================================================
  489. ' = ExtOnly()                                                   =
  490. ' =     Returns the extension (.ext) for the filename <fn>      =
  491. ' ===============================================================
  492. '
  493. Declare Function ExtOnly Lib "VBossAPI.DLL" (ByVal fn As String) As String
  494.  
  495. ' ===============================================================
  496. ' = DirOnly()                                                   =
  497. ' =     Returns the directory part of the filename <fn>         =
  498. ' =     including last "\"                                      =
  499. ' ===============================================================
  500. '
  501. Declare Function DirOnly Lib "VBossAPI.DLL" (ByVal fn As String) As String
  502.  
  503. ' ===============================================================
  504. ' = ReplacePath()                                               =
  505. ' =     Replaces the path in <fn> with the path in <np>         =
  506. ' ===============================================================
  507. '
  508. Declare Function ReplacePath Lib "VBossAPI.DLL" (ByVal fn As String, ByVal np As String) As String
  509.  
  510.  
  511. ' *************************
  512. ' ** END OF VBOSSAPI.BAS **
  513. ' *************************
  514.  
  515.