Hello,
I have the string like this, 0.0.0.1. I need to parse through this string and obtain the value that is after the second period and before the third period. What is the best way in Installshield to find the number in position 3?
I am playing with strFind and StrSub but have not gotten it to work just yet?
Please include a snippit of code if possible.
Thanks,
Robbie
This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Finding a Substring Within A String
Started by
elliottrb
, Aug 09 2002 17:48
3 replies to this topic
Posted 09 August 2002 - 19:31
Here's some snipptes of code for you, but I don't go as far out as you'd like. However, you can easily extend it to cover the remaining portions of the version number.
Code Sample |
function DetectFileVersion(szFilename, svVersion, svVersionMjr, svVersionMnr, szComment) NUMBER nResult, nPosition; begin // DETERMINE THE WHOLE VERSION NUMBER nResult = VerGetFileVersion (szFilename, svVersion); if (nResult = 0) then Debug("Successfully retrieved "+szComment+"'s version of '"+svVersion+"'.", INFORMATION); else MessageBox("ERROR: Unable to retrieve the version of "+szComment+".", SEVERE); abort; endif; // DETERMINE THE MAJOR VERSION NUMBER nPosition = StrFind(svVersion, "."); nResult = StrSub(svVersionMjr, svVersion, 0, nPosition); if(nResult != 0) then Debug("Successfully retrieved "+szComment+"'s major version of '"+svVersionMjr+"' from '"+svVersion+"'.", INFORMATION); else MessageBox("ERROR: Unable to retrieve the major version of "+szComment+".", SEVERE); abort; endif; // DETERMINE THE MINOR VERSION NUMBER nResult = StrSub( svVersionMnr, svVersion, nPosition + 1, StrLength(svVersion) ); if(nResult != 0) then Debug("Successfully retrieved "+szComment+"'s minor version of '"+svVersionMnr+"' from '"+svVersion+"'.", INFORMATION); else MessageBox("ERROR: Unable to retrieve the minor version of "+szComment+".", SEVERE); abort; endif; end; function DetectIEVersion(svVersion, svVersionMjr, svVersionMnr) NUMBER nResult; begin nResult = DetectFileVersion(WINSYSDIR ^ "shdocvw.dll", svVersion, svVersionMjr, svVersionMnr, "IE"); return nResult; end; |
Posted 14 August 2002 - 22:07
I do something along the same lines. But I need to check the current version against previously installed versions, as I don't want to Patch backwards!. Here's the code I use to do that. It doesn't particulary parse the product version, but I don't need to. A StrCompare more than meets my needs.
You have to keep updating the Product version on your string table, but I do this as a matter of coarse. Hope this helps someone
Code Sample |
szMsg6 = "A more current version of TheProduct has been found on your system.\n"; szMsg7 = "The installer will now abort."; // Check Previous version to make sure we are installing a higher version listResults = ListCreate(STRINGLIST); RegDBQueryKey("SOFTWARE\\Our Company\\TheProduct",REGDB_KEYS,listResults); nCount = ListCount(listResults); NumToStr(sCount,nCount); nLast = nCount -1; ListSetIndex(listResults, nLast); ListCurrentString(listResults,sLastInstall); sCurrentInstall = @Product_Version; nResult = StrCompare(sLastInstall, sCurrentInstall); //results from StrComp: below zero A less than B; zero - equal; // over zero - A greater than B if (nResult > 0) then MessageBox(szMsg6 + szMsg7, INFORMATION); abort; endif; ListDestroy(listResults); |
You have to keep updating the Product version on your string table, but I do this as a matter of coarse. Hope this helps someone
There is great chaos under heaven, and the situation is excellent. (Mao Tse Tung)
Posted 27 August 2002 - 22:42
FYI, I just learned that IS has a built-in VerCompare function which is probably good to make use of when doing this stuff.