|
Description
A small script that works like printf in WinRunner for QTP
Solution
Hope this would help others... I was having problems with this and posted on Forum and there on came up with this sort of solution.
Function UniqueMe()
dim myDate, myTime, Unique, TempArray
myTime=split(time(),":")
myDate=split(FormatDateTime(date(),vbshortdate),"/")
TempArray=split(myTime(2)," ")
Unique=myDate(0)&myDate(1)&myDate(2)&myTime(0)&myTime(1)&TempArray(0)&TempArray(1)
UniqueMe=Unique
End Function
Function CreatePrintLog()
dim FileID, FileSysObj, FileName
FileID = UniqueMe()
FileName="c:\" &FileID &".txt"
' Create a File Object
Set FileSysObj = CreateObject("Scripting.FileSystemObject")
' not required but its good to have
do while FileSysObj.FileExists(FileName) = TRUE
FileID = UniqueMe()
FileName="c:\" &FileID &".txt"
Loop
FileSysObj.CreateTextFile FileName, True
OpenPrintLog(FileName)
CreatePrintLog=FileID
End Function
Function OpenPrintLog(FileName)
' load the shell execute functions
Extern.Declare micLong, "ShellExecute","shell32.dll","ShellExecuteA", micLong, micString, micString, micString, micString, micLong
Const SW_RESTORE = 9
rc=extern.ShellExecute (0,"open","notepad.exe",FileName,"",SW_RESTORE)
End Function
dim File
File=CreatePrintLog()
Window("text:="&File &".*").WinEditor("nativeclass:=Edit").Type "asdfs" + micReturn |
|