Remove ESC from incoming string data

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Search this Thread Display Modes
  06 June 2013
Remove ESC from incoming string data

I have a function that uses memStream.readLine() to get data from 3rd party data sources (text files). Now I've encountered a problem I've never seen before.

Here is some pseudo-code:

Incoming string looks like this in Notepad++ (but uses little arrows in Notepad):

  "OnUser1" "target1ESCSetParentESCparentObj1ESC0ESC-1"
  "OnUser2" "target1ESCSetParentESCparentObj2ESC0ESC-1"
  "OnUser3" "target1ESCSetParentESCparentObj3ESC0ESC-1"
  "OnUser4" "target1ESCSetParentESCparentObj4ESC0ESC-1"

(The characters did not paste properly into the form, so below is an actual image.)

That string is assigned to IncomingString in the code below:

memStreamString = memStreamMgr.openString IncomingString
while memStreamString.eos() == false AND memStreamString.peekToken() != undefined do (
  theLineC= (memStreamString.readLine())
  print theLineC
  --This will print the text in the MAXScript listener
  filterString theLineC " " 
  --This will stop the code from executing and print **interrupted** in the Maxscript listener

So it appears this incoming data is using the character code that represents the ESC key on the keyboard.

I do not know how to sanitize this so that I can use it.

I find it odd that I can print the code but as soon as I try to run string functions that let me extract the data I want, Max stops executing and prints:

** interrupted **

I tried adding this code to the top of the parser:

escapeEnable = false

But that did not help (and according to the docs, is now defaulting to false anyway).
Attached Images
File Type: jpg maxscript_ESC.jpg (75.2 KB, 42 views)
Shawn Olson
Autodesk Expert Elite
3ds Max Charter Member

Developer of:
Wall Worm Tools for the Source Game Engine
CorVex Level Design Plugin

Last edited by wallworm : 06 June 2013 at 10:45 AM. Reason: clarification
  06 June 2013
OK... I found a solution:

replacementString = " " --set to whatever is best for needs
cleanString = substituteString taintedString "\x1b" replacementString
Shawn Olson
Autodesk Expert Elite
3ds Max Charter Member

Developer of:
Wall Worm Tools for the Source Game Engine
CorVex Level Design Plugin
  06 June 2013
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share 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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 02:34 AM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.