home *** CD-ROM | disk | FTP | other *** search
/ Troubleshooting Netware Systems / CSTRIAL0196.BIN / attach / msj / v10n10 / vb40.exe / WCIMR.EXE / WCSTRING.BAS < prev    next >
BASIC Source File  |  1995-10-01  |  2KB  |  89 lines

  1. Attribute VB_Name = "WCIMStrings"
  2. Function StrReplace(Strg As String, find As String, change As String) As String
  3. Dim NewStrg As String
  4. r = Len(Strg)
  5.  
  6. NewStrg = ""
  7.  
  8. n = 1
  9.  
  10. While (n <> 0)
  11.     n = InStr(n, Strg, find)
  12.     If (n > 0) Then
  13.         LSide = Left(Strg, n - 1)
  14.         RSide = Right(Strg, Len(Strg) - n - Len(find) + 1)
  15.         Strg = LSide & change & RSide
  16.         n = n + Len(change)
  17.     End If
  18. Wend
  19.  
  20. StrReplace = Strg
  21. End Function
  22. Function ZTrim$(Strg$)
  23.  
  24. ' I'm not Dim'ing NulChar, just to annoy people
  25. NulChar = String(1, Chr$(0))
  26.  
  27. NulLoc = InStr(1, Strg$, NulChar)
  28.  
  29. If (NulLoc = 0) Then
  30.     ZTrim$ = Strg$
  31. Else
  32.     If (NulLoc = Null) Then
  33.         ZTrim$ = Strg$
  34.     Else
  35.         ZTrim$ = Left(Strg$, NulLoc - 1)
  36.     End If
  37. End If
  38.  
  39. End Function
  40.  
  41. Function TSToString(TS As TimeStamp) As String
  42.     Dim NewStr As String
  43.     
  44.     NewStr = "" & TS.TMonth & "/" & TS.TDay & "/" & (TS.TYear + 1970)
  45.     NewStr = NewStr + ", " & Format$(TS.THour, "00") & ":" & Format$(TS.TMin, "00") & ":" & Format$(TS.TSec, "00")
  46.     TSToString = NewStr
  47. End Function
  48.  
  49. Function TSToDate(TS As TimeStamp) As String
  50. ' TSToDate formats a string in text sorting order,
  51. ' i.e.: yyyy-mm-dd
  52.  
  53.     Dim NewStr As String
  54.  
  55.     NewStr = "" & (TS.TYear + 1970)
  56.     NewStr = NewStr & "/" & Format$(TS.TMonth, "00")
  57.     NewStr = NewStr & "/" & Format$(TS.TDay, "00")
  58.     TSToDate = NewStr
  59. End Function
  60.  
  61. '================================================
  62. ' GetPString
  63. ' Reads a CIM Pascal-type string from a file
  64.  
  65. Function GetPString(FNum As Integer, Pstr As PString)
  66.     Get #FNum, , Pstr.SLen
  67.  
  68.     If (Pstr.SLen = 0) Then
  69.         GetPString = 0
  70.         Exit Function
  71.     End If
  72.     Pstr.SData = String(Pstr.SLen, " ")
  73.     Get #FNum, , Pstr.SData
  74.  
  75.     GetPString = Pstr.SLen
  76. End Function
  77.  
  78. Function StdReplace(Strg As String) As String
  79.     Dim Tmp As String
  80.  
  81.     Tmp = Strg
  82.     Tmp = StrReplace(Tmp, Chr$(10), Chr$(13) & Chr$(10))
  83.     Tmp = StrReplace(Tmp, "@b", " ")
  84.     Tmp = StrReplace(Tmp, "@@", "@")
  85.     Tmp = StrReplace(Tmp, "@I", "")
  86.     StdReplace = Tmp
  87. End Function
  88.  
  89.