Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Notices

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 06-27-2019, 01:04 AM
slouw slouw is offline
Registered User
 
Join Date: Nov 2005
Posts: 166
Inverted comma literal

Related to this forum post
I have a script that turns off logging, changes the log file name and turns on logging again.
In this script is the fragment below to replace certain defined characters in a string with a "_".
The string is the new logfile name.
The illegal characters are those that cannot be included in a filename.
All works well accept that this script fragment does not remove a double quote
"
resulting in an error.
Any ideas how I can represent the double quote as a literal so code fragment will do what is intended?

With much gratitude...

Code:
IllegalChars ="|/\<>:*"""
## Problem here is that each illegal char is searched for only once.
## When 2 senak in we have a problem
for char in IllegalChars:
    if char in CommandStr:
        ## .replace method should replace ALL occurrences.
        ## Seems this is not happening
        CommandStr = CommandStr.replace(char, "_")
        writeB("00380 **PRESENT**                 :" + CommandStr + "<>" + "   " + char)
        ## crt.Dialog.MessageBox("00380 **PRESENT** :" + CommandStr + "<>" + "   " + char)
    else:
        ## crt.Dialog.MessageBox("00390 No          :" + CommandStr + "<>" + "   " + char)
        writeB("00390 No                          :" + CommandStr + "<>" + "   " + char)

Last edited by jdev; 07-08-2019 at 08:29 AM. Reason: wrap code in [code] blocks
Reply With Quote
 

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 06:44 PM.