This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Finding an unknown string between two known strings
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
Feb 16, 2011
08:48 AM
Finding an unknown string between two known strings
Hi everyone,
I tried searching for this, but I couldn't find an answer. During one of our installs, we are allowing the user to update which database they are pointing too, this information is stored in an XML file. I have code to replace that value, but I wanted to read that value before hand so we can display where it's currently pointed. I'm having trouble finding out how exactly to do that. I know the string that comes before the machine name, and the one after, but I will never be able to tell what the actual value is, nor the length of it. Is there an easy function to do this?
I'm looking for a function that would take an input like this:
stringStart = '" '
findString(startString, endString);
is this possible?
I tried searching for this, but I couldn't find an answer. During one of our installs, we are allowing the user to update which database they are pointing too, this information is stored in an XML file. I have code to replace that value, but I wanted to read that value before hand so we can display where it's currently pointed. I'm having trouble finding out how exactly to do that. I know the string that comes before the machine name, and the one after, but I will never be able to tell what the actual value is, nor the length of it. Is there an easy function to do this?
I'm looking for a function that would take an input like this:
stringStart = '"
findString(startString, endString);
is this possible?
(1) Reply
Feb 16, 2011
05:16 PM
Searching these forums for "installscript xml" will turn up some sample code for reading XML documents, and I think there's some regular expression code sprinkled here and there.
Otherwise, an old-old-school approach might be (usual disclaimers about lack of error checking, worked once on one machine, etc.):
Otherwise, an old-old-school approach might be (usual disclaimers about lack of error checking, worked once on one machine, etc.):
function OnBegin( )
STRING searchme, before, after, foundit;
NUMBER beforepos, afterpos;
begin
// beginning and end of your string
before = '';
// in practice, this is the string you read from the file, of course
searchme = before + "servo" + after;
// find where the prefix ends and the postfix begins
beforepos = StrFind(searchme, before) + StrLengthChars(before);
afterpos = StrFind(searchme, after);
// drag out the characters in that range
StrSub(foundit, searchme, beforepos, afterpos - beforepos);
// here's hoping:
MessageBox("Found it: " + foundit, INFORMATION);
end;