Doorgaan naar de website
OCLC Support

ReplaceText

Find the syntax, use, parameters, return values, and an example for the ReplaceText macro command in Connexion client.
Syntax BOOL = CS.ReplaceText (sOldText, sNewText, bMatchCase)
Use to Replace the first or next occurrence of “found” text with specified text.
Parameters
  • For sOldText, enter the text you want to find, enclosed in quotation marks (“).
  • For sNewText, enter the text you want to replace the “found” text, enclosed in quotation marks (“).
  • For bMatchCase, enter the boolean value to specify whether to match upper- and lowercase exactly or not match case:
    • True - Match upper- and lowercase exactly
    • False - Do not match case
Comments
  • Precede ReplaceText by FindText.
  • After text is replaced, the cursor remains to the right of the replaced text.
  • ReplaceText replaces text only within a single cell of a field, not across cells. You can replace tags or indicators or data separately, but not in combination.
Return values TRUE if the action is successful, or FALSE if not.
Example Sub Main()

     Dim CS As Object
     Set CS = GetObject(,“Connex.Client”)

     Dim sText as String
     Dim nResult As Integer

     If CS.IsOnline = False Then
          CS.Logon ““, ““, ““
     End If

     CS.Search “WC”, “#1”

     CS.CursorRow = 1
     CS.CursorColumn = 1

     If CS.FindText(“XXX”, False) = False Then
          MsgBox “XXX - not found”
     End If

     If CS.replaceText(“Rand”, “XXX”, False) Then
          MsgBox “The first instance of Rand was replaced with XXX”
     End If

     nResult = CS.ReplaceText(“xxx”, “YYY”, True)

     If nResult - True Then
          MsgBox “Incorrect xxx - replaced”
     Else
          MsgBox “Correct xxx - not replaced”
     End If
End Sub

What this example does
  • Logs on to Connexion if not already logged on, using the default authorization and password you selected in Tools > Options > Authorizations tab.
  • Searches WorldCat for record number 1.
  • Places the cursor in the first column of the first row (beginning of the record).
  • Searches the record for the text XXX, disregarding upper- and lowercase (not case- sensitive), and returns the message XXX - not found if the text is notfound.
  • Searches for the text Rand. If it is found, replaces the first instance of Rand with the text XXX, and returns the message: The first instance of Rand was changed to XXX.
  • Finds and replaces the first instance of the text xxx with the text YYY, matching case exactly. If the action is successful (lowercase xxx is replaced with YYY), returns the message: Incorrect xxx - replaced. If the xxx text found does not match case exactly, returns the message: Correct xxx - not replaced.