adspace
I want to open a text file and then search some specified
text in it and then replace that text with some other text
i found that text in .txt but do not know how to replace
that text can any body help me. if possible put the code
for qtp
Answer Posted / venki
Function Replacestring(filepath,find_string,replace_string)
Const ForReading = 1
Const ForWriting = 2
Dim obj,notepad,myline,newText
Set obj = CreateObject("scripting.FileSystemObject")
Set notepad=obj.OpenTextFile(filepath,ForReading)
Do Until notepad.AtEndOfStream
myline = notepad.readall
loop
msgbox myline
newText = Replace(myline ,find_string,replace_string)
Set notepad = obj.openTextFile(filepath, ForWriting )
notepad.WriteLine newText
notepad.Close
msgbox newText
end function
Call Replacestring("C:\New Folder\fade to
black.txt","me","you")'>mention your file path,string to
find,replacing string.
| Is This Answer Correct ? | 7 Yes | 2 No |
Post New Answer View All Answers
How software tester can use constants and variables in scripts?
Define Environment Variable in UFT and its uses?
Pls can anybody send me the Recent Technical and Interview Questions Which were asked in IBM(QTP)Automation PLZZZZZZZZZ
Please help me by providing the License key for QTP 9.2, at guru_aarya@yahoo.co.in Best Regards Gururaj.B
how to use the regular expression for the below code-- swf("application name").swftreeview ("Treename").select"Medication;Pharmacy:56" There is a tree view window of the folder's ie Medication- >Pharmacy(sub folder)with 56 as count of records...The records can be different or if no records present in the specific folder..then it show "Paharmacy:-no records".Whe i record at the first time .....and try to rerun the same script with different records count say "pharmacy:800"..qtp is not regnizing it...therefore i want to user regular expression..but donot now how to use it and where to use...i have tried.... swf("application name").swftreeview ("Treename").select"Medication;Pharmacy:\*"..but it s of no use..plz help..me
What is the new version of qtp which is recently released in the market?
Hi all Can u give me the link where we can download full version of qtp my mail id is karthic.venkitapathi@gmail.com
can any body tell me how i create a simple script and apply output value on it .pls send me a step by step process
hi i have 4 yrs exp in manual and automation testing using QTP i need sample resumes plz can u send this mail id pbre1980@gmail.com
any body can you help me what is the script to automate an comand promt
Any body have QTP 9.5 licence key. please provide me at madhukar_dec30@yahoo.co.in
How to give a call to another action from one action?
I want to do Certification course in QTP. For this I request you to suggest the best Tutorial in PDF format. Hence, if possible, kinldy mail PDF file to my mail-ID: sushmapokhriyal79@gmail.com
I want to open a Notepad window without recording a test and I do not want to use System utility Run command as well. How do I do this?
if anyone has idea of the interview procedure in covansys, plz send me a mail?