QTP/UFT: REMOVE QC/ALM HTML STRING FROM ORIGINAL STRING



'UTILITY.QFL
'REMOVE QC/ALM HTML STRING FROM ORIGINAL STRING
'Created by : Miah, Create date 05/24/2013
'strFul = Origional string
'strRemov1 = Any unwanded string first time will remove
'strRemov2 = Any unwanded string second time will remove
Public Function strReplace(strFul,strRmov1,StrRmov2)
	dCot = """
	strReplace =Replace(strFul, strRmov1, "")
	strReplace =Replace(strReplace, strRmov2, "")
	strReplace =Replace(strReplace, dCot, "'")
End Function

'FIND LAST FOLDER NAME FROM TEST PLAN DIRECTORY
'Created by : Miah, Create date 05/28/2013
Public Function findFoldNm(fulPath)
	spltStr=Split(fulPath,"\")
	cnt = uBound(spltStr) + 1
	'MsgBox cnt
	itr =0
	for each x in spltStr
		itr = itr + 1
		if cnt = itr Then
			findFoldNm = x
		End If
	next
End Function

'Get KEY and VALUE IN ARRY 
'input keyValuArray = (Test1=1, Test2=2) and key = (test2) output will be 2 
Public Function getKeyValue(keyValu,key)
	aryKeyValue =""
	For i = 1 To UBound(keyValu) Step 1
		If key= keyValue(keyValu(i))(0) Then
			getKeyValue= keyValue(keyValu(i))(1)
			Exit For
		End If
	Next
End Function

'GET KEY and VALUE
'Created by : Miah, Create date 06/05/2013
'input Test=1 output will be 1
Public Function keyValue(keyVal)
	spltStr=Split(keyVal,"=")
	If UBound(spltStr) = 0 Then
		keyVal = keyVal & "="
		spltStr=Split(keyVal,"=")
	End If
	spltStr(0) = Replace(spltStr(0)," ","")'blank space not allowed in key
	keyValue = spltStr
End Function

'DELETE EXCEL FILE
Public Function dltExlFile(fPath)
    Set fso = CreateObject("Scripting.FileSystemObject")
    fExist = fso.FileExists(fPath & ".xls")
    If (fExist = True) Then
    	fso.DeleteFile(fPath & ".xls")
    End If
End Function

'REMOVE ANY UNWANTED STRING FROM ORIGIONAL STRING
'strFul = Origional string
'strRemov1 = Any unwanded string first time will remove
'strRemov2 = Any unwanded string second time will remove
Public Function strReplace(strFul)
	Dim strRmov (15)

	strRmov(1)="<html><body><div align=""left"">"
	strRmov(2)="</div></body></html>"
	strRmov(3)="<html>"
	strRmov(4)="<body>"
	strRmov(5)="</html>"
	strRmov(6)="</body>"
	strRmov(7)="<html><body>"
	strRmov(8)="</html></body>"
	strRmov(9)="</span></font></div></body></html>"
	strRmov(10)="</span></font>"
	strRmov(11)="<font face=""Arial""><span style=""font-size:8pt"">"
	strRmov(12)="<div align=""left""><font face=""Arial""><span style=""font-size:8pt"">"
	strRmov(13)="<div align=""left"">"
	strRmov(14)="</div>"
	strRmov(15)="&nbsp;"
	
	strReplace =strFul
	For i = 1 To UBound(strRmov) Step 1
		strReplace =Replace(strReplace, strRmov(i), "") 'Remove all Unwanted character
		strReplace = Replace(strReplace, vbCrLf, "")'Remove new line from the string
	Next
	strReplace =Replace(strReplace, "&quot;", "'")
	
End Function

'Find login information from the text file
Public Function getLogInfo(key)
	getLogInfo=""
	fPath = Environment.Value("txFilePath")

	Set filSys = CreateObject("Scripting.FileSystemObject")
	Set filOpn = filSys.OpenTextFile(fPath) 'Get main text file
    
	Do While filOpn.AtEndOfStream <> True And getLogInfo=""
		redFile = filOpn.ReadLine
    	ck = InStr(redFile, key)
    	If (ck <> 0) Then
    		spltStr=Split(redFile,"=")
			If UBound(spltStr) > 0 Then    		
    			getLogInfo = spltStr(1)
    		End If
     	End If
	Loop ' End For loop here
End Function

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s