Monday, February 15, 2010

Check if a String contains a substring using InstallScript

Check if a String contains a substring.

If you want to check whether a string contains a specific substring or not, it's quite easy in .net or Java or any other OO language. But when it comes to InstallScript it's not that straight forward. In spent little time on InstallShield help but could not manage anything usual. And then finally google help me to reach some example on that. Here is a function I wrote to use in my project:


prototype BOOL IsStringContains(STRING,STRING);

function BOOL IsStringContains(szSource, szArgs)

BOOL bIsContains;

begin

if(szSource % szArgs) then

bIsContains = TRUE;

else

bIsContains = FALSE;

endif;

return bIsContains;

end;


And then I use this call this function like this:


if(IsStringContains("This is Zakirul","Zakirul")) then

MessageBox("String match found.", INFORMATION);

else

MessageBox("String doesn't found",INFORMATION);

endif;


Hope this will help you.

Thanks,

Zakirul

No comments: