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

Find and Replace using Custom Dialog

Good morning,

Can anyone help me on the below.

I have file in my [INSTALLDIR] with name testfile.asa and I have two hardcoded strngs - String1 and String2 in that file. I would like to replace these strings as per user input. For this I have created a Custom diaog to accept the values. from here I am unable to proceed further to replcae these values in my file.

Can you please do the needful.

Warm Regards,
Ameer
Labels (1)
0 Kudos
(3) Replies
schmoli
Level 6

I have to do this a lot -- unfortunately it requires stepping out of InstallShield and using a custom action.

In my previous installations I had just created a very simple executable file that took 3 arguments -- a filename, string to search for, and string to replace. After learning about DTF (Thanks Chris Painter!) I now have some more complex .Net CA dll's that do regular expression searching, replacing, and match reformatting. It sounds like for what you are doing you can definitely get away with a simple search/replace executable.
0 Kudos
nadiya
Level 2

Hi,
I too have the same issue and i have been trying to use custom actions but was not able to figure out a way. Can anyone please suggest some examples or any help as to how to do it.

Any information is appreciated,

Thanks in advance
0 Kudos
ameer09
Level 3

\*--------------------------------------------------------------*/
#define SOURCE_DIR INSTALLDIR
#define SOURCE_FILE "global.asa"

#include "Ifx.h"
export prototype globalsettings(HWND);

function globalsettings(hMSI)
STRING svLine, szNewString, svReturnLine, szMsg, svResult;
NUMBER nvLineNumber, nvResult;
begin
// Find the search string in the source file.
nvResult = FileGrep (SOURCE_DIR ^ SOURCE_FILE, "ameer" , svReturnLine, nvLineNumber, RESTART);
switch(nvResult)
case FILE_NOT_FOUND:
// Report error; then abort.
MessageBox( SOURCE_FILE + " not found.", WARNING);
abort;
case FILE_LINE_LENGTH:
// Report error; then abort.
MessageBox (SOURCE_FILE + "lines too long.", WARNING);
abort;
case OTHER_FAILURE:
// Report error; then abort.
MessageBox (SOURCE_FILE + "Unknown failure on call to FileGrep.",
WARNING);
abort;
endswitch;
// Loop until end of file.
while (nvResult != END_OF_FILE)
// Set up message string for SprintfBox.
szMsg = "'ameer' found in line %d of %s:\n\n'%s'";


// Report matching line from file.
SprintfBox (INFORMATION, "SISWeb Info", szMsg, nvLineNumber, SOURCE_FILE, svReturnLine);
// Search again.
nvResult = FileGrep (SOURCE_DIR ^ SOURCE_FILE, "ameer" , svReturnLine, nvLineNumber, CONTINUE);

endwhile;
StrReplace (svReturnLine , "ameer" , "suhaan" , 0);end;


anything wrong in the above script. I am getting the string through message box but it is not getting replcaed. can anyone help me..plz
0 Kudos