home *** CD-ROM | disk | FTP | other *** search
/ ftp.wwiv.com / ftp.wwiv.com.zip / ftp.wwiv.com / pub / MISC / PBAPI10.ZIP / MNNNNHDR.BAS < prev    next >
BASIC Source File  |  1998-02-21  |  12KB  |  250 lines

  1. ' ─────────────────────────────────────────────────────────────────────────
  2. ' Program Title: Sample Program for TriBBS's MNNNN.HDR API UNIT
  3. '     Copyright: 1997-98 by Freejack's Software
  4. '        Author: Gary Price
  5. ' Last Modified: 02/21/98
  6. ' ─────────────────────────────────────────────────────────────────────────
  7. '         Notes:
  8. ' ─────────────────────────────────────────────────────────────────────────
  9. '       History:
  10. ' ─────────────────────────────────────────────────────────────────────────
  11. '
  12. ' In this sample.bas file, you will see servals different examples on how
  13. ' to use the Pointer "mch" to make calls to the TriBBS API MNNNNH.PBU Unit.
  14. ' Also there are some examples showing how to use the MNNNNH.PBU Unit
  15. ' without using pointers.  To use any of the current examples, go to the
  16. ' section and you will see a "$IF 0" statment at the head of the example, all
  17. ' you need to do to make that section of code run is change the '0' to any
  18. ' non-zero number.
  19. '
  20. ' A pointer is a varible that holds 32-bit (4 byte) address of data located
  21. ' elsewhere in memory. It is called a pointer because it literally points
  22. ' to data. The data at which it points is known as the target.
  23. '
  24. ' Pointers are Powerfull! The address is defined at run-time, so any target
  25. ' in memory can be referenced by your program just as if it were a standard
  26. ' PowerBASIC varible. This type of indirection is much faster and more
  27. ' efficient than PEEKing and POKEing at the target data.
  28. '
  29. ' All String Pointer calls will grab the data from memory, and strip any
  30. ' spaces and null terminator characters from the end of the string which
  31. ' will allow you to print with better screen output control.
  32. '
  33. ' When writting back to memory with a pointer string, this MNNNNH API will
  34. ' set the length back to proper size and add the null terminator, CHR$(0)
  35. ' to the end of the string. This again, will save time in writting back
  36. ' to the original record MNNNN.HDR.
  37. '
  38. ' For non-pointer calls, you will have to adjust the string yourself for
  39. ' proper printing to the screen. Also, when writting back to the MNNNN.HDR
  40. ' file, you must add a num terminator to the end of the string. More on this
  41. ' in the Non-Pointer example.
  42. ' ─────────────────────────────────────────────────────────────────────────
  43.  
  44. $CPU 80386                    ' Requires a 386 system or faster
  45.  
  46. $OPTIMIZE SPEED             ' make fastest possible executable
  47.  
  48. '$COMPILE EXE "MNNNN.EXE"   ' compile to an EXE
  49.  
  50. $DEBUG MAP OFF              ' turn off map file generation
  51. $DEBUG PBDEBUG OFF          ' don't include pbdebug support in our executable
  52.  
  53. $LIB COM        OFF         ' turn off PowerBASIC's communications library.
  54. $LIB CGA        OFF         ' turn off PowerBASIC's CGA graphics library.
  55. $LIB EGA        OFF         ' turn off PowerBASIC's EGA graphics library.
  56. $LIB VGA        OFF         ' turn off PowerBASIC's VGA graphics library.
  57. $LIB LPT        OFF         ' turn off PowerBASIC's printer support library.
  58. $LIB IPRINT     OFF         ' turn off PowerBASIC's interpreted print library.
  59. $LIB FULLFLOAT  OFF         ' turn off PowerBASIC's floating point support.
  60.  
  61. $ERROR BOUNDS   ON          ' turn on bounds checking for pointer debugging
  62. $ERROR NUMERIC  OFF         ' turn off numeric checking
  63. $ERROR OVERFLOW OFF         ' turn off overflow checking
  64. $ERROR STACK    OFF         ' turn off stack checking
  65.  
  66. $COM    0                   ' set communications buffer to nothing
  67. $STRING 16                  ' set largest string size at 16k
  68. $STACK  2048                ' let's use a 2k stack
  69. $SOUND  1                   ' smallest music buffer possible
  70.  
  71. $DIM ALL                    ' forces all Varibles and Arrays to be
  72.                             ' pre-dementioned before use.
  73.  
  74. $DYNAMIC                    ' all arrays will be dynamic by default
  75.  
  76. $OPTION CNTLBREAK OFF       ' don't allow Ctrl-Break to exit program
  77.  
  78. DEFINT A-Z                  ' default all variables to integers for maximum
  79.                             ' speed and minimum size
  80. '============================================================================
  81.  
  82.  
  83. '============================================================================
  84. '                          DECLARATIONS SECTION
  85. '============================================================================
  86. ' ** THIS SECTION IS FOR LINKS AND INCLUDES STATMENTS **
  87.  
  88. $LINK "G:\PB35\TBAPI10\PBAPI10.PBL"    ' ** SET THIS LINE TO YOUR PATH **
  89. $INCLUDE "G:\PB35\TBAPI10\PBAPI10.INC" ' ** SET THIS LINE TO YOUR PATH **
  90.  
  91. '---------------------------------------------------------------------------
  92. ' ** DECLARE SUB's BELOW THAT WILL BE USED IN THIS PROGRAM **
  93. '
  94. ' Use this section for any declarations needed to be made other than the
  95. ' MNNNN.HDR API which are located in the MNNNNHDR.INC file.
  96. '
  97. '----------------------------------------------------------------------------
  98. ' ** SET THIS LINE BELOW TO YOUR TRIBBS MAIN NODE's DIRECTORY **
  99.  
  100. TBNode1sMainDirectory = "E:\TRIBBS"
  101. '============================================================================
  102.  
  103. '============================================================================
  104. '                         ** MAIN PROGRAM BODY **
  105. '============================================================================
  106.  
  107. CLS     ' Clears screen prepares it for printing
  108.  
  109. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  110. '                ** EXAMPLE 1 for MNNNN.HDR Pointer Calls **
  111. '----------------------------------------------------------------------------
  112. $IF 0  ' Change the '0' to '1' to run this example
  113.  
  114. ' Dimentions some local variables below to hold values for this example
  115. '
  116. DIM c   AS INTEGER  ' For Message Conference Number
  117. DIM mn  AS LONG     ' For Message Number in 'c'
  118. DIM FU  AS STRING   ' For From User Name
  119.  
  120. c = 1   ' Message Conference Number
  121. mn = 1  ' Message Record Number in 'c'
  122.  
  123. IF MNNNN_HDR_OpenRead(c, mn) <> 0 THEN ' Will Open and Read in MNNNN.HDR
  124.                                        ' record if it returns a file exist
  125.                                        ' value of 1. 'NNNN' can be 1 to 9999
  126.                                        '  0 = MNNNN.HDR does not exist did
  127.                                        '      not open
  128.                                        '  1 = MNNNN.HDR does exist and was
  129.                                        '      opened
  130.  MNNNN_HDR_Open 1
  131.  
  132.     PRINT "Total Records:" MNNNN_HDR_Length ' Returns and Prints Total
  133.                                             ' Records in MNNNN.HDR for 'c'
  134.  
  135.     FU = MNNNN_HDR_GetFU     ' Returns a 32-bit pointer to the From User
  136.                              ' Name string
  137.  
  138.     PRINT FU                 ' Prints the From User name
  139.  
  140.     MNNNN_HDR_PutFU "Gary Price"  ' Let's put a new From User Name for this
  141.                                   ' this Message
  142.  
  143.     PRINT MNNNN_HDR_GetFU     ' Returns a 32-bit pointer to the From User
  144.                               ' Name string with the new User Name.
  145.  
  146.   MNNNN_HDR_Close              ' Closes MNNNN.HDR file
  147.  
  148. END IF
  149.  
  150.  ' In the example below, we can Open, Read, & Close the MNNNN.HDR file, also
  151.  ' get and print the To User Name from Conference 1, Message 1 all in a
  152.  ' single line of code. :)
  153.  
  154.    PRINT    ' Print a blank line
  155.    IF MNNNN_HDR_OpenReadClose(c, mn) <> 0 THEN PRINT MNNNN_HDR_GetTU
  156.  
  157. $ENDIF
  158. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  159.  
  160. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  161. '                ** EXAMPLE 2 for MNNNN.HDR Pointer Calls **
  162. '----------------------------------------------------------------------------
  163. $IF 0  ' Change the '0' to '1' to run this example
  164.  
  165. ' Dimentions some local variables below to hold values for this example
  166. '
  167. DIM c   AS INTEGER  ' For Message Conference Number
  168. DIM mn  AS LONG     ' For Message Number in 'c'
  169.  
  170. c = 1   ' Message Conference Number
  171. mn = 1  ' Message Record Number in 'c'
  172.  
  173.  IF MNNNN_HDR_OpenRead(c,mn) <> 0 THEN ' Will Open and Read in MNNNN.HDR
  174.                                        ' record if it returns a file exist
  175.                                        ' value of 1. 'NNNN' can be 1 to 9999
  176.                                        '  0 = MNNNN.HDR does not exist did
  177.                                        '      not open
  178.                                        '  1 = MNNNN.HDR does exist and was
  179.                                        '      opened
  180.  
  181.   ' Grab File Area's data from memory using the a 32-bit pointer
  182.  
  183.     PRINT MNNNN_HDR_GetFU       ' From User
  184.     PRINT MNNNN_HDR_GetTU       ' To User
  185.     PRINT MNNNN_HDR_GetMS       ' Message's Subject
  186.     PRINT MNNNN_HDR_GetNOAF     ' Name Of Attached File
  187.     PRINT MNNNN_HDR_GetDAT      ' Date And Time
  188.     PRINT MNNNN_HDR_GetNMFZ     ' Net Mail From Zone
  189.     PRINT MNNNN_HDR_GetNMFNet   ' Net Mail From Net
  190.     PRINT MNNNN_HDR_GetNMFNode  ' Net Mail From Node
  191.     PRINT MNNNN_HDR_GetNMFP     ' Net Mail From Point
  192.     PRINT MNNNN_HDR_GetNMTZ     ' Net Mail To Zone
  193.     PRINT MNNNN_HDR_GetNMTNet   ' Net Mail To Net
  194.     PRINT MNNNN_HDR_GetNMTNode  ' Net Mail To Node
  195.     PRINT MNNNN_HDR_GetNMTP     ' Net Mail To Point
  196.     PRINT MNNNN_HDR_GetOITF     ' Offset Into Text File
  197.     PRINT MNNNN_HDR_GetML       ' Message Length
  198.     PRINT MNNNN_HDR_GetMN       ' Message Number
  199.     PRINT MNNNN_HDR_GetNOMTRT   ' Number of Messages This Replies To
  200.     PRINT MNNNN_HDR_GetFH       ' From Hash
  201.     PRINT MNNNN_HDR_GetTH       ' To Hash
  202.  
  203.     PRINT
  204.     Print "Press Any Key to Continue"
  205.     DO WHILE INKEY$ = "" :LOOP
  206.     CLS
  207.  
  208.   ' ** These are Bit Fields converted to integers below **
  209.  
  210.     PRINT "Bit Fields"
  211.     PRINT
  212.  
  213.     PRINT MNNNN_HDR_GetEMF       ' Echo Message Flag
  214.                                    ' 0 = Do not echo the message
  215.                                    ' 1 = Echo the message
  216.     PRINT MNNNN_HDR_GetTMF       ' Threaded Message Flag
  217.                                    ' 0 = The message is not the start of a
  218.                                    '     message thread.
  219.                                    ' 1 = The message is the start of a
  220.                                    '      message thread.
  221.     PRINT MNNNN_HDR_GetPriMF     ' Private Message Flag
  222.                                    ' 0 = The message is a public message
  223.                                    ' 1 = The message is a private message
  224.     PRINT MNNNN_HDR_GetDMF       ' Deleted Message Flag
  225.                                    ' 0 = The message is not marked for
  226.                                    '     deletion
  227.                                    ' 1 = The message is marked for deletion
  228.     PRINT MNNNN_HDR_GetRMF       ' Received Message Flag
  229.                                    ' 0 = The message hasn't been received
  230.                                    ' 1 = The message has been received
  231.     PRINT MNNNN_HDR_GetPerMF     ' Permanent Message Flag
  232.                                    ' 0 = The message is not a permanent
  233.                                    '     message
  234.                                    ' 1 = The message is a permanent message
  235.     PRINT MNNNN_HDR_GetTTEMF     ' TriToss Echo Message Flag
  236.                                    ' 0 = The message has not been echoed by
  237.                                    '     TriToss
  238.                                    ' 1 = The message has been echoed by
  239.                                    '     TriToss
  240.     PRINT MNNNN_HDR_GetCMF       ' Crash Mail Flag
  241.                                    ' 0 = The message is not a crashmail
  242.                                    '     message
  243.                                    ' 1 = The message is a crashmail message
  244. END IF
  245.  
  246. $ENDIF
  247. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  248.  
  249. END                          ' Ends the Program
  250.