home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_refer / vb_pxen / readme.txt next >
Text File  |  1992-01-03  |  16KB  |  441 lines

  1.                                    
  2.                                    
  3.                                    
  4.                                 PREFACE
  5.                                    
  6.                                    
  7. I am placing this code and documentation in the public domain in the
  8. hopes that others may find it useful. You are free to use, modify and
  9. distribute it as you see fit.  This code is provided on an as-is
  10. basis; I have tested much of it but it is not guaranteed to be bug-
  11. free.  If you find errors or have suggestions for improvement, you can
  12. send them to me if you'd like.
  13.  
  14. Sharon F. Dooley
  15. January 2, 1992
  16. CompuServe ID 70740,2330
  17.  
  18. PAL and PARADOX are trademarks of Borland.  Visual Basic is a
  19. trademark of Microsoft.
  20.  
  21.                                    
  22.                                    
  23.                                    
  24.               A VISUAL BASIC -- PARADOX ENGINE INTERFACE
  25.                                    
  26.                                    
  27.  
  28. Introduction
  29.  
  30. This Visual Basic interface to the Paradox Engine insulates the VB
  31. programmer from some of the quirks of the Paradox Engine as well as
  32. from some of the differences between VB and a C DLL.  It also permits
  33. the VB programmer to work with VB's native data types while
  34. simultaneously allowing the Paradox user or PAL (Paradox Application
  35. Language) programmer to work with the native Paradox data types.  For
  36. example, VB has a wealth of date manipulation functions that want the
  37. VB date-serial date format.  The PAL date functions naturally expect a
  38. Paradox date format.  The interface layer translates to and from the
  39. database format as data is retrieved from or stored in a Paradox
  40. table.  The separate interface layer also provides a measure of
  41. independence from the particular DBMS.
  42.  
  43. VB programmers can access the engine by calling a set of functions
  44. which parallel the engine's C functions.  For convenience, these
  45. routines have the same name as the engine functions with the prefix
  46. VB.  For example, VBPXGetShort calls the engine's PXGetShort.
  47.  
  48. This document assumes that the reader has a working knowledge of the
  49. engine functions, Paradox database constructs, and Visual Basic.  It
  50. also assumes that user of the package will be moderately curious and
  51. willing to look at the supplied code if the documentation isn't clear.
  52.  
  53. This package contains two files in addition to this documentation.
  54. The first, VBPXGLOB.TXT, contains declarations of global constants
  55. that the VB programmer can use.  These global constants include
  56. TypeDefs for the various objects the engine uses: handles, buffers,
  57. etc., mnemonics for the engine's error codes, and some of the 'words'
  58. used by engine functions such as SEARCHFIRST, SEARCHNEXT.  The
  59. interface layer assumes these definitions are global.  If you do not
  60. want to use them, add them to the module that contains VBPXENG.TXT.
  61. If you also want to use them, add them to your global module.  The
  62. second file is VBPXENG.TXT.  This file contains a few constants used
  63. only by the VBPX... routines, the declarations for the Paradox Engine
  64. DLL, and the VBPX... functions.  Note that this is a TEXT file.  To
  65. use it in your VB application, you should create a new module file.
  66. Next,  use the load text option from the code menu to place this text
  67. into the file.  Like their Engine counterparts, the VBPX... routines
  68. all return an integer containing a Paradox status code.  Your programs
  69. should always test this and handle the error if there is one.  I have
  70. included a function that puts up a message box with the error message
  71. text.  You will probably find this useful for debugging.
  72.  
  73. The following sections list the VBPX... functions together with their
  74. arguments.  For convenience, I have organized them into the categories
  75. used in the Paradox Engine documentation.  If the function simply
  76. calls a Paradox function, only the name of that function is given.  In
  77. this case, the VB function simply passes the arguments along to the
  78. engine.  You can read the description of the function in the Engine
  79. documentation.  If the function transforms data or is different in
  80. some way from the Engine function that it calls, there is a brief
  81. description of the differences.
  82.  
  83.  
  84. INITIALIZATION AND FINALIZATION FUNCTIONS
  85.  
  86. Function VBPXExit() As Integer
  87.      Invokes PXExit.
  88.      
  89. Function VBPXGetDefaults (swapSize As Integer, maxTables As Integer,
  90. maxRecBufs As Integer, maxLocks As Integer, maxFiles As Integer,
  91. sortOrder As String) As Integer
  92.      Invokes PXGetDefaults
  93.      
  94. Function VBPXNetInit (netNamePath As String, netType As Integer,
  95. UserName As String) As Integer
  96.      Invokes PXNetInit; not generally used in Windows
  97.      
  98. Function VBPXSave () As Integer
  99.      Invokes PXSave
  100.      
  101. Function VBPXSetDefaults (bufSize As Integer, maxTables As Integer,
  102. maxRecBufs As Integer, maxLocks As Integer, maxFiles As Integer,
  103. sortOrder As String) As Integer
  104.      Invokes PXSetDefaults; note that there are defined constants
  105.      for sort order in VBPXGLOB.TXT.  This may not be useful
  106.      because you need to run the engine configuration program to
  107.      tell Windows what your maxima are, but the engine
  108.      documentation is unclear, so here it is.
  109.      
  110. Function VBPXWinInit (ClientName As String, ShareMode As Integer) As
  111. Integer
  112.      Invokes PXWinInit
  113.      
  114.  
  115. TABLE FUNCTIONS
  116.  
  117. Function VBPXTblAdd (srcTableName As String, destTableName As String)
  118. As Integer
  119.      Invokes PXTblAdd
  120.      
  121. Function VBPXTblClose (table As TABLEHANDLE) As Integer
  122.      Invokes PXTblClose
  123.      
  124. Function VBPXTblCopy (srcTableName As String, destTableName As String)
  125. As Integer
  126.      Invokes PXTblCopy
  127.      
  128. Function VBPXTblCreate (TableName As String, NumFields As Integer,
  129. Fields() As String, Types() As String) As Integer
  130.      Fields and Types are simple VB String arrays of NumFields
  131.      entries.  This routine handles all the conversion of these
  132.      arrays into the Engine's required array of pointers to
  133.      character.  Invokes PXTblCreate.
  134.      
  135. Function VBPXTblDelete (TableName As String) As Integer
  136.      Invokes PXTblDelete
  137.      
  138. Function VBPXTblEmpty (TableName As String) As Integer
  139.      Invokes PXTblEmpty
  140.      
  141. Function VBPXTblMaxSize (maxTblSize As Integer) As Integer
  142.           Invokes PXTblMaxSize
  143.      
  144. Function VBPXTblName (table As TABLEHANDLE, TableName As String) As
  145. Integer
  146.      Returns the table name as a VB String
  147.      
  148. Function VBPXTblOpen (TableName As String, table As TABLEHANDLE,
  149. indexId As Integer, saveEveryChange As Integer) As Integer
  150.      Invokes PXTblOpen.  Remember that Paradox uses 1 for TRUE,
  151.      so use a constant 1 for saveEveryChange if you want it,
  152.      otherwise use a zero.
  153.      
  154. Function VBPXTblRename (srcTableName As String, destTableName As
  155. String) As Integer
  156.      Invokes PXTblRename
  157.      
  158.  
  159. RECORD FUNCTIONS
  160.  
  161. Function VBPXRecAppend (table As TABLEHANDLE, Record As RECORDHANDLE)
  162. As Integer
  163.      Invokes PXRecAppend
  164.      
  165. Function VBPXRecBufClose (Record As RECORDHANDLE) As Integer
  166.      Invokes PxRecBufClose
  167.      
  168. Function VBPXRecBufCopy (SrcRecord As RECORDHANDLE, DestRecord As
  169. RECORDHANDLE) As Integer
  170.      Invokes PXRecBufCopy
  171.      
  172. Function VBPXRecBufEmpty (Record As RECORDHANDLE) As Integer
  173.      Invokes PXRecBufEmpty
  174.      
  175. Function VBPXRecBufOpen (table As TABLEHANDLE, Record As RECORDHANDLE)
  176. As Integer
  177.      Invokes PXRecBufOpen
  178.      
  179. Function VBPXRecDelete (table As TABLEHANDLE) As Integer
  180.      Invokes PXRecDelete
  181.      
  182. Function VBPXRecFirst (table As TABLEHANDLE) As Integer
  183.      Invokes PXRecFirst
  184.      
  185. Function VBPXRecGet (table As TABLEHANDLE, Record As RECORDHANDLE) As
  186. Integer
  187.      Invokes PXRecGet
  188.      
  189. Function VBPXRecGoto (table As TABLEHANDLE, Record As RECORDHANDLE) As
  190. Integer
  191.      Invokes PXRecGoTo
  192.      
  193. Function VBPXRecInsert (table As TABLEHANDLE, Record As RECORDHANDLE)
  194. As Integer
  195.      Invokes PXRecInsert
  196.      
  197. Function VBPXRecLast (table As TABLEHANDLE) As Integer
  198.      Invokes PXRecLast
  199.      
  200. Function VBPXRecNext (table As TABLEHANDLE) As Integer
  201.      Invokes PXRecNext
  202.      
  203. Function VBPXRecNum (table As TABLEHANDLE, RNum As RECORDNUMBER) As
  204. Integer
  205.      Invokes PXRecNum
  206.      
  207. Function VBPXRecPrev (table As TABLEHANDLE) As Integer
  208.      Invokes PXRecPrev
  209.      
  210. Function VBPXRecUpdate (table As TABLEHANDLE, Record As RECORDHANDLE)
  211. As Integer
  212.      Invokes PXRecUpdate
  213.      
  214.  
  215. FIELD FUNCTIONS
  216.  
  217. Function VBPXFldBlank (Record As RECORDHANDLE, Field As FIELDHANDLE)
  218. As Integer
  219.      Unlike the engine function, which places the truth value of
  220.      the blank comparison in a separate variable, this function
  221.      returns TRUE (-1) if field is blank, 0 if field is not
  222.      blank, error code otherwise.  It invokes PXFldBlank.
  223.      
  224. Function VBPXFldHandle (table As TABLEHANDLE, fldName As String, Field
  225. As FIELDHANDLE) As Integer
  226.      Invokes PXFldHandle
  227.      
  228. Function VBPXFldName (table As TABLEHANDLE, Field As FIELDHANDLE,
  229. fldName As String) As Integer
  230.      Invokes PXFldName
  231.      
  232. Function VBPXFldType (table As TABLEHANDLE, Field As FIELDHANDLE,
  233. fldType As String) As Integer
  234.      Calls PXFldType and places a VB String in fldType
  235.      
  236. Function VBPXGetAlpha (Record As RECORDHANDLE, Field As FIELDHANDLE,
  237. dest As String) As Integer
  238.      If the PXGetAlpha call is successful, strips the null
  239.      terminator and returns a true VB string in dest.
  240.      
  241. Function VBPXGetCurrency (Record As RECORDHANDLE, Field As
  242. FIELDHANDLE, Value As Currency) As Integer
  243.      Converts a Paradox Double to a VB Currency
  244.      
  245. Function VBPXGetDate (Record As RECORDHANDLE, Field As FIELDHANDLE,
  246. dateval As Double)
  247.      Gets a Paradox date and converts it to a VB Date Serial
  248.      
  249. Function VBPXGetDoub (Record As RECORDHANDLE, Field As FIELDHANDLE,
  250. Value As Double) As Integer
  251.      Invokes PXGetDoub
  252.      
  253. Function VBPXGetLong (Record As RECORDHANDLE, Field As FIELDHANDLE,
  254. Value As Long) As Integer
  255.      Invokes PXGetLong
  256.      
  257. Function VBPXGetShort (Record As RECORDHANDLE, Field As FIELDHANDLE,
  258. Value As Integer) As Integer
  259.      Invokes PXGetShort
  260.      
  261. Function VBPXPutAlpha (Record As RECORDHANDLE, Field As FIELDHANDLE,
  262. Value As String) As Integer
  263.      Invokes PXPutAlpha
  264.      
  265. Function VBPXPutBlank (Record As RECORDHANDLE, Field As FIELDHANDLE)
  266. As Integer
  267.      Invokes PXPutBlank
  268.      
  269. Function VBPXPutCurrency (Record As RECORDHANDLE, Field As
  270. FIELDHANDLE, Value As Currency) As Integer
  271.      Converts a VB Currency variable to a double and puts it into
  272.      the record buffer with PXPutDoub
  273.      
  274. Function VBPXPutDate (Record As RECORDHANDLE, Field As FIELDHANDLE,
  275. dateval As Double) As Integer
  276.      converts a VB date serial to a Paradox Date field and puts
  277.      it into the record buffer with PXPutDate
  278.      
  279. Function VBPXPutDoub (Record As RECORDHANDLE, Field As FIELDHANDLE,
  280. Value As Double) As Integer
  281.      Invokes PXPutDoub
  282.      
  283. Function VBPXPutLong (Record As RECORDHANDLE, Field As FIELDHANDLE,
  284. Value As Long) As Integer
  285.      Invokes PXPutLong
  286.      
  287. Function VBPXPutShort (Record As RECORDHANDLE, Field As FIELDHANDLE,
  288. Value As Integer) As Integer
  289.      Invokes PXPutShort
  290.      
  291.  
  292. KEY AND INDEX FUNCTIONS
  293.  
  294. Function VBPXKeyAdd (tblName As String, nflds As Integer, Fields() As
  295. FIELDHANDLE, IndexType As Integer) As Integer
  296.      Invokes PXKeyAdd.  Constants for IndexType are defined in
  297.      VBPXGLOB.
  298.      
  299. Function VBPXKeyDrop (tblName As String, indexId As Integer) As
  300. Integer
  301.      Invokes PXKeyDrop
  302.      
  303.  
  304. SEARCH FUNCTIONS
  305.  
  306. Function VBPXSrchFld (table As TABLEHANDLE, Record As RECORDHANDLE,
  307. Field As FIELDHANDLE, SearchMode As Integer) As Integer
  308.      Invokes PXSrchFld.  Constants for SearchMode are defined in
  309.      VBPXGLOB.
  310.      
  311. Function VBPXSrchKey (table As TABLEHANDLE, Record As RECORDHANDLE,
  312. nflds As Integer, SearchMode As Integer) As Integer
  313.      Invokes PXSrchKey.  Constants for SearchMode are defined in
  314.      VBPXGLOB.
  315.      
  316.  
  317. PASSWORD/SECURITY FUNCTIONS
  318.  
  319. Function VBPXPswAdd (Password As String) As Integer
  320.      Invokes PXPswAdd.
  321.      
  322. Function VBPXPswDel (Password As String) As Integer
  323.      Invokes PXPswDel.
  324.      
  325. Function VBPXTblDecrypt (TableName As String) As Integer
  326.      Invokes PXTblDecrypt.
  327.      
  328. Function VBPXTblEncrypt (TableName As String, Password As String) As
  329. Integer
  330.      Invokes PXTblEncrypt
  331.      
  332. Function VBPXTblProtected (TableName As String) As Integer
  333.      Invokes PXTblProtected and returns TRUE if table is
  334.      protected, FALSE if not, otherwise, it returns an error code
  335.      
  336.  
  337. INFORMATION FUNCTIONS
  338.  
  339. Function VBPXKeyNFlds (table As TABLEHANDLE, nKeyFlds As Integer) As
  340. Integer
  341.      Invokes PXKeyNFlds
  342.      
  343. Function VBPXRecNFlds (table As TABLEHANDLE, nflds As Integer) As
  344. Integer
  345.      Invokes PXRecNFlds
  346.      
  347. Function VBPXTblExist (TableName As String) As Integer
  348.      Invokes PXTblExist and returns TRUE if table exists, FALSE
  349.      if table doesn't exist, otherwise, a Paradox Error Code
  350.      
  351. Function VBPXTblNRecs (table As TABLEHANDLE, NRecs As RECORDNUMBER) As
  352. Integer
  353.      Invokes PXTblNRecs
  354.      
  355.  
  356. NETWORK/CONCURRENCY FUNCTIONS
  357.  
  358. Function VBPXNetFileLock (fileName As String, lockType As Integer) As
  359. Integer
  360.      Invokes PXNetFileLock
  361.      
  362. Function VBPXNetFileUnlock (fileName As String, lockType As Integer)
  363. As Integer
  364.      Invokes PXNetFileLock
  365.      
  366. Function VBPXNetRecGotoLock (table As TABLEHANDLE, PXlock As
  367. LOCKHANDLE) As Integer
  368.      Invokes PXNetRecGotoLock
  369.      
  370. Function VBPXNetRecLock (table As TABLEHANDLE, PXlock As LOCKHANDLE)
  371. As Integer
  372.      Invokes PXNetRecLock
  373.      
  374. Function VBPXNetRecUnlock (table As TABLEHANDLE, PXlock As LOCKHANDLE)
  375. As Integer
  376.      Invokes PXNetRecUnlock
  377.      
  378. Function VBPXNetRecLocked (table As TABLEHANDLE) As Integer
  379.      Invokes PXNetRecLocked and returns TRUE (-1) if the current
  380.      record of table is locked, FALSE if it is not locked, and
  381.      otherwise an error code.
  382.      
  383. Function VBPXNetTblChanged (table As TABLEHANDLE) As Integer
  384.      Invokes PXNetTblChanged, and returns TRUE (-1) if table has
  385.      changed.  Returns FALSE if table hasn't changed; otherwise
  386.      it returns an error code.
  387.      
  388. Function VBPXNetTblLock (table As TABLEHANDLE, lockType As Integer) As
  389. Integer
  390.      Invokes PXNetTblLock
  391.      
  392. Function VBPXNetTblRefresh (table As TABLEHANDLE) As Integer
  393.      Invokes PXNetTblRefresh
  394.      
  395. Function VBPXNetTblUnlock (table As TABLEHANDLE, lockType As Integer)
  396. As Integer
  397.      Invokes PXNetTblUnlock
  398.      
  399. Function VBPXNetUserName (UserName As String) As Integer
  400.      Invokes PXNetUserName and, if successful, returns the name
  401.      as a VB string.  Otherwise, it returns an error code.
  402.      
  403.  
  404. ERROR FUNCTIONS
  405.  
  406. Function VBPXERRMSG (errcode As Integer) As String
  407.      Calls PXErrMsg and returns the text for a Paradox Error code
  408.      as a VB string
  409.      
  410. Function VBPXNetErrUser (UserName As String) As Integer
  411.      Calls PXNetErrUser and returns the user name as a VB string.
  412.      
  413. Function showPDOXError (errcode As Integer) As Integer
  414.      puts up a message box with the stop icon and the text of the
  415.      error.  Program stops after you click ok on the  msg box so
  416.      you can explore with the debugger, then, if you continue,
  417.      it calls VBPXExit so you can get out cleanly.
  418.      
  419.  
  420. BLANK FIELD FUNCTIONS
  421.  
  422. Sub BLANKSHORT (X As Integer)
  423.      Places a Paradox Short Blank in X
  424.      
  425. Sub BLANKDATE (X As Double)
  426.      Places a Paradox Blank Date in X
  427.      
  428. Sub BLANKLONG (X As Long)
  429.      Places a Paradox Blank Long in X
  430.      
  431. Note: VBISBLANK... Functions return a VB TRUE if the the field is
  432. blank otherwise they return a VB FALSE
  433.  
  434. Function VBISBLANKSHORT (X As Integer) As Integer
  435. Function VBISBLANKLONG (X As Long) As Integer
  436. Function VBISBLANKDOUBLE (X As Double) As Integer
  437. Function VBISBLANKDATE (X As Double) As Integer
  438.  
  439. See also VBPXFldBlank, VBPXPutBlank
  440.  
  441.