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

  1. ' ─────────────────────────────────────────────────────────────────────────
  2. ' Program Title: Sample Program for TriBBS's MCONF.DAT 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 "mc" to make calls to the TriBBS API MCONF.PBU Unit.
  14. ' Also there are some examples showing how to use the MCONF.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 Powerful! 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 MCONF 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 MCONF.DAT.
  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 MCONF.DAT
  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 "MCONF.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. ' MCONF.DAT API which are located in the MCONF.INC file.
  96. '
  97. '---------------------------------------------------------------------------
  98. ' ** DIMENTION ALL VARIBLES, ARRAYS, TYPE STRUCTURES, & POINTERS **
  99. '
  100. '----------------------------------------------------------------------------
  101. ' ** SET THIS LINE BELOW TO YOUR TRIBBS MAIN NODE's DIRECTORY **
  102.  
  103. TBNode1sMainDirectory = "E:\TRIBBS"
  104. '============================================================================
  105.  
  106. '============================================================================
  107. '                         ** MAIN PROGRAM BODY **
  108. '============================================================================
  109.  
  110. CLS     ' Clears screen prepares it for printing
  111.  
  112. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  113. '                ** EXAMPLE 1 for MCONF.DAT Pointer Calls **
  114. '----------------------------------------------------------------------------
  115. $IF 0  ' Change the '0' to '1' to run this example
  116.  
  117. DIM MCN  AS STRING             ' Local Varible to hold the Message
  118.                                ' Conference Name for this example
  119.  
  120.   MCONF_DAT_OpenRead 1         ' Will Open and Read in MCONF.DAT
  121.                                ' record #1
  122.  
  123.     PRINT "Total Records:" MCONF_DAT_Length ' Returns and Prints Total
  124.                                             ' Records in MCONF.DAT
  125.  
  126.     MCN = MCONF_DAT_GetMCN     ' Returns a 32-bit pointer to the Message
  127.                                ' Conference's Name string
  128.  
  129.     PRINT MCN                  ' Prints the Message Conference Name
  130.  
  131.     MCONF_DAT_PutMCN "New Message Conference Name" ' Let's put a new Message
  132.                                                    ' Conference Name in for
  133.                                                    ' this Message Conference
  134.  
  135.     PRINT MCONF_DAT_GetMCN     ' Returns a 32-bit pointer to the Message
  136.                                ' Conference's Name string with the new
  137.                                ' Message Conference Name.
  138.  
  139.   MCONF_DAT_Close              ' Closes Mconf.dat file
  140.  
  141.  ' In the example below, we can open, read, close the Mconf.dat file, also
  142.  ' get and print the Message Conference Name from record #1 all in a single
  143.  ' line of code. :)
  144.  
  145.    PRINT    ' Print a blank line
  146.    MCONF_DAT_OpenReadClose 1 : PRINT MCONF_DAT_GetMCN
  147.  
  148. $ENDIF
  149. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  150.  
  151. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  152. '                ** EXAMPLE 2 for MCONF.DAT Pointer Calls **
  153. '----------------------------------------------------------------------------
  154. $IF 0  ' Change the '0' to '1' to run this example
  155.  
  156.  MCONF_DAT_OpenReadClose 1     ' Will Open and Read in MCONF.DAT
  157.                                ' record #1 and Close the file
  158.  
  159.   ' Grab File Area's data from memory using the a 32-bit pointer
  160.  
  161.     PRINT MCONF_DAT_GetMCN     ' Message Conference Name
  162.     PRINT MCONF_DAT_GetNWCN    ' Gets all of the Network Names which are
  163.                                ' assigned to the Message Conference Record
  164.                                ' that is currently being read in
  165.     PRINT MCONF_DAT_GetRSL     ' Read Security Level
  166.     PRINT MCONF_DAT_GetPSL     ' Post Security Level
  167.     PRINT MCONF_DAT_GetTPNODTS ' TriPack Number Of Days To Save
  168.     PRINT MCONF_DAT_GetHMN     ' Highest Message Number
  169.  
  170.   ' ** These are Bit Fields converted to integers below **
  171.  
  172.     PRINT                        ' Prints a blank line
  173.     PRINT MCONF_DAT_GetNWF(1)    ' Gets Network Flag for Record #(nw)
  174.                                    ' (nw) = 1 to 16
  175.     PRINT MCONF_DAT_PutNWF(1, 1) ' Changes Network Flag for Record #(nw, n)
  176.                                    ' nw = 1 to 16
  177.                                    ' n  = either 0 or 1
  178.                                    ' 0  = The conference does not belong to
  179.                                    '      the network.
  180.                                    ' 1  = The conference belongs to the
  181.                                    '      network.
  182.     PRINT MCONF_DAT_GetNWF(1)    ' Gets Network Flag for Record #(nw) after
  183.                                  ' bit change - (nw) = 1 to 16
  184.     PRINT                        ' Prints a blank line
  185.  
  186.     PRINT MCONF_DAT_GetNWCF     ' Networked Conference Flag
  187.                                   ' 0 = The Conference isn't a networked
  188.                                   '     conference
  189.                                   ' 1 = The Conference is a networked
  190.                                   '     conference
  191.     PRINT MCONF_DAT_GetPCF      ' Private Conference Flag
  192.                                   ' 0 = The conference isn't a private
  193.                                   '     conference.
  194.                                   ' 1 = The conference is a private
  195.                                   '     conference.
  196.     PRINT MCONF_DAT_GetFSNM     ' Fido Style Net Mail Flag
  197.                                   ' 0 = The conference isn't a Fido-style
  198.                                   '     netmail conference.
  199.                                   ' 1 = The conference is a Fido-style
  200.                                   '     netmail conference.
  201.     PRINT MCONF_DAT_GetACF      ' Alais Conference Flag
  202.                                   ' 0 = The conference isn't an alias
  203.                                   '     conference.
  204.                                   ' 1 = The conference is an alias conference.
  205.     PRINT MCONF_DAT_GetUDF      ' User Delete Flag
  206.                                   ' 0 = Users are not allowed to delete
  207.                                   '     messages.
  208.                                   ' 1 = Users can deleted messages.
  209.     PRINT MCONF_DAT_GetTPBF     ' TriPack Backup Flag
  210.                                   ' 0 = Do not save backup files while
  211.                                   '     packing the message base.
  212.                                   ' 1 = Save backup files while packing the
  213.                                   '     message base.
  214.  
  215.   ' ** SPECIAL NOTE: When working with these two bit flags below, Do Not
  216.   ' Set both to '1' which will set both to "NO". At least one of these
  217.   ' has to be set to '0' which will set it to "YES". However, both can
  218.   ' be set to '0' or "YES".
  219.  
  220.     PRINT MCONF_DAT_GetDPriM    ' Disable Private Messages Flag
  221.                                   ' 0 = Do not disable private messages.
  222.                                   ' 1 = Disable private messages.
  223.     PRINT MCONF_DAT_GetDPubM    ' Disable Public Messages Flag
  224.                                   ' 0 = Do not disable public messages.
  225.                                   ' 1 = Disable public messages.
  226. $ENDIF
  227.  
  228. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  229. '                ** EXAMPLE for MCONF.DAT Non-Pointer Calls **
  230. '----------------------------------------------------------------------------
  231. '
  232. ' This sample section will show how to use the MCONF.PBU Unit in it's basic
  233. ' form. This will require more string operations than the pointer section
  234. ' since you will be grabing just basic data straight from the MCONF.DAT
  235. ' file. Trimming, and removing and adding null terminators will have to be
  236. ' performed in this manner. If is very important when writting any data
  237. ' back to the MCONF.DAT file in this manner, you add the null terminator
  238. ' CHR$(0) to the end of all normal predefined strings based on the MCONF.DAT
  239. ' type structure located in the MCONF.INC file. Follow the example below.
  240. '
  241. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  242.  
  243. $IF 0  ' Change the '0' to '1' to run this example
  244.  
  245.  MCONF_DAT_OpenRead 1        ' Open MCONF.DAT File, and Read in record #1
  246.  
  247.  
  248.   PRINT MCONF.ConfName       ' Prints Message Conference Name as it is from
  249.                              ' Mconf.dat
  250.   PRINT LEN(MCONF.ConfName)  ' Prints Len of Message Conference Name
  251.                              ' This shows a string length of 41 characters,
  252.                              ' which is 40 charcaters that you may use for
  253.                              ' data, and the last 41 contains the null
  254.                              ' terminator, CHR$(0)
  255.  MCONF_DAT_Close             ' Close MCONF.DAT File.
  256.  
  257.  
  258.   ' Now, lets trim off the excess spaces and the null terminator.
  259.   ' First I will create a new variable to hold the new data.
  260.  
  261.   DIM Temp AS STRING         ' Dimention a new variable
  262.  
  263.  MCONF_DAT_Open              ' Open MCONF.DAT File
  264.  MCONF_DAT_Read 1            ' Read in Record #1
  265.  
  266.   Temp = RTRIM$(MCONF.ConfName, ANY " " + CHR$(0)) ' This preforms the trim
  267.                                                        ' operation
  268.   PRINT Temp                 ' Prints the new string without the extra spaces
  269.                              ' and CHR$(0)
  270.   PRINT LEN(Temp)            ' Prints the True Length of the Message
  271.                              ' Conference Name
  272.  
  273.  MCONF_DAT_Close             ' Closes MCONF.DAT File
  274.  
  275. $ENDIF
  276. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  277.  
  278. END                          ' Ends the Program