home *** CD-ROM | disk | FTP | other *** search
/ Pegasus 5 / Pegasus_Vol_5_CD2.iso / lotus / lotus022.dsk / LTSSL30.LSS < prev   
Text File  |  1995-06-23  |  22KB  |  773 lines

  1. '--------------------------------------------------------------------------
  2. '
  3. '    File:         LTSSL30.LSS
  4. '    Module:    Sample Function Libraries - Windows 3.1 interfaces
  5. '    Created:    07/12/94
  6. '
  7. '    Copyright (c) 1994-95 Lotus Development Corporation
  8. '
  9. '    Description: This file contains the following sample 
  10. '        LotusScript Windows Functions:
  11. '    
  12. '        GetTempDirectory
  13. '        GetWinDirectory
  14. '        WindowsHelp
  15. '        GetProfInteger
  16. '        GetProfString
  17. '        WriteProfInteger
  18. '        WriteProfString
  19. '
  20. '        AppClose
  21. '        AppGetAppCount
  22. '        AppGetAppNames
  23. '        AppGetHWnd
  24. '        AppGetWindowPos
  25. '        AppHide
  26. '        AppShow
  27. '        AppIsRunning
  28. '        AppIsVisible
  29. '        AppMaximize
  30. '        AppMinimize
  31. '        AppMove
  32. '        AppRestore
  33. '        AppSize
  34. '        AppSendMessage
  35. '
  36. '        FormatDate
  37. '        DateDiff
  38. '        Pause
  39. '        ProperCase
  40. '        Repeat
  41. '        Str_Word
  42. '        Log10
  43. '
  44. '    Disclaimer:
  45. '        The sample LotusScript functions are provided 
  46. '        as code examples that provide useful functionality
  47. '        to LotusScript programmers.  lotus makes no promise
  48. '        or guarantee with respect to the use of these
  49. '        functions.  Users can use the library at their own risk.
  50. '
  51. '--------------------------------------------------------------------------
  52.  
  53.  
  54. '--------------------------------------------------------------------------
  55. ' External Function Declarations
  56. '
  57. ' Rather than include a monster header file with every Windows function
  58. ' in it, we just take what we need.
  59. '--------------------------------------------------------------------------
  60.  
  61. Declare Function GetWindowsDirectory Lib "Kernel" (ByVal lpBuffer As String, ByVal nSize As Integer) As Integer
  62. Declare Function GetProfileInt Lib "Kernel" (ByVal lpSection As String, ByVal lpEntry As String, ByVal nDefault As Integer) As Integer
  63. Declare Function GetProfileString Lib "Kernel" (ByVal lpSection As String, ByVal lpEntry As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Integer) As Integer
  64. Declare Function GetPrivateProfileInt Lib "Kernel" (ByVal lpSection As String, ByVal lpEntry As String, ByVal nDefault As Integer, ByVal lpFileName As String) As Integer
  65. 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
  66. Declare Function WriteProfileString Lib "Kernel" (ByVal lpSection As String, ByVal lpEntry As String, ByVal lpNewString As String) As Integer
  67. Declare Function WritePrivateProfileString Lib "Kernel" (ByVal lpSection as String, ByVal lpEntry As String, ByVal lpNewString As String, ByVal lpFileName As String ) As Integer
  68. Declare Function WinHelp Lib "User" (ByVal hWnd As Integer, ByVal lpHelpFile As String, ByVal wCommand As Integer, dwData As Any) As Integer
  69.  
  70. public Const HELP_CONTENTS    = &H3    ' Display index.
  71. public Const HELP_FORCEFILE    = &H9   ' Ensure that correct file is displayed.
  72. public Const HELP_HELPONHELP    = &H4    ' Display "Using Help"    
  73. public Const HELP_QUIT        = &H2   ' Help no longer needed.
  74.  
  75. '--------------------------------------------------------------------------
  76. ' GetWinDirectory
  77. '
  78. ' Returns the Directory in which Windows is installed.        
  79. '--------------------------------------------------------------------------
  80.  
  81. Public Function GetWinDirectory( ) as String
  82.  
  83.     Dim sBuffer as String * 256: sBuffer = string( 256, " " )
  84.                                                                  
  85.     GetWindowsDirectory sBuffer, 256
  86.  
  87.     GetWinDirectory = sBuffer
  88.  
  89. End Function
  90.  
  91. '--------------------------------------------------------------------------
  92. ' GetTempDirectory
  93. '
  94. ' The temporary directory "TEMP" set in the environment variables. 
  95. ' If this fails, it looks for "TMP".  If neither one is found, it returns
  96. ' an empty string.
  97. '--------------------------------------------------------------------------
  98.  
  99. Public Function GetTempDirectory() as String
  100.  
  101.     Dim sTempBuffer as String
  102.     
  103.     sTempBuffer = Environ$( "TEMP" )
  104.  
  105.     If sTempBuffer = "" then
  106.         sTempBuffer = Environ$ ( "TMP" )
  107.     End If
  108.  
  109.     GetTempDirectory = sTempBuffer
  110.  
  111. End Function
  112.  
  113. '--------------------------------------------------------------------------
  114. ' WindowsHelp
  115. '
  116. ' Brings up Windows Help with a given help file and context flags.
  117. '--------------------------------------------------------------------------
  118.  
  119. Public Function WindowsHelp(HelpFile as String, HelpType as Integer ) as Long
  120.  
  121.  
  122.    WindowsHelp = WinHelp(0, HelpFile, HelpType, 0 )
  123.  
  124. End Function 
  125.  
  126. '--------------------------------------------------------------------------
  127. ' GetProfInteger
  128. '
  129. ' Finds a value of the specified entry in the specified file.  If
  130. ' the entry is not found, the return value is set to zero.
  131. '--------------------------------------------------------------------------
  132.  
  133. Public Function GetProfInteger(Section as String, Entry as String, Filename as String, DefaultValue as Integer) as Long
  134.         
  135.     Dim retval as Integer
  136.  
  137.     If filename = "" then
  138.         retval = GetProfileInt(Section, Entry, DefaultValue)
  139.     Else
  140.         retval = GetPrivateProfileInt(Section, Entry, DefaultValue, Filename)
  141.     End If
  142.  
  143.     GetProfInteger = retval
  144.  
  145. End Function
  146.  
  147. '--------------------------------------------------------------------------
  148. ' GetProfString
  149. '
  150. ' This function returns a profile string from the specified ini file.
  151. ' If the filename passed is "", then the string will be searched for
  152. ' in the WIN.INI file
  153. '--------------------------------------------------------------------------
  154.  
  155. Public Function GetProfString(Section as String, Entry as String, Filename as String, DString as String) as String
  156.  
  157.     Dim retstr as String*256
  158.     Dim retval as Integer
  159.  
  160.     If filename = "" then
  161.         retval = GetProfileString(Section, Entry, DString, retstr, 256)
  162.    Else
  163.         retval = GetPrivateProfileString(Section, Entry, DString, retstr, 256,Filename)
  164.     End If
  165.             
  166.     GetProfString = Left$(retstr, retval)
  167.  
  168. End Function
  169.  
  170. '--------------------------------------------------------------------------
  171. ' WriteProfInteger
  172. '--------------------------------------------------------------------------
  173.  
  174. Public Function WriteProfInteger(Section as String, Entry as String, Filename as String, NewValue as Integer) as Long
  175.     
  176.     Dim Strval as String
  177.     Dim Errval as Integer
  178.     Dim CurrChar as String
  179.  
  180.     Strval = CSTR(NewValue)
  181.     
  182.     If filename = "" then
  183.         Errval = WriteProfileString(Section, Entry, Strval)
  184.     Else
  185.         Errval = WritePrivateProfileString(Section, Entry, Strval, Filename)
  186.     End if
  187.     
  188.     WriteProfInteger = Errval
  189.                             
  190. End Function
  191.  
  192. '--------------------------------------------------------------------------
  193. ' WriteProfString
  194. '--------------------------------------------------------------------------
  195.  
  196. Public Function WriteProfString(Section as String, Entry as String, Filename as String, NewString as String ) as Long
  197.  
  198.     Dim Errval as Integer
  199.     
  200.     If filename = "" then
  201.         Errval = WriteProfileString(Section, Entry, NewString)
  202.     Else
  203.         Errval = WritePrivateProfileString(Section, Entry, NewString, Filename)
  204.     End If
  205.     
  206.     WriteProfString = Errval        
  207.  
  208. End Function
  209.  
  210. option declare
  211. option compare nocase
  212.  
  213. '--------------------------------------------------------------------------
  214. ' Windows functions/constants
  215. '
  216. ' Culled from windows.h, rather than including the whole huge file.
  217. '--------------------------------------------------------------------------
  218.  
  219. public Const GW_HWNDFIRST    = 0
  220. public Const GW_HWNDLAST    = 1
  221. public Const GW_HWNDNEXT    = 2
  222. public Const GW_HWNDPREV    = 3
  223. public Const GW_OWNER        = 4
  224. public Const GW_CHILD         = 5
  225.  
  226. Declare Function GetWindow Lib "User" (ByVal hWnd As Integer, ByVal wCmd As Integer) As Integer
  227. Declare Function GetDesktopWindow Lib "User" () As Integer
  228. Declare Function GetWindowText Lib "User" (ByVal hWnd As Integer, ByVal lpString As String, ByVal aint As Integer) As Integer
  229. Declare Function GetNextWindow Lib "User" (ByVal hWnd As Integer, ByVal wFlag As Integer) As Integer
  230. Declare Function IsWindowVisible Lib "User" (ByVal hWnd As Integer) As Integer
  231. Declare Function SendMessage Lib "User" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, lParam As Any) As Long
  232.  
  233. '------------------------------------------
  234. ' GetWindowRect
  235. '------------------------------------------
  236.  
  237. Type RECT
  238.     left As Integer
  239.     top As Integer
  240.     right As Integer
  241.     bottom As Integer
  242. End Type
  243.  
  244. Declare Sub GetWindowRect Lib "User" (ByVal hWnd As Integer, lpRect As RECT)
  245.  
  246. '------------------------------------------
  247. ' ShowWindow 
  248. '------------------------------------------
  249.  
  250. public Const SW_HIDE                 = 0
  251. public Const SW_NORMAL                 = 1
  252. public Const SW_MAXIMIZE             = 3
  253. public Const SW_SHOW                 = 5
  254. public Const SW_MINIMIZE             = 6
  255. public Const SW_RESTORE             = 9
  256.  
  257. Declare Function ShowWindow Lib "User" (ByVal hWnd As Integer, ByVal nCmdShow As Integer) As Integer
  258.  
  259. '------------------------------------------
  260. ' SetWindowPos
  261. '------------------------------------------
  262.  
  263. public Const SWP_NOSIZE         = &H1
  264. public Const SWP_NOMOVE         = &H2
  265. public Const SWP_NOZORDER         = &H4
  266.  
  267. Declare Function SetWindowPos Lib "User" (ByVal hWnd As Integer, ByVal hWndInsertAfter As Integer, ByVal X As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer) As Integer
  268.  
  269. '--------------------------------------------------------------------------
  270. ' AppClose
  271. '
  272. ' Close a particular application
  273. '--------------------------------------------------------------------------
  274.  
  275. public function AppClose(AppName as String) as Long
  276.  
  277.     on error goto handleit
  278.  
  279.     ActivateApp AppName
  280.     SendKeys "%{F4}", TRUE
  281.     AppClose = TRUE
  282.     exit function
  283.  
  284.     handleit:
  285.         AppClose = FALSE
  286.  
  287. end function
  288.  
  289. '--------------------------------------------------------------------------
  290. ' AppGetAppCount
  291. '
  292. ' Return number of running Windows applications
  293. '--------------------------------------------------------------------------
  294.  
  295. public function AppGetAppCount() as Long
  296.  
  297.     dim hWnd as Long
  298.     dim namebuf as string*80
  299.     dim textlen as Integer
  300.  
  301.     AppGetAppCount = 0
  302.     hWnd = GetWindow(GetDesktopWindow(),GW_CHILD)
  303.     
  304.     do while hWnd <> 0
  305.  
  306.         textlen = GetWindowText(hWnd,namebuf,80)
  307.         if textlen <> 0 then
  308.             AppGetAppCount = AppGetAppCount + 1
  309.         end if
  310.  
  311.         hWnd = GetNextWindow( hWnd, GW_HWNDNEXT )
  312.      
  313.     loop
  314.  
  315. end function
  316.  
  317. '--------------------------------------------------------------------------
  318. ' AppGetAppNames
  319. '
  320. ' Fill an array with the names of the currently running applications.
  321. '--------------------------------------------------------------------------
  322.  
  323. public function AppGetAppNames(AppList() as String, AppCount as Integer) as Integer
  324.  
  325.     dim hWnd as Long
  326.     dim namebuf as String*80 ': namebuf = string(80," ")
  327.     dim i as Integer : i = 0
  328.     dim textlen as Integer
  329.  
  330.     redim AppList(AppCount)
  331.  
  332.     hWnd = GetWindow(GetDesktopWindow(),GW_CHILD)
  333.  
  334.     do while hWnd <> 0
  335.  
  336.         textlen = GetWindowText(hWnd,namebuf,80)
  337.  
  338.         if textlen <> 0 then
  339.             AppList(i) = left$(namebuf,textlen) : i = i + 1
  340.             if  i = AppCount then
  341.                 exit do
  342.             end if
  343.         end if
  344.  
  345.         hWnd = GetNextWindow( hWnd, GW_HWNDNEXT )
  346.      
  347.     loop
  348.  
  349.     AppGetAppNames = i
  350.  
  351. end function
  352.  
  353. '--------------------------------------------------------------------------
  354. ' AppGetHWnd
  355. '
  356. ' Returns HWnd for a given window title
  357. '--------------------------------------------------------------------------
  358.  
  359. public function AppGetHWnd(AppName as String) as Long
  360.  
  361.     dim hWnd as Long
  362.     dim namebuf as String*80 ': namebuf = string(80," ")
  363.     dim textlen as Integer
  364.     
  365.     AppGetHWnd = 0
  366.  
  367.     hWnd = GetWindow(GetDesktopWindow(), GW_CHILD)
  368.  
  369.     if hWnd = 0 then
  370.         AppGetHWnd = 0
  371.         exit function
  372.     end if
  373.  
  374.     do while hWnd <> 0
  375.  
  376.         textlen = GetWindowText(hWnd,namebuf,80)
  377.         if textlen <> 0 then
  378.             if AppName = left$(namebuf,textlen) then
  379.                 AppGetHWnd = hWnd
  380.                 exit do
  381.             end if
  382.         end if
  383.  
  384.         hWnd = GetNextWindow( hWnd, GW_HWNDNEXT )
  385.      
  386.     loop
  387.  
  388. end function
  389.  
  390. '--------------------------------------------------------------------------
  391. ' AppGetWindowPos
  392. '
  393. ' Get the coordinates and size of a window
  394. '--------------------------------------------------------------------------
  395.  
  396. public function AppGetWindowPos(AppName as String, x as Integer, y as Integer, w as Integer, h as Integer) as Long
  397.  
  398.     dim hWnd as Long
  399.     dim namebuf as string*80
  400.     dim r as RECT
  401.  
  402.     hWnd = AppGetHWnd(AppName)
  403.  
  404.     if hWnd = 0 then
  405.         AppGetWindowPos = FALSE
  406.         exit function
  407.     end if
  408.         
  409.     ' Window is valid, get rectange coordinates and compute width/height...
  410.  
  411.     call GetWindowRect(hWnd, r)
  412.  
  413.     x = r.left
  414.     y = r.right
  415.     w = r.right - r.left
  416.     h = r.bottom - r.top
  417.     AppGetWindowPos = TRUE
  418.  
  419. end function
  420.  
  421. '--------------------------------------------------------------------------
  422. ' SetWindowState (Private function)
  423. ' Set the state of a named window
  424. '--------------------------------------------------------------------------
  425.  
  426. function SetWindowState(AppName as String, NewState as Integer) as Long
  427.  
  428.     dim hWnd as Long
  429.  
  430.     hWnd = AppGetHWnd(AppName)
  431.  
  432.     if hWnd = 0 then
  433.         SetWindowState = FALSE
  434.         exit function
  435.     end if
  436.  
  437.     if ShowWindow(hWnd, NewState) = 0 then
  438.         SetWindowState = TRUE  ' Previously visible
  439.     else
  440.         SetWindowState = FALSE ' Previously hidden
  441.     end if
  442.  
  443. end function
  444.  
  445.  
  446. '--------------------------------------------------------------------------
  447. ' AppHide
  448. '
  449. ' Hides a window
  450. '--------------------------------------------------------------------------
  451.  
  452. public function AppHide(AppName as String) as Long
  453.  
  454.     AppHide = SetWindowState(AppName, SW_HIDE)
  455.  
  456. end function
  457.  
  458. '--------------------------------------------------------------------------
  459. ' AppShow
  460. '
  461. ' Shows a window
  462. '--------------------------------------------------------------------------
  463.  
  464. public function AppShow(AppName as String) as Long
  465.  
  466.     AppShow = SetWindowState(AppName, SW_SHOW)
  467.  
  468. end function
  469.  
  470. '--------------------------------------------------------------------------
  471. ' AppIsRunning
  472. '
  473. ' Return whether or not an application is running
  474. '--------------------------------------------------------------------------
  475.  
  476. public function AppIsRunning(AppName as String) as Long
  477.  
  478.     if AppGetHWnd(AppName) <> 0 then
  479.         AppIsRunning = TRUE
  480.     else
  481.         AppIsRunning = FALSE
  482.     end if
  483.  
  484. end function
  485.  
  486. '--------------------------------------------------------------------------
  487. ' AppIsVisible
  488. '
  489. ' Return whether or not an application is visible
  490. '--------------------------------------------------------------------------
  491.  
  492. public function AppIsVisible(AppName as String) as Long
  493.  
  494.     dim hWnd as Long
  495.     
  496.     AppIsVisible = FALSE
  497.  
  498.     hWnd = AppGetHWnd(AppName)
  499.     if hWnd <> 0 then
  500.         if IsWindowVisible(hWnd) then
  501.             AppIsVisible = TRUE
  502.         end if
  503.     end if
  504.  
  505. end function
  506.  
  507. '--------------------------------------------------------------------------
  508. ' AppMaximize
  509. ' Maximizes a window
  510. '--------------------------------------------------------------------------
  511.  
  512. public function AppMaximize(AppName as String) as Long
  513.  
  514.     AppMaximize = SetWindowState(AppName, SW_MAXIMIZE)
  515.  
  516. end function
  517.  
  518. '--------------------------------------------------------------------------
  519. ' AppMinimize
  520. ' Minimizes a window
  521. '--------------------------------------------------------------------------
  522.  
  523. public function AppMinimize(AppName as String) as Long
  524.  
  525.     AppMinimize = SetWindowState(AppName, SW_MINIMIZE)
  526.  
  527. end function
  528.  
  529. '--------------------------------------------------------------------------
  530. ' AppRestore
  531. ' Restore window to previous state
  532. '--------------------------------------------------------------------------
  533.  
  534. public function AppRestore(AppName as String) as Long
  535.  
  536.     AppRestore = SetWindowState(AppName, SW_RESTORE)
  537.  
  538. end function
  539.  
  540. '--------------------------------------------------------------------------
  541. ' AppMove
  542. '
  543. ' Move a window
  544. '--------------------------------------------------------------------------
  545.  
  546. public function AppMove(AppName as String, x as Integer, y as Integer) as Long
  547.  
  548.     dim hWnd as Long
  549.  
  550.     hWnd = AppGetHWnd(AppName)
  551.  
  552.     if hWnd = 0 then
  553.         AppMove = FALSE
  554.         exit function
  555.     end if
  556.  
  557.     AppMove = SetWindowPos(hWnd, 0, x, y, 0, 0, SWP_NOSIZE+SWP_NOZORDER)
  558.  
  559. end function
  560.  
  561. '--------------------------------------------------------------------------
  562. ' AppSize
  563. '
  564. ' Resize a window
  565. '--------------------------------------------------------------------------
  566.  
  567. public function AppSize(AppName as String, w as Integer, h as Integer) as Long
  568.  
  569.     dim hWnd as Long
  570.  
  571.     hWnd = AppGetHWnd(AppName)
  572.  
  573.     if hWnd = 0 then
  574.         AppSize = FALSE
  575.         exit function
  576.     end if
  577.  
  578.     AppSize = SetWindowPos(hWnd, 0, 0, 0, w, h, SWP_NOMOVE+SWP_NOZORDER)
  579.  
  580. end function
  581.  
  582. '--------------------------------------------------------------------------
  583. ' AppSendMessage
  584. ' Send a Windows message to a window
  585. '--------------------------------------------------------------------------
  586.  
  587. public function AppSendMessage(AppName as String, msg as Integer, wParam as Integer, lParam as Long) as Long
  588.  
  589.     dim hWnd as Long
  590.  
  591.     hWnd = AppGetHWnd(AppName)
  592.  
  593.     if hWnd = 0 then
  594.         AppSendMessage = FALSE
  595.         exit function
  596.     end if
  597.  
  598.     AppSendMessage = SendMessage(hWnd, msg, wParam, lParam)
  599.  
  600. end function
  601.  
  602.  
  603. '--------------------------------------------------------------------------
  604. ' FormatDate
  605. '
  606. ' Formats date based on specified flag.
  607. '--------------------------------------------------------------------------
  608.  
  609. Public Function FormatDate(d as variant, fmt as string) as string
  610.  
  611.     select case fmt
  612.  
  613.         case is="b":     FormatDate =    format$(d, "mmmm dd, yyyy")
  614.         case is="B":     FormatDate =     ucase(format$(d, "mmmm dd, yyyy"))
  615.         case is="c":     FormatDate =    format$(d, "dd mmmm yyyy")
  616.         case is="C":    FormatDate =     ucase(format$(d, "dd mmmm yyyy"))
  617.         case is="d":    FormatDate =    format$(d, "long date")
  618.         case is="D":    FormatDate =    ucase(format$(d, "long date"))
  619.         case is="e":    FormatDate =    format$(d, "mmmm dd")
  620.         case is="E":    FormatDate =    ucase(format$(d, "mmmm dd"))
  621.         case is="f":     FormatDate =    format$(d, "dddd dd")
  622.         case is="F":    FormatDate =     ucase(format$(d, "dddd dd"))
  623.         case is="g":    FormatDate =    format$(d, "mm/dd")
  624.         case is="G":    FormatDate =    ucase(format$(d, "mm/dd"))
  625.         case is="h":    FormatDate =    format$(d, "mm/dd/yyyy")
  626.         case is="H":    FormatDate =    ucase(format$(d, "mm/dd/yyyy"))
  627.         case is="i":     FormatDate =    format$(d, "dd, mmmm")
  628.         case is="I":     FormatDate =    ucase(format$(d, "dd, mmmm"))
  629.         case is="j":    FormatDate =    format$(d, "dd, mmmm yyyy")
  630.         case is="J":    FormatDate =    ucase(format$(d, "dd, mmmm yyyy"))
  631.         case is="k":    FormatDate =    format$(d, "yyyy mmmm dd")
  632.         case is="K":    FormatDate =     ucase(format$(d, "yyyy mmmm dd"))
  633.         case is="l":     FormatDate =    format$(d, "mmmm, dd")
  634.         case is="L":    FormatDate =     ucase(format$(d, "mmmm, dd"))
  635.         case else:        FormatDate =    ""
  636.     end select
  637.  
  638. End function
  639.  
  640. '--------------------------------------------------------------------------
  641. ' DateDiff
  642. '
  643. ' Returns an integer value that represents the number of days that
  644. ' separate the dates passed to the function
  645. '--------------------------------------------------------------------------
  646.  
  647. Public Function DateDiff(date1 as Variant, date2 as Variant ) as Long
  648.  
  649.     Dim TempVal as Variant
  650.  
  651.     TempVal = CINT((DateValue(date1)) - (DateValue(date2)) )
  652.  
  653.     DateDiff = ABS(TempVal)
  654.  
  655. End Function
  656.  
  657. '--------------------------------------------------------------------------
  658. ' Pause
  659. '
  660. ' Suspend execution of application for specified amount of time.
  661. '--------------------------------------------------------------------------
  662.  
  663. Public Sub Pause( pausetime as Integer ) 
  664.  
  665.     Dim BeginTime as Single
  666.  
  667.     BeginTime = Timer
  668.  
  669.     Do While Timer < BeginTime + pausetime
  670.         Yield
  671.     loop
  672.  
  673. End Sub
  674.  
  675. '----------------------------------------------------------------------------
  676. ' ProperCase
  677. '
  678. ' Capitalizes the first character, and lowercases the rest, of a string.
  679. '----------------------------------------------------------------------------
  680.  
  681. Public Function ProperCase ( s as String ) as String
  682.  
  683.     Dim UpperIt as Integer : UpperIt = TRUE
  684.     Dim newstring as string 
  685.     Dim currchar as string
  686.     Dim i as Integer
  687.  
  688.     For i = 1 to len(s) 
  689.         currchar = mid(s,i,1)
  690.         currchar = lcase$(currchar)
  691.         If UpperIt then
  692.             currchar = ucase$(currchar)
  693.             UpperIt = FALSE
  694.         End if
  695.         If currchar = " " then
  696.             UpperIt = TRUE
  697.         End if
  698.         newstring = newstring + currchar
  699.     Next i
  700.  
  701.     ProperCase = newstring
  702.  
  703. End Function
  704.  
  705. '----------------------------------------------------------------------------
  706. ' Repeat
  707. '
  708. ' Repeat a given pattern a certain number of times, up to a maximum length.
  709. '----------------------------------------------------------------------------
  710.  
  711. Public Function Repeat(pattern as string, repcount as integer, maxlen as integer) as String
  712.  
  713.     Dim Newstring as String 
  714.    Dim i as Integer
  715.  
  716.     For i =  1 to repcount
  717.         Newstring = Newstring + pattern
  718.     Next i
  719.  
  720.     If maxlen <> 0 then ' in lieu of ommitted arguments...
  721.         newstring = left$(newstring, maxlen)
  722.     end if
  723.  
  724.     Repeat = newstring
  725.  
  726. End function    
  727.  
  728. '----------------------------------------------------------------------------
  729. ' Str_Word
  730. '
  731. ' Search for a given numbered repetition of a substring
  732. '----------------------------------------------------------------------------
  733.  
  734. Public Function Str_Word(searchstr as String, sepstr as String, wordnum as Integer) as String
  735.  
  736.     Dim done as Integer : done = FALSE
  737.     Dim beginpos as Integer : beginpos = 0
  738.     Dim endpos as Integer : endpos = 0
  739.    Dim i as Integer
  740.  
  741.     For i = 1 to wordnum
  742.         beginpos = endpos + 1
  743.         endpos = instr(beginpos, searchstr, sepstr)
  744.         if endpos = 0 then
  745.             endpos = len(searchstr) + 1
  746.             exit for
  747.         end if
  748.     Next i
  749.  
  750.     Str_Word = mid$(searchstr,beginpos,endpos-beginpos)
  751.  
  752. End function
  753.  
  754. '----------------------------------------------------------------------------
  755. ' Log10
  756. '
  757. ' Calculates the logarithm for a given number for the base of 10.
  758. '----------------------------------------------------------------------------
  759.  
  760. Public Function Log10( inVal as Double) as Double
  761.  
  762.     Log10 = Log(inVal)/Log(10)
  763.  
  764. End function    
  765.  
  766.  
  767.  
  768.