home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / sys_util / pminfo / pminfo.bas < prev    next >
Encoding:
BASIC Source File  |  1994-09-18  |  7.5 KB  |  282 lines

  1. Global Const ProgTitle = "Steve's ProgMan Info"
  2.  
  3. Type GroupHeader
  4.   Name As String
  5.   NumItems As Integer
  6. End Type
  7.  
  8. Type GroupInfo
  9.   Parent As Integer
  10.   Name As String
  11.   CommandLine As String
  12.   DefaultDir As String
  13.   IconPath As String
  14.   MinFlag As Integer
  15. End Type
  16.  
  17. Type MasterGroup
  18.   Name As String
  19.   Level As Integer
  20. End Type
  21.  
  22. Global GroupList() As GroupHeader
  23. Global GroupInfoList() As GroupInfo
  24. Global MasterList() As MasterGroup
  25.  
  26. 'Word 6 document name
  27. Global Const DOC_NAME = "PMINFO.DOC"
  28.  
  29. 'Word 6 document object
  30. Global OhMyWord As Object
  31.  
  32. 'window state
  33. Global Const WINDOW_MINIMIZED = 1
  34.  
  35. 'dde link
  36. Global Const COLD_LINK = 2
  37.  
  38. 'dialog box stuff
  39. Global Const YES_NO_QUESTION = 36
  40. Global Const NO = 7
  41.  
  42.  
  43. Sub CenterForm (SForm As Form)
  44.  
  45. SForm.Top = (Screen.Height - SForm.Height) / 2
  46. SForm.Left = (Screen.Width - SForm.Width) / 2
  47.  
  48. End Sub
  49.  
  50. Function FillGroupInfoList (GroupNum As Integer) As Integer
  51.  
  52. Dim FirstPos As Integer
  53. Dim NextPos As Integer
  54. Dim Looper As Integer
  55. Dim MyText As String
  56. Dim Minimized As Integer
  57.  
  58. On Error GoTo FillGroupInfoError
  59.  
  60. 'set initial value
  61. FillGroupInfoList = False
  62.  
  63. 'get the text from the text box
  64. MyText = PMMainForm.DDEText.Text
  65.  
  66. 'find the first comma (chr$(44) is a comma)
  67. FirstPos = InStr(1, MyText, Chr$(44))
  68.  
  69. 'find the next comma
  70. FirstPos = InStr(FirstPos + 1, MyText, Chr$(44))
  71. 'find the third comma
  72. NextPos = InStr(FirstPos + 1, MyText, Chr$(44))
  73.  
  74. 'get the number of group items; start from the character after the 2nd comma, and
  75. 'take the number of characters up to but not including the third comma
  76. GroupList(GroupNum).NumItems = Val(Mid$(MyText, FirstPos + 1, NextPos - FirstPos - 1))
  77.  
  78. 'find the start of the second line, after the first set of quote marks
  79. FirstPos = InStr(1, MyText, Chr$(10)) + 2
  80.  
  81. 'iterate through the number of items for this group
  82. For Looper = 1 To GroupList(GroupNum).NumItems
  83.   'bump our group info array by one
  84.   ReDim Preserve GroupInfoList(UBound(GroupInfoList) + 1)
  85.   
  86.   'set the group parent
  87.   GroupInfoList(UBound(GroupInfoList)).Parent = GroupNum
  88.  
  89.   'find the trailing quote of the icon name
  90.   NextPos = InStr(FirstPos, MyText, Chr$(34))
  91.  
  92.   'add the icon name to the group info array
  93.   GroupInfoList(UBound(GroupInfoList)).Name = Mid$(MyText, FirstPos, NextPos - FirstPos)
  94.  
  95.   'set the new starting position - the last quote, plus the comma, plus the next quote
  96.   FirstPos = NextPos + 3
  97.  
  98.   'find the trailing quote of the command line
  99.   NextPos = InStr(FirstPos, MyText, Chr$(34))
  100.  
  101.   'add the command line info to the array
  102.   GroupInfoList(UBound(GroupInfoList)).CommandLine = Mid$(MyText, FirstPos, NextPos - FirstPos)
  103.  
  104.   'set the new starting postion - the last quote, plus the comma
  105.   FirstPos = NextPos + 2
  106.  
  107.   'find the next comma
  108.   NextPos = InStr(FirstPos, MyText, Chr$(44))
  109.  
  110.   'add the default directory information to the array
  111.   GroupInfoList(UBound(GroupInfoList)).DefaultDir = Mid$(MyText, FirstPos, NextPos - FirstPos)
  112.  
  113.   'set the new starting position - the last comma, plus one
  114.   FirstPos = NextPos + 1
  115.  
  116.   'find the next comma
  117.   NextPos = InStr(FirstPos, MyText, Chr$(44))
  118.   
  119.   'add the icon path to the array
  120.   GroupInfoList(UBound(GroupInfoList)).IconPath = Mid$(MyText, FirstPos, NextPos - FirstPos)
  121.  
  122.   'find the end of the line
  123.   FirstPos = InStr(NextPos, MyText, Chr$(13))
  124.  
  125.   'set the minimize flag
  126.   Minimized = Val(Mid$(MyText, FirstPos - 1, 1))
  127.  
  128.   If Minimized = 0 Then
  129.     GroupInfoList(UBound(GroupInfoList)).MinFlag = False
  130.   Else
  131.     GroupInfoList(UBound(GroupInfoList)).MinFlag = True
  132.   End If
  133.  
  134.   'set the starting position to the beginning of the next line
  135.   FirstPos = FirstPos + 3
  136.  
  137. Next Looper
  138.  
  139. 'return success!
  140. FillGroupInfoList = True
  141.  
  142. FillGroupInfoResume:
  143. Exit Function
  144.  
  145. FillGroupInfoError:
  146. Resume FillGroupInfoResume
  147.  
  148. End Function
  149.  
  150. Function FillGroupList () As Integer
  151.  
  152. On Error GoTo FillGroupListError
  153.  
  154. Dim Looper As Integer
  155. Dim MyString As String
  156. Dim TempStr As String
  157.  
  158. 'set initial value
  159. FillGroupList = False
  160.  
  161. 'reset our array
  162. ReDim GroupList(0)
  163.  
  164. 'get text
  165. MyString = PMMainForm.DDEText.Text
  166.  
  167. 'for each character in the  string
  168. For Looper = 1 To Len(MyString)
  169.   
  170.   If Asc(Mid$(MyString, Looper, 1)) > 31 Then  'if we don't have a non-printable character
  171.     TempStr = TempStr + Mid$(MyString, Looper, 1)  'concatenate string
  172.   Else
  173.     
  174.     If TempStr <> "" Then  'we've formed a group name
  175.       ReDim Preserve GroupList(UBound(GroupList) + 1)  'bump our array by one
  176.       GroupList(UBound(GroupList)).Name = TempStr  'add the group name to the array
  177.       TempStr = ""                            'clear out our list
  178.     End If
  179.  
  180.   End If
  181.  
  182. Next Looper
  183.  
  184. 'return success!
  185. FillGroupList = True
  186.  
  187. FillGroupListResume:
  188. Exit Function
  189.  
  190. FillGroupListError:
  191. Resume FillGroupListResume
  192.  
  193. End Function
  194.  
  195. Function FillMasterList () As Integer
  196.  
  197. Dim Looper As Integer
  198. Dim Loop2 As Integer
  199. Dim CurItem As Integer
  200.  
  201. On Error GoTo FillMasterListError
  202.  
  203. 'initialize variables
  204. FillMasterList = False
  205. ReDim MasterList(0)
  206. CurItem = 1
  207.  
  208. For Looper = 1 To UBound(GroupList)
  209.  
  210.   ReDim Preserve MasterList(UBound(MasterList) + 1)  'increment our array
  211.   MasterList(UBound(MasterList)).Name = GroupList(Looper).Name 'add the group name
  212.   MasterList(UBound(MasterList)).Level = 1  'add the level
  213.  
  214.   'loop through each group's individual items
  215.   For Loop2 = CurItem To GroupList(Looper).NumItems + CurItem - 1
  216.  
  217.       ReDim Preserve MasterList(UBound(MasterList) + 1)  'increment our array
  218.       MasterList(UBound(MasterList)).Name = GroupInfoList(Loop2).Name  'add the icon name
  219.       MasterList(UBound(MasterList)).Level = 2  'add the level
  220.       
  221.       ReDim Preserve MasterList(UBound(MasterList) + 1)  'increment our array
  222.       MasterList(UBound(MasterList)).Name = "Command Line:  " + GroupInfoList(Loop2).CommandLine'add the command line
  223.       MasterList(UBound(MasterList)).Level = 3  'add the level
  224.  
  225.       ReDim Preserve MasterList(UBound(MasterList) + 1)  'increment our array
  226.       MasterList(UBound(MasterList)).Name = "Default Directory:  " + GroupInfoList(Loop2).DefaultDir'add the default directory
  227.       MasterList(UBound(MasterList)).Level = 3  'add the level
  228.  
  229.       ReDim Preserve MasterList(UBound(MasterList) + 1)  'increment our array
  230.       MasterList(UBound(MasterList)).Name = "Icon Path:  " + GroupInfoList(Loop2).IconPath'add the icon path
  231.       MasterList(UBound(MasterList)).Level = 3  'add the level
  232.  
  233.       ReDim Preserve MasterList(UBound(MasterList) + 1)  'increment our array
  234.       
  235.       If GroupInfoList(Loop2).MinFlag Then
  236.         MasterList(UBound(MasterList)).Name = "Minimize Flag:  True"
  237.       Else
  238.         MasterList(UBound(MasterList)).Name = "Minimize Flag:  False"
  239.       End If
  240.  
  241.       MasterList(UBound(MasterList)).Level = 3  'add the level
  242.  
  243.   Next Loop2
  244.  
  245. 'increment the number of items we've worked with
  246. CurItem = CurItem + GroupList(Looper).NumItems
  247.  
  248. Next Looper
  249.  
  250. 'clear out our other arrays to clean up some memory
  251. ReDim GroupList(0)
  252. ReDim GroupInfoList(0)
  253.  
  254. 'return success!
  255. FillMasterList = True
  256.  
  257. FillMasterListResume:
  258. Exit Function
  259.  
  260. FillMasterListError:
  261. Resume FillMasterListResume
  262.  
  263. End Function
  264.  
  265. Sub FillPMOutline ()
  266.  
  267. Dim MyOutline As Control
  268.  
  269. 'set our object to the outline to make it easier (and quicker) to reference
  270. Set MyOutline = PMMainForm.PMOutline
  271.  
  272. 'go through each item in the master list and add it to the outline
  273. For Looper = 1 To UBound(MasterList)
  274.   MyOutline.AddItem MasterList(Looper).Name, Looper + 1
  275.   MyOutline.Indent(Looper + 1) = MasterList(Looper).Level
  276. Next Looper
  277.  
  278. Set MyOutline = Nothing
  279.  
  280. End Sub
  281.  
  282.