Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
Cache Loaded - Valentina
Authoring Xtras
Testing CPU speed
GetInfoFromAIFF
Versiown
Drag and Switch
VbScript Xtra
Macromedia Director Game Development: From Concept to Creation
MM-XDK-L (Developers of Xtras)
APresentationTrakker Xtra
 

 

 

Behavior replace escape characters

Added on 5/25/2001

 

Compatibilities:
D6_5 D7 D8 D8_5 Mac PC Script Shockwave

Rating:

Author: robbchar

Send this some text and it will give you the text back with the escaped '\' characters switched. Current supports \n - RETURN \t - TAB \q - QUOTE Others can be easily added in the case statement. This really isn't a behavior but rather a utility for text that should be placed in a movie script.

on replaceEscapeChars theText
  if stringP(theText) = 1 then
    -- save the old itemDelimiter and replace it with "\"
    oldDelimiter = the itemDelimiter
    the itemDelimiter = "\"
    newText = theText.item[1]
    numItems = theText.item.count
    repeat with i = 2 to numItems
      currentItem = theText.item[i]
      specialChar = ""
      
      -- figure out which char it is
      escapedChar = currentItem.char[1]
      case escapedChar of
        "n":
          specialChar = RETURN
        "t":
          specialChar = TAB
        "q":
          specialChar = QUOTE
      end case
      
      -- put it together
      currentItem = currentItem.char[2..currentItem.char.count]
      newText = newText & specialChar & currentItem
    end repeat
    -- restore the itemDelimiter
    the itemDelimiter = oldDelimiter
    -- return the new string
    return newText
  else
    -- return theText if its not a string
    return theText
  end if
end  

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail