StringReplace crashing - string length limitations?

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
mpopkin
Newbie
Posts: 15
Joined: Wed Dec 17, 2008 5:56 pm

StringReplace crashing - string length limitations?

Post by mpopkin » Thu Jul 26, 2012 4:28 am

Hi All,

What are the string length limitations for the StringReplace function?

I am currently searching an HTML template string that is about 2000 chars in length. There is a replace tag in it where I replace it with another string that is about 5000 chars in length. I stepped through the code and there are no empty strings at that point.

Code: Select all

StringReplace>%strTemplate%,|EquipmentHistoryK|,%LargeReplaceString%,strTemplate
All the other replace actions up to that point work fine, but crash when using a large replace string.

I also tried doing this with EVAL>Replace. Again, it works fine for small strings, but crashes with a large replace string value.

Is there a better way to do this?


BTW, I use MS ver 11.1.19

Thanks!

-mark

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Jul 26, 2012 6:26 am

There should be no length limit - indeed we routinely use StringReplace with even larger strings than that.

I notice you are on version 11.1.19. The last v11 release was 11.1.23. So the first thing I would do is update your software by going to:
http://www.mjtnet.com/dldregd.htm

There are some references to StringReplace in the history list:
http://www.mjtnet.com/mswhatsnew.htm
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

mpopkin
Newbie
Posts: 15
Joined: Wed Dec 17, 2008 5:56 pm

Post by mpopkin » Thu Jul 26, 2012 4:02 pm

Hi Marcus,

Thanks. I upgraded my version to 11.1.23, but it still behaves the same. There must be something in the search and/or replace contents that is mucking it up.

I am able to get around it by preparing the strings used by doubling up the quotes and replacing CRLF's. I then run them through the vbscript Replace function and it works perfectly:

Code: Select all

  StringReplace>strTemplate,","",strTemplate
  StringReplace>strTemplate,CRLF," & vbCRLF & ",strTemplate
  StringReplace>LargeReplaceString,","",LargeReplaceString
  StringReplace>LargeReplaceString,CRLF," & vbCRLF & ",LargeReplaceString
  
  VBEval>Replace("%strTemplate%","|EquipmentHistoryK|","%LargeReplaceString%"),strTemplate
For whatever reason, StringReplace would not take the contents of my LargeReplaceString for the replace argument. It must be something to do with the content (complex HTML).

I'm happy enough that it will work with vbscript.

-mark

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts