nstnst
Level 2

Problem with strings replacement on an XML file, using installscript

Hi, 

I'm using the following function on my installscript for replacing strings on a XML file, the strings are being replaced successfully.
The really strange thing that happens is that only on 2 computers (windows 10 -  in case it matters), there are several characters that where added at the beginning of my XML file, after calling this function. It doesn't happen on the computer where Installshield is installed so I cannot debug this issue.

I have tried running the installation on several computers,  windows 10, windows 7 but nothing is wrong there so I cannot figure out what is causing it.. 

Do you have any idea how to solve this issue?

Thanks:) 

 Capture.PNG

 

/////////////////////////////////////////////////////////////////////////////////////
//
//  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;

 

 

Labels (1)
0 Kudos
0 Replies