cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
hbgsoft
Level 3

Problems with text replacement

Hello,

we are working on a Installscript MSI project. During the installation process, in a custom dialog, the end-user inputs a numeric code, which is stored in a variable named "Etb".
Our problem is located in the following step:
- this variable is used in an sql script (database attachment)
- in this sql script, I have the following piece of code: "...%etb%.mdf..."

I want to replace %etb% by the value of my "Etb" variable. But we don't know how to use the text replacement with property manager. The help library talks only about system variables.

Thank you in advance for any helps,

Cedric and Franck
Labels (1)
0 Kudos
(2) Replies
m_rudolph
Level 6

I've been using a FindAndReplace function from InstallSite.org:

/////////////////////////////////////////////////////////////////////////////////////
//
// File Name: FindAndReplace
//
// Description: Finding a line containing a specified String, and replacing
// with a string you specify. A complete find-and-replace function
//
// Comments: Function takes three String arguments
//
// Usage: call function passing the three String parameters required
// i.e FindAndReplace("C:\winnt\vb.ini","Search","Replace")
// Find and Replace function not case-sensitive
//
// Script Author: Dinesh
// Date last modified: 04/07/02
////////////////////////////////////////////////////////////////////////////////


prototype FindAndReplace(STRING, STRING, STRING);

//Global Variables
STRING SrcDirFileName, SrchString, RplcString;
STRING firstPart;
NUMBER SrchLen, nvLineNumber;


function FindAndReplace(SrcDirFileName, SrchString, RplcString)
STRING svReturnLine,szString, secPart;
NUMBER nReturn, subPos, nStringLength;
begin
Disable(STATUSEX); //stop displaying the progress bar
ShowObjWizardPages(NEXT); //WARNING this may throw a user interface
SrchLen = StrLength(SrchString); //length of search string
nvLineNumber = 0; //pre-set file line number to 0

Din:
while (FileGrep (SrcDirFileName, SrchString, svReturnLine, nvLineNumber, RESTART)=0)
//subPos is the number where the first char of search string was found
subPos = StrFind(svReturnLine, SrchString);
//firstPart is the string upto search string but not including searchString
StrSub (firstPart, svReturnLine, 0, subPos);
//get length of string to pass to StrSub
nStringLength = StrLength (svReturnLine);
//secPart is the string after search string
StrSub (secPart, svReturnLine, subPos+SrchLen, nStringLength);
//new string is firstPart followed by replace string followed by secPart
TextSub.Value( "SUBBED" ) = RplcString;
szString = firstPart+""+secPart;
TextSub.Substitute( szString );
//write line replacing original
FileInsertLine (SrcDirFileName, szString, nvLineNumber, REPLACE);
//the code below examines the line written back for any other occurences
//systematically searching and re-writting back to file

//search first line again for search string
if (FileGrep (SrcDirFileName, SrchString, svReturnLine, nvLineNumber, RESTART)=0) then
goto Din; //another occurence found
else
//increment line number and start all over again
nvLineNumber = nvLineNumber + 1;
endif;
endwhile; //while loop exited when END_OF_FILE reached
end;
0 Kudos
hbgsoft
Level 3

Ok thank you.

I have found the problem without use the find and replace function.

But now, I have an other problem. I have 2 Sql scripts in my SQL connection. And one of them can not to be execute, if a feature is selected or not by the end-user.

I know I can use property manager, but I don't know how manage that.

I don't know how to use the condition builder...
0 Kudos