home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / VISUAL_B / ARQS_ZIP / MAINF.ZIP / CONFIGUR.BAS < prev    next >
Encoding:
BASIC Source File  |  1992-07-13  |  23.4 KB  |  575 lines

  1. Declare Function GetProfileString Lib "Kernel" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Integer) As Integer
  2. Declare Function WriteProfileString Lib "Kernel" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String) As Integer
  3. Declare Function GetPrivateProfileString Lib "Kernel" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
  4. Declare Function WritePrivateProfileString Lib "Kernel" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lplFileName As String) As Integer
  5. Declare Function GetPrivateProfileInt Lib "Kernel" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal nDefault As Integer, ByVal lpFileName As String) As Integer
  6.  
  7. Declare Function GetIniSections Lib "Kernel" Alias "GetPrivateProfileString" (ByVal lpAppName As String, ByVal lpKeyName As Long, ByVal lpDefault As String, ByVal lpBuffer As String, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
  8. Declare Function KillSection Lib "Kernel" Alias "WritePrivateProfileString" (ByVal lpSectionName As String, ByVal lpKeyName As Long, ByVal lpString As Long, ByVal lpFileName As String) As Integer
  9. Declare Function KillIniKey Lib "Kernel" Alias "WritePrivateProfileString" (ByVal lpSectionName As String, ByVal lpKeyName As String, ByVal lpString As Long, ByVal lpFileName As String) As Integer
  10.  
  11. Declare Sub MessageBeep Lib "User" (ByVal wType As Integer)
  12.  
  13. Dim GDTemp As String
  14.  
  15. Function FioReadLurkerPath () As String
  16.     Dim PassedString As String
  17.     PassedString = Space$(255)
  18.     R% = GetProfileString(GioAPPNAME, GioLURKERPATH, GioDEFAULT, PassedString, Len(PassedString))
  19.     PassedString = RTrim$(PassedString)
  20.     Length% = Len(PassedString)
  21.     PassedString = Left$(PassedString, (Length% - 1))
  22. ' For consistency, make sure GSioLurkerPath ends with \
  23.     If PassedString <> GioDEFAULT And Right$(GSioLurkerPath, 1) <> "\" Then
  24.      GSioLurkerPath = GSioLurkerPath + "\"
  25.     End If
  26.     FioReadLurkerPath = PassedString
  27. End Function
  28.  
  29. Sub ConfigureLurker ()
  30.     Msg$ = "As a new user, you first need to configure Lurker.  "
  31.     Msg$ = Msg$ + "The following dialog boxes will guide you through the configuration process."
  32.     SioMsgBox Msg$, 64, "Lurker"
  33.     Directories.Show MODAL
  34.     NewUser$ = ""
  35.     RetVal% = FioUserAdd(NewUser$, TRUE)
  36.     Users.Show MODAL
  37.     Msg$ = "We'll add other configuration routines, such as Host and Modem, later"
  38.     SioMsgBox Msg$, 64, "Lurker"
  39. '    Forums.Show MODAL
  40.     Lurker.laUser.Caption = GSioActiveUser
  41.     GetForums Lurker.lbForums
  42. End Sub
  43.  
  44. Function FioUserAdd (NewName$, MakeDefault As Integer) As Integer
  45. '   Add user to user list.  Returns True if successful, false if not
  46. '   MakeDefault = TRUE if new user is to be default user
  47.     
  48.     
  49. AUBegin:
  50.     NewName$ = InputBox$("Enter new user name.", "Add User")
  51.     If NewName$ = "" Then
  52.     FioUserAdd = FALSE
  53.     Exit Function
  54.     End If
  55.     
  56.     Size% = 255
  57.     Buffer$ = Space$(Size%)
  58.     a% = GetPrivateProfileString("Users", NewName$, "", Buffer$, Size%, GSioLurkerIni)
  59.     If a% > 0 Then
  60.     Msg$ = "There is already a user by this name.  Do you wish to replace that user?"
  61.     If FioMsgBox(Msg$, 36, "Lurker") = 7 Then GoTo AUBegin
  62.     End If
  63.     DupeFlag = TRUE
  64.     counter = 1
  65. ' Find a unique name for new user.ini file
  66.     While DupeFlag
  67.     NewUserIni$ = GSioLurkerPath + "User" + RTrim$(LTrim$(Str$(counter))) + ".ini"
  68.     Temp$ = Dir$(NewUserIni$)
  69.     If Len(Temp$) = 0 Then
  70.     DupeFlag = FALSE
  71.     End If
  72.     counter = counter + 1
  73.     Wend
  74.     RetVal% = WritePrivateProfileString("Users", NewName$, NewUserIni$, GSioLurkerIni)
  75.     RetVal% = WritePrivateProfileString("Defaults", "Name", NewName$, NewUserIni$)
  76. ' If this is going to be the default user, then update "Defaults" section in Lurker.ini
  77. ' and update Global variables that maintain active UserName and UserIni
  78.     If MakeDefault Then
  79.     RetVal% = WritePrivateProfileString("Defaults", "User", NewName$, GSioLurkerIni)
  80.     GSioActiveUser = NewName$
  81.     GSioUserIni = NewUserIni$
  82.     End If
  83.     FioUserAdd = TRUE
  84. End Function
  85.  
  86. Function FioWriteLurkerPath (PassedString As String) As String
  87.     ' This function writes the LurkerPath at startup, and if
  88.     ' the user changes it around.
  89.     R% = WriteProfileString(GioAPPNAME, GioLURKERPATH, PassedString)
  90. End Function
  91.  
  92. Function FioGetDirectory$ (TheCaption$, TheMessage$)
  93. ' Displays dialog box which lets user select existing or add
  94. ' new directory.  Returns name of new directory.
  95. ' Requires form level variable GDTemp$ and companion
  96. ' routine, FioFillGDTemp.  Also requires GetDir form
  97. ' TheCaption$ = Caption of Get Directory dialog box
  98. ' TheMessage$ = Message displayed in Get Directory dialog box
  99.  
  100.     If TheCaption$ <> "" Then
  101.     GetDir.Caption = TheCaption$
  102.     Else
  103.     GetDir.Caption = "Select Directory"
  104.     End If
  105.     GetDir.Label1.Caption = TheMessage$
  106.     GetDir.Show MODAL
  107.     FioGetDirectory$ = GDTemp$
  108. End Function
  109.  
  110. Sub FioFillGDTemp (PassedString$)
  111. ' Used by GetDirectory to Pass string from Get Directory forms
  112. ' to Configuration module
  113.  
  114.     GDTemp$ = PassedString$
  115. End Sub
  116.  
  117. Function FioUserGetData (TheUser As User) As Integer
  118. ' Gets User data and places in passed parameter - TheUser
  119. ' Returns Bool
  120. ' Parameters:   TheUser = Variable to be filled with User data.
  121. '               TheUser.Name should already contain name of user from "Users" section of Lurker.ini
  122.  
  123.     Size% = 255
  124.     Buffer$ = Space$(Size%)
  125.     a% = GetPrivateProfileString("Users", TheUser.Name, "", Buffer$, Size%, GSioLurkerIni)
  126.     If a% = 0 Then
  127.     FioUserGetData = FALSE
  128.     Exit Function
  129.     End If
  130.     TheUser.Ini = Left$(Buffer$, a%)
  131.     
  132.     a% = GetPrivateProfileString("Defaults", "ID", "", Buffer$, Size%, TheUser.Ini)
  133.     TheUser.ID = Left$(Buffer$, a%)
  134.     a% = GetPrivateProfileString("Defaults", "Password", "", Buffer$, Size%, TheUser.Ini)
  135.     TheUser.Password = Left$(Buffer$, a%)
  136.     If a% <> 0 Then
  137.     TheUser.Password = FioDecrypt(TheUser.Password)
  138.     End If
  139.  
  140. End Function
  141.  
  142. Function FioUserGetActive () As String
  143.     Size% = 255
  144.     Buffer$ = Space$(Size%)
  145.     a% = GetPrivateProfileString("Defaults", "User", GioDEFAULT, Buffer$, Size%, GSioLurkerIni)
  146.     FioUserGetActive = Left$(Buffer$, a%)
  147. End Function
  148.  
  149. Function FioUserGetIni (UserName As String) As String
  150. ' Returns path and name of UserX.Ini file for designated User
  151. ' Parameter:    UserName = Name of User from "Users" section of Lurker.ini
  152.     Size% = 255
  153.     Buffer$ = Space$(Size%)
  154.     a% = GetPrivateProfileString("Users", UserName, GioDEFAULT, Buffer$, Size%, GSioLurkerIni)
  155.     FioUserGetIni = Left$(Buffer$, a%)
  156.  
  157. End Function
  158.  
  159. Sub SioUserFillLB (UserLB As Control)
  160. ' Fills passed list box with list of users from [Users] section of Lurker.ini
  161.  
  162.     While UserLB.ListCount
  163.     UserLB.RemoveItem 0
  164.     Wend
  165.     Size% = 1500
  166.     Buffer$ = Space$(Size%)
  167.     
  168.     RetVal% = GetIniSections("Users", 0&, "", Buffer$, Size%, GSioLurkerIni)
  169.     UserList$ = Left$(Buffer$, RetVal%)
  170.     Null$ = Chr$(0)
  171.     LastNdx = 0
  172.     NextNdx = 1
  173.     While NextNdx > 0
  174.     NextNdx = InStr(LastNdx + 1, UserList$, Null$)
  175.     If NextNdx > 0 Then
  176.     Cut = NextNdx - LastNdx - 1
  177.     TempUser$ = Mid$(UserList$, LastNdx + 1, Cut)
  178.     UserLB.AddItem TempUser$
  179.     End If
  180.     LastNdx = NextNdx
  181.     Wend
  182.     
  183. End Sub
  184.  
  185. Function FioUserUpdate (UserRec As User)
  186. ' This procedure is used to update user record data when
  187. ' user name and user ini name have not changed
  188.     UserIni$ = UserRec.Ini
  189.     ID$ = UserRec.ID
  190.     Password$ = UserRec.Password
  191.     Password$ = FioEncrypt(Password$)
  192.     RetVal% = WritePrivateProfileString("Defaults", "ID", ID$, UserIni$)
  193.     RetVal% = WritePrivateProfileString("Defaults", "Password", Password$, UserIni$)
  194.     
  195. End Function
  196.  
  197. Function FioEncrypt (PassedString As String) As String
  198.     
  199.     ' FioEncrypt uses a very simple two-key substitution cipher to render
  200.     ' the user's password as gibberish. It then stores the user's password
  201.     ' BACKWARDS in a string. That string (Rebuild$) is returned by the function.
  202.     
  203.     ' For a good read, get a copy of *Archimedes' Revenge* (New York:
  204.     ' W.W. Norton, 1988) from your library. The book has a really fascinating
  205.     ' section on encryption. If you read it, you'll realize that this is
  206.     ' really simple stuff.
  207.  
  208.     ' And that's the real danger--this is simple. A determined thief with a
  209.     ' little ingenuity (or a DL'd copy of this module) can crack any password
  210.     ' he comes across. The documentation (HEY DOCS DUDES!!) has to make it
  211.     ' evident that this isn't sufficient security for any kind of network--
  212.     ' the best kind of security for a corporate user is no security at all:
  213.     ' enter your password when you log on to CIS. (We trap for no entered password.)
  214.  
  215.     ' First off, we want to simplify our string manipulation by changing the
  216.     ' whole string to upper case. We'll also measure the length of the string,
  217.     ' which we'll use with For...Next loops.
  218.  
  219.     PassedString = UCase$(PassedString)
  220.     Length = Len(PassedString)
  221.     
  222.     ' We need to test to be sure nobody's snuck a null string in on us....
  223.  
  224.     If Length = 0 Then
  225.     FioEncrypt = GioNOPASSWORD
  226.     GoTo FioEncryptEnd
  227.     End If
  228.     
  229.     Dim OutString As String, Char1 As String
  230.  
  231.     ' Now we'll read the string. We'll change the odd-
  232.     ' numbered elements to a letter five ANSI characters higher (so A becomes
  233.     ' F, and Z becomes "_"); we'll change even-numbered elements to a letter
  234.     ' two characters higher.
  235.  
  236.     For counter = 1 To Length
  237.     Char1 = Mid$(PassedString, counter, 1)
  238.     Temp = Asc(Char1)                       ' Get the ANSI number
  239.     If counter Mod 2 = 1 Then               ' True answers are odd-numbered
  240.     Temp = Temp + 5                     ' Add 5
  241.     Else                                    ' False answers are even-numbered
  242.     Temp = Temp + 2                     ' Add 2
  243.     End If
  244.     Char1 = Chr$(Temp)                      ' Return value to encrypt Char1
  245.     OutString = Char1 + OutString           ' Create OutString in *reverse* order
  246.     Next
  247.  
  248.     FioEncrypt = OutString
  249.     
  250. FioEncryptEnd:
  251. End Function
  252.  
  253. Function FioDecrypt (PassedString As String) As String
  254.     ' FioDecrypt is the logical "twin" of FioEncrypt. Take a peek at that to
  255.     ' get a better grasp of how and why we're using encryption.
  256.  
  257.     ' FioDecrypt is passed a string, presumably from the Lurker.ini file,
  258.     ' to decrypt. The encryption algorithm is just reversed.
  259.     Dim ReversedString As String, Char1 As String, Char2 As String, OutputString As String
  260.     Dim Temp As Integer
  261.     
  262.     ' We'll test quickly to see if we've been passed a "non-password" flag
  263.  
  264.     If InStr(PassedString, GioNOPASSWORD) Then      ' If the INI file has no real password
  265.     FioDecrypt = GioNOPASSWORD                  ' then we say so...
  266.     GoTo FioDecryptEnd                          ' and quit
  267.     End If
  268.  
  269.     Length = Len(PassedString)                      ' For counters
  270.  
  271.     For counter = 1 To Length
  272.     Char1 = Mid$(PassedString, counter, 1)      ' Reverse the elements: select a character
  273.     ReversedString = Char1 + ReversedString     ' Write it to the end of the string
  274.     Next
  275.  
  276.     For counter = 1 To Length
  277.     Char2 = Mid$(ReversedString, counter, 1)    ' Select a character
  278.     Temp = Asc(Char2)                           ' Get the ANSI value
  279.     If counter Mod 2 = 1 Then                   ' If an odd numbered element in string
  280.     Temp = Temp - 5                         ' The value is changed
  281.     Char2 = Chr$(Temp)                      ' The string is passed out to
  282.     OutputString = OutputString + Char2     ' the OutputString
  283.     Else                                        ' If an even-numbered element
  284.     Temp = Temp - 2                         ' the value goes down by 2
  285.     Char2 = Chr$(Temp)                      ' and the string goes
  286.     OutputString = OutputString + Char2     ' back to OutputString
  287.     End If
  288.     Next
  289.  
  290.     FioDecrypt = OutputString                       ' return the function value
  291.     
  292. FioDecryptEnd:
  293. End Function
  294.  
  295. Function FioUserMakeActive (TheUser As String)
  296.     GSioActiveUser = TheUser
  297.     a% = WritePrivateProfileString("Defaults", "User", GSioActiveUser, GSioLurkerIni)
  298.     GSioUserIni = FioUserGetIni(GSioActiveUser)
  299. '    GIioForums = FioGetForumNames()
  300.  
  301. End Function
  302.  
  303. Function FioMakeSectnsNdx () As Integer
  304. ' This function reads the Sectns.lst file, searching for the Forum names. When it finds one, the function
  305. ' gets all the detail we need, writes the data to the section index, and continues on.
  306. ' The function returns the number of forums processed. If no forums are processed, the
  307. ' function returns 0. So the user can test the function as a boolean.
  308.  
  309. ' This function assumes that Sectns.lst is in the program directory designated
  310. ' by GSioLurkerPath
  311.  
  312. ' First off, we need to get a name for the matching index file.
  313.  
  314.     Dim SectnsNdx As String, SectnsLst As String
  315.     SectnsNdx = GSioLurkerPath + "Sectns.ndx"
  316.     SectnsLst = GSioLurkerPath + "Sectns.lst"
  317.     Dim DummyRec As AllForumsNdx                          ' Get the record length
  318.     RecLength% = Len(DummyRec)
  319.     
  320.  
  321. ' At this point we know the name/path of the Sections list file and the index file
  322. ' and we know the length of a ForumIndex record.  Now we'll
  323. ' open both files (opening the NDX file will create it)
  324.  
  325.     On Error Resume Next
  326.     Kill SectnsNdx                                  ' We're starting fresh
  327.     LstNum% = FileOpener(SectnsLst, READFILE, 0)    ' Get file number
  328.     NdxNum% = FileOpener(SectnsNdx, RANDOMFILE, RecLength%)
  329.  
  330.     FileSize = LOF(LstNum%)
  331.     Dim a As OFSTRUCT
  332.     x = OpenFile(SectnsLst, a, &H4000)
  333.     FileDate = a.r1
  334.     FileTime = a.r2
  335.     DummyRec.Name = "Size"
  336.     DummyRec.BytePos = FileSize
  337.     Put #NdxNum%, 1, DummyRec
  338.     DummyRec.Name = "Date"
  339.     DummyRec.BytePos = FileDate
  340.     Put #NdxNum%, , DummyRec
  341.     DummyRec.Name = "Time"
  342.     DummyRec.BytePos = FileTime
  343.     Put #NdxNum%, , DummyRec
  344.  
  345. 'Scan prologue information in Sectns.lst
  346.     ProcessForumsFlag = FALSE
  347.     While Not EOF(LstNum%) And Not ProcessForumsFlag
  348.     Line Input #LstNum%, TextLine$
  349.     If Mid$(TextLine$, 1, 10) = "----------" Then ProcessForumsFlag = TRUE
  350.     Wend
  351.     
  352. ' What we need to do next is:
  353. '   * Identify the beginning of a forum
  354. '   * Extract the name of the forum
  355. '   * Write the information to the index file
  356. '   * Move on to the next forum
  357. ' The trick is that we have to find the byte where the forum begins. BUT, we
  358. ' have to use a Line Input # statement to find the line where the message begins.
  359. ' (*Mucho* faster than evaluating every character in the file.) But after a Line
  360. ' Input # statement, the Seek pointer is looking at the *next* line, not the one where
  361. ' the forum data starts. So we have to first find the byte position of the first char in the
  362. ' line, then evaluate the line....
  363.     
  364.     Do While Not EOF(LstNum%)                          ' Chunk through each line of the file
  365.     CurrentPos& = Seek(LstNum%)                    ' Define a marker
  366.     Line Input #LstNum%, TextLine$                  ' Read the line.
  367.     If Left$(TextLine$, 3) <> "   " And TextLine$ <> "" Then             ' If a forum, go to work. If not, loop.
  368.     
  369. ' If the line starts with spaces it's not the beginning of a forum. We loop back to the Do
  370. ' four lines above us. Comments further down assume we have a valid forum.
  371.     
  372.     ForumStart& = CurrentPos&                     ' We know where the forum record begins.
  373.     ForumName$ = LTrim$(RTrim$(Left$(TextLine$, 31)))  'Get the forum Name
  374.     ForumCount% = ForumCount% + 1                   ' Increment the forum counter
  375.  
  376. ' Now we write the data to the record, and write the record to the file. We could have assigned the data
  377. ' directly to the record in each of the "Now we know..." lines above, but I think it's better form to have
  378. ' all the data collection and writing happen in one place in the code.
  379.     
  380.     DummyRec.Name = ForumName$
  381.     DummyRec.BytePos = ForumStart&
  382.     Put #NdxNum%, , DummyRec
  383.     End If
  384.     Loop
  385.  
  386.     FioMakeSectnsNdx = ForumCount%                          ' Return number of forums proc'd to the calling form.
  387.     Close LstNum%                                      ' We just close our files. We don't use a blanket...
  388.     Close NdxNum%                                      ' ...close because other forms may have files open too.
  389.  
  390. End Function
  391.  
  392. Function FioIsSectnNdxGood (Lst$, Ndx$)
  393. 'Compare size and file dates to determine if SectnsLst has changed
  394. 'since index was created
  395. 'Returns false is they aren't the same or if sectns.lst or sectns.ndx don't exist
  396.  
  397. 'If either file doesn't exist, return FALSE
  398.     SLst$ = Dir$(Lst$)
  399.     SNdx$ = Dir$(Ndx$)
  400.     If Len(SLst$) = 0 Or Len(SNdx$) = 0 Then
  401.     FioIsSectnNdxGood = FALSE
  402.     Exit Function
  403.     End If
  404.     
  405. 'Get file size of sectns list
  406.     FileNum% = FileOpener(Lst$, RANDOMFILE, 1)
  407.     FileSize = LOF(FileNum%)
  408.     Close FileNum%
  409.  
  410. 'Get date and time sectns.lst file last modified
  411.     Dim a As OFSTRUCT
  412.     x = OpenFile(Lst$, a, &H4000)
  413.     FileDate = a.r1
  414.     FileTime = a.r2
  415.  
  416. 'Sectns.ndx stores date, time and size of sectns.lst file
  417. 'in its first record.  Get it to  see if it matches
  418. 'with numbers obtained above
  419.     Dim DummyRec As AllForumsNdx
  420.     RecordLength% = Len(DummyRec)
  421.     FileNum% = FileOpener(Ndx$, RANDOMFILE, RecordLength%)
  422.     Get FileNum%, 1, DummyRec
  423.     NdxSize = DummyRec.BytePos
  424.     Get FileNum%, 2, DummyRec
  425.     NdxDate = DummyRec.BytePos
  426.     Get FileNum%, 3, DummyRec
  427.     NdxTime = DummyRec.BytePos
  428.     Close FileNum%
  429.     If FileDate <> NdxDate Then
  430.     FioIsSectnNdxGood = FALSE
  431.     ElseIf FileTime <> NdxTime Then
  432.     FioIsSectnNdxGood = FALSE
  433.     ElseIf FileSize <> NdxSize Then
  434.     FioIsSectnNdxGood = FALSE
  435.     Else
  436.     FioIsSectnNdxGood = TRUE
  437.     End If
  438. End Function
  439.  
  440. Function FioWriteForumData (ForumRec As forum)
  441. ' Writes forum data for new forum to UserX.ini
  442.     If ForumRec.Name = "" Then
  443.     FioWriteForumData = FALSE
  444.     Exit Function
  445.     End If
  446.     
  447.     GoWord$ = ForumRec.GoWord
  448.     Success% = WritePrivateProfileString("Forums", ForumRec.Name, GoWord$, GSioUserIni)
  449.     If GoWord$ = "" Then
  450.     FioWriteForumData = FALSE
  451.     Exit Function
  452.     End If
  453.     Success% = WritePrivateProfileString(GoWord$, "Messages", ForumRec.MessageFile, GSioUserIni)
  454.     Success% = WritePrivateProfileString(GoWord$, "AppendMessages", Str$(ForumRec.AppendMsg), GSioUserIni)
  455.     Success% = WritePrivateProfileString(GoWord$, "Gateway", ForumRec.Gateway, GSioUserIni)
  456. ' The next two sections were originally stored in forum data record but will now probably be kept
  457. ' in PassOptions record
  458. '        Success% = WritePrivateProfileString(GoWord$, "ActiveSections", ForumRec.ActiveSections, GSioUserIni)
  459. '        Success% = WritePrivateProfileString(GoWord$, "HMN", ForumRec.HMN, GSioUserIni)
  460.     If ForumRec.MsgDirectory = "" Then
  461.     Success% = KillIniKey(GoWord$, "MsgDirectory", 0&, GSioUserIni)
  462.     Else
  463.     Success% = WritePrivateProfileString(GoWord$, "MsgDirectory", ForumRec.MsgDirectory, GSioUserIni)
  464.     End If
  465.     If ForumRec.DLDirectory = "" Then
  466.     Success% = KillIniKey(GoWord$, "DLDirectory", 0&, GSioUserIni)
  467.     Else
  468.     Success% = WritePrivateProfileString(GoWord$, "DLDirectory", ForumRec.DLDirectory, GSioUserIni)
  469.     End If
  470. ' Test for DefaultID
  471.     UserName$ = ForumRec.UserName
  472.     If UserName$ = GSioActiveUser Then
  473.     Success% = KillIniKey(GoWord$, "UserName", 0&, GSioUserIni)
  474.     Else
  475.     Success% = WritePrivateProfileString(GoWord$, "UserName", ForumRec.UserName, GSioUserIni)
  476.     End If
  477.     FioWriteForumData = TRUE
  478. End Function
  479.  
  480. Function FioKillForum (ForumName$, GoWord$) As Integer
  481. ' Deletes forum data and section data from Lurker.ini
  482.     Success% = KillIniKey("Forums", ForumName$, 0&, GSioUserIni)
  483.     Success% = KillSection(GoWord$, 0&, 0&, GSioUserIni)
  484.     Success% = KillSection(GoWord$ + " Sections", 0&, 0&, GSioUserIni)
  485.     Success% = KillSection(GoWord$ + " Libraries", 0&, 0&, GSioUserIni)
  486. '    GIioForums = FioGetForumNames()
  487. End Function
  488.  
  489. Function FioUpdateForumData (OldRecord As forum, NewRecord As forum) As Integer
  490. ' Update Forum record information.  Name of forum to update is obtained
  491. ' from OldRecord argument.  New data is contained in NewRecord.
  492.  
  493.     If OldRecord.Name <> "" And OldRecord.Name <> NewRecord.Name Then
  494.     ForumName$ = OldRecord.Name
  495.     Success% = KillIniKey("Forums", ForumName$, 0&, GSioUserIni)
  496.     End If
  497.     If OldRecord.GoWord <> "" And OldRecord.GoWord <> NewRecord.GoWord Then
  498.     SectionToKill$ = OldRecord.GoWord
  499.     Success% = KillSection(SectionToKill$, 0&, 0&, GSioUserIni)
  500.     End If
  501.     Success% = FioWriteForumData(NewRecord)
  502. 'SHOULDN'T NEXT LINE BE MOVED TO END OF LAST IF...END IF
  503. ' MAKE CHANGE GO WORD PROCEDURE
  504. '    Success% = FioUpdateSectionAppName(OldRecord, NewRecord)
  505. End Function
  506.  
  507. Sub GetForums (LB As Control)
  508. ' Fills LB with Forum Names
  509.     ClearList LB
  510.     Size% = 1500
  511.     PassedString$ = Space$(Size%)
  512.     a% = GetIniSections("Forums", 0&, "", PassedString$, Size%, GSioUserIni)
  513.     If a% = 0 Then Exit Sub
  514.     Null$ = Chr$(0)
  515.     ForumNames$ = Left$(PassedString$, a%)
  516.     LastNdx = 0
  517.     NextNdx = 1
  518.     counter = 0
  519.     While NextNdx > 0
  520.     NextNdx = InStr(LastNdx + 1, ForumNames$, Null$)
  521.     If NextNdx > 0 Then
  522.         Cut = NextNdx - LastNdx - 1
  523.         LB.AddItem Mid$(ForumNames$, LastNdx + 1, Cut)
  524.         LastNdx = NextNdx
  525.     End If
  526.     Wend
  527. End Sub
  528.  
  529. Function FioGetForumData (ForumRec As forum) As Integer
  530. ' Fills ForumRec with Forum data.  Name of forum is
  531. ' passed in ForumRec.Name.  Typically, calling procedure
  532. ' will declare a variable of type Forum, define the .Name field
  533. ' and pass the variable in this function.
  534. ' Returns true if successful, false if unsuccessful
  535.  
  536. 'First get Forum name from passed variable
  537.     ForumName$ = ForumRec.Name
  538.     If ForumName$ = "" Then
  539.     GetForumData = FALSE
  540.     Exit Function
  541.     End If
  542.     
  543. 'Then get Go word from Userx.ini
  544.     Size% = 255
  545.     Buffer$ = Space$(Size%)
  546.     a% = GetPrivateProfileString("Forums", ForumName$, GioDEFAULT, Buffer$, Size%, GSioUserIni)
  547.     GoWord$ = Left$(Buffer$, a%)
  548.     If GoWord$ = GioDEFAULT Then
  549.     GetForumData = FALSE
  550.     Exit Function
  551.     End If
  552.     ForumRec.GoWord = GoWord$
  553.     
  554. 'Now use Go word to get other fields
  555. '    a% = GetPrivateProfileString(GoWord$, "HMN", "", Buffer$, Size%, GSioUserIni)
  556. '    ForumRec.HMN = Left$(Buffer$, a%)
  557.     a% = GetPrivateProfileString(GoWord$, "Messages", "", Buffer$, Size%, GSioUserIni)
  558.     ForumRec.MessageFile = Left$(Buffer$, a%)
  559.     a% = GetPrivateProfileString(GoWord$, "Gateway", "", Buffer$, Size%, GSioUserIni)
  560.     ForumRec.Gateway = Left$(Buffer$, a%)
  561. '    a% = GetPrivateProfileString(GoWord$, "ActiveSections", "", Buffer$, Size%, GSioUserIni)
  562. '    ForumRec.ActiveSections = Left$(Buffer$, a%)
  563.     a% = GetPrivateProfileString(GoWord$, "MsgDirectory", "", Buffer$, Size%, GSioUserIni)
  564.     ForumRec.MsgDirectory = Left$(Buffer$, a%)
  565.     a% = GetPrivateProfileString(GoWord$, "DLDirectory", "", Buffer$, Size%, GSioUserIni)
  566.     ForumRec.DLDirectory = Left$(Buffer$, a%)
  567.     a% = GetPrivateProfileInt(GoWord$, "AppendMessages", 1, GSioUserIni)
  568.     ForumRec.AppendMsg = a%
  569.     a% = GetPrivateProfileString(GoWord$, "UserName", "", Buffer$, Size%, GSioUserIni)
  570.     ForumRec.UserName = Left$(Buffer$, a%)
  571.     If ForumRec.UserName = "" Then ForumRec.UserName = GSioActiveUser
  572.     FioGetForumData = TRUE
  573. End Function
  574.  
  575.