cnxmax
asked on
VBScript Binary Replace Function
I'm looking for some kind of function that will do a binary replace. So it needs to be the same as the regular Replace function in vbscript, but I need to be able to submit binary data. So implemented, this function would would like this:
MyNewBinaryData = BinaryReplace(MyOldBinaryD ata, BinaryToFind, BinaryToReplaceWith)
I've started to hack together away to accomplish what I need using MidB, but I can't seem to make it work without messing up my binary data.
MyNewBinaryData = BinaryReplace(MyOldBinaryD
I've started to hack together away to accomplish what I need using MidB, but I can't seem to make it work without messing up my binary data.
post your code please (we won't write it for you, but will help....)
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Hi, I'm not sure whether you've tried this, but have a go with the standard VBScript Replace function, and just specify vbBinaryCompare as the last parameter for the function.
http://msdn2.microsoft.com/en-us/library/238kz954.aspx
Regards,
Rob.
http://msdn2.microsoft.com/en-us/library/238kz954.aspx
Regards,
Rob.
ASKER
Thanks for the tip RobSampson. I have tried that and haven't been able to get it to work. The strange thing about it is that the binary compare is the default method for the replace function, which I frequently use for regular text string data. So I'm not sure what the difference is between binary compare and text compare.
I don't know for sure that the regular replace option can't be used, because with this problem there are many areas where I'm not really sure what I'm doing so there might be two things I'm doing wrong at any given attempt.
I was hoping this wasn't such an uncommon problem and that someone could just point me to simple solution. At this point I'm still looking for a reliable binary replace
I don't know for sure that the regular replace option can't be used, because with this problem there are many areas where I'm not really sure what I'm doing so there might be two things I'm doing wrong at any given attempt.
I was hoping this wasn't such an uncommon problem and that someone could just point me to simple solution. At this point I'm still looking for a reliable binary replace
Looking at the functions you've got, would it be easier to convert all binary chunks into string variables, then perform the standard replace, and convert back to binary?
Or am I off track with what you're trying to achieve?
Regards,
Rob.
Or am I off track with what you're trying to achieve?
Regards,
Rob.
ASKER
I'm not really sure what to do with this question. The only solution I have found is the one I came up with myself. It's not what I was hoping for, but it works.
Should I just accept a solution or can should this question be closed in some other way?
Should I just accept a solution or can should this question be closed in some other way?
You can post a request in the Community Support --> General zone to have this question either PAQ'ed with an answer of yours, or deleted, if you don't need it, including the link to this question.
Regards,
Rob.
Regards,
Rob.