Sign in to follow this  
Followers 0
jwurmz

StringReplace is eating my string?

4 posts in this topic

#1 ·  Posted (edited)

I'm opening a file (w/ flag 16), reading the contents of a file as binary string, converting the binary string (with BinaryToString) to a 'regular' string, and trying to StringReplace a potion of it based on a start value (portion length = replacement string length, start value = predetermined offset in the file).

The problem is StringReplace is returning 1 (along with 'eating' my source string) and I'm not exactly sure why. Some of the characters in the converted 'regular string' are sometimes unprintable characters; they may be any value 0-255.

I guess my question is -- does StringReplace return error = 1 if it encounters any unprintable characters in the source string?

Edited by jwurmz

Share this post


Link to post
Share on other sites



Can you show a simplified code failing to work as you expect, along if possible with an example of the contents of the offending file?


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

Actually, I found a workaround by using a couple extra StringMid steps instead -- works exactly as I expect it to now. Thank you

A lot of functions choke on Null characters. It would be easier to just work with the binary.

I tried working with it in binary form and all of the sudden other areas of my program started acting funny.

Can you show a simplified code failing to work as you expect, along if possible with an example of the contents of the offending file?

If you're still wanting to look at it for the sake of curiosity, I can supply the data files and the source but the logic for StringReplace has been completely removed from my code so you would have to build that part back in yourself. The problem has been sidestepped, so it's up to you.

Thanks for all your help over the last week jchd, it's very much appreciated!

Share this post


Link to post
Share on other sites

Thanks for all your help over the last week jchd, it's very much appreciated!

You're welcome!

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0