脚本开头
Function main()
脚本结束
End function
{Function}
Set Common=new CommonClass
main()
Function QTP_Release_Memory(hwnd)
Extern.Declare micVoid ,"SendMessageA","user32.dll","SendMessageA",micHwnd,micInteger,micInteger,micInteger
SC_MINIMIZE = &HF020&
SC_MAXIMIZE = &HF030&
WM_SYSCOMMAND = &H112
Extern.SendMessageA hwnd,WM_SYSCOMMAND,SC_MINIMIZE,0
wait 3
Extern.SendMessageA hwnd,WM_SYSCOMMAND,SC_MAXIMIZE,0
wait 3
End Function
If Err.Number <> 0 Then
snap_screen("运行失败截图")
err.Raise vbObjectError + 513,"",Err.Description
end if
截图 Snap_Screen
Sub snap_screen(param1)
set fs =createobject("scripting.filesystemobject")
If not (fs.FolderExists("{MainDir}\result\image\{track}\{caseId}")) Then
create fs,"{MainDir}\result\image\{track}\{caseId}"
End If
Set objfol=fs.GetFolder("{MainDir}\result\image\{track}\{caseId}")
preIndex=objfol.Files.Count+1
While len(preIndex)<4
preIndex="0"&preIndex
Wend
desktop.CaptureBitmap "{MainDir}\result\image\{track}\{caseId}\"&preIndex&"."¶m1&".png",true
End Sub
memSub 变量数据存入数据池,提供变量计算功能
Sub memSub(param1,param2,param3,tableName,isVertical)
memKey = param1
memValue = param2
set fs =createobject("scripting.filesystemobject")
If Not fs.FileExists("{MainDir}\tempData.txt") Then
row=-1
else
set ts=fs.opentextfile("{MainDir}\tempData.txt",1,false,-1)
strComputer = ts.ReadAll
ts.close
strLine = Split(strComputer,vbcrlf)
row = ubound(strLine)'tempData的行数
End If
Dim position,lineValue(500,2),errData'定义最大行数
int index=0
int rowIndex=0
For i=0 to row
If strLine(i) = "" Then
index=index+1
else
tempLine = Split(strLine(i),"$-----$")
lineValue(rowIndex,0) = tempLine(0)
lineValue(rowIndex,1) = tempLine(1)
rowIndex=rowIndex+1
End If
Next
row=row-index
keyFlag = false
tagFlag = false
If InStr (memValue,"<") <> 0 Then
tagFlag = true
End If
For i =0 to row
If lineValue(i,0) = memKey Then
position = i
keyFlag = true
Exit for
End If
Next
If tagFlag Then
memValue = Replace(memValue,"<","")
memValue = Replace(memValue,">","")
TelnetText= content_wait(param3,tableName,isVertical)
TelnetText = Replace(TelnetText,vbcrlf,";")
If InStr(memValue," ")=0 Then
TelnetText = Replace(TelnetText," ",";")
End If
If instr(TelnetText,memValue) Then
'msgbox memValue
tagTemp = Split(TelnetText,"|")
For i =0 to UBound(tagTemp)
If instr( tagTemp(i),memValue) Then
tagTemp2 = Split(tagTemp(i),";")
hasFound=false
For j=0 to Ubound(tagTemp2)
If instr(1,tagTemp2(j),memValue)>0 Then
If instr(1,tagTemp2(j),memValue)+len(memValue)=len(tagTemp2(j))+1 and j<Ubound(tagTemp2) Then
For k=j+1 to Ubound(tagTemp2)
If tagTemp2(k)<>empty and tagTemp2(k)<>"" Then
memValue = tagTemp2(k)
hasFound=true
Exit for
End If
Next
elseif instr(1,tagTemp2(j),memValue)+len(memValue)<len(tagTemp2(j))+1 then
memValue=right(tagTemp2(j),len(tagTemp2(j))-instr(1,tagTemp2(j),memValue)-len(memValue)+1)
hasFound=true
Exit for
else
End If
If hasFound=true Then
Exit for
End If
End If
Next
If hasFound=true Then
Exit for
End If
End If
Next
'Exit Do
else
err.Raise vbObjectError + 513,"","找不到关键字:" & memValue
End If
If not keyFlag Then
lineValue(row+1,0) = memKey
lineValue(row+1,1) = memValue
else
lineValue(position,1) = memValue
End If
else
If not keyFlag Then
lineValue(row+1,0) = memKey
lineValue(row+1,1) = memValue
else
lineValue(position,1) = memValue
End If
End If
set fs =createobject("scripting.filesystemobject")
If fs.FileExists("{MainDir}\tempData.txt") Then
fs.DeleteFile("{MainDir}\tempData.txt")
End If
set ts=fs.opentextfile("{MainDir}\tempData.txt",8,true,-1)
If keyFlag Then
For i =0 to row-1
ts.WriteLine(lineValue(i,0) & "$-----$" &lineValue(i,1))
Next
ts.Write(lineValue(row,0) & "$-----$" &lineValue(row,1))
else
For i =0 to row
ts.WriteLine(lineValue(i,0) & "$-----$" &lineValue(i,1))
Next
ts.Write(lineValue(row+1,0) & "$-----$" &lineValue(row+1,1))
End If
ts.close
End Sub
领导让把这段VB代码写成java的格式,怎么写啊?
Function main()
脚本结束
End function
{Function}
Set Common=new CommonClass
main()
Function QTP_Release_Memory(hwnd)
Extern.Declare micVoid ,"SendMessageA","user32.dll","SendMessageA",micHwnd,micInteger,micInteger,micInteger
SC_MINIMIZE = &HF020&
SC_MAXIMIZE = &HF030&
WM_SYSCOMMAND = &H112
Extern.SendMessageA hwnd,WM_SYSCOMMAND,SC_MINIMIZE,0
wait 3
Extern.SendMessageA hwnd,WM_SYSCOMMAND,SC_MAXIMIZE,0
wait 3
End Function
If Err.Number <> 0 Then
snap_screen("运行失败截图")
err.Raise vbObjectError + 513,"",Err.Description
end if
截图 Snap_Screen
Sub snap_screen(param1)
set fs =createobject("scripting.filesystemobject")
If not (fs.FolderExists("{MainDir}\result\image\{track}\{caseId}")) Then
create fs,"{MainDir}\result\image\{track}\{caseId}"
End If
Set objfol=fs.GetFolder("{MainDir}\result\image\{track}\{caseId}")
preIndex=objfol.Files.Count+1
While len(preIndex)<4
preIndex="0"&preIndex
Wend
desktop.CaptureBitmap "{MainDir}\result\image\{track}\{caseId}\"&preIndex&"."¶m1&".png",true
End Sub
memSub 变量数据存入数据池,提供变量计算功能
Sub memSub(param1,param2,param3,tableName,isVertical)
memKey = param1
memValue = param2
set fs =createobject("scripting.filesystemobject")
If Not fs.FileExists("{MainDir}\tempData.txt") Then
row=-1
else
set ts=fs.opentextfile("{MainDir}\tempData.txt",1,false,-1)
strComputer = ts.ReadAll
ts.close
strLine = Split(strComputer,vbcrlf)
row = ubound(strLine)'tempData的行数
End If
Dim position,lineValue(500,2),errData'定义最大行数
int index=0
int rowIndex=0
For i=0 to row
If strLine(i) = "" Then
index=index+1
else
tempLine = Split(strLine(i),"$-----$")
lineValue(rowIndex,0) = tempLine(0)
lineValue(rowIndex,1) = tempLine(1)
rowIndex=rowIndex+1
End If
Next
row=row-index
keyFlag = false
tagFlag = false
If InStr (memValue,"<") <> 0 Then
tagFlag = true
End If
For i =0 to row
If lineValue(i,0) = memKey Then
position = i
keyFlag = true
Exit for
End If
Next
If tagFlag Then
memValue = Replace(memValue,"<","")
memValue = Replace(memValue,">","")
TelnetText= content_wait(param3,tableName,isVertical)
TelnetText = Replace(TelnetText,vbcrlf,";")
If InStr(memValue," ")=0 Then
TelnetText = Replace(TelnetText," ",";")
End If
If instr(TelnetText,memValue) Then
'msgbox memValue
tagTemp = Split(TelnetText,"|")
For i =0 to UBound(tagTemp)
If instr( tagTemp(i),memValue) Then
tagTemp2 = Split(tagTemp(i),";")
hasFound=false
For j=0 to Ubound(tagTemp2)
If instr(1,tagTemp2(j),memValue)>0 Then
If instr(1,tagTemp2(j),memValue)+len(memValue)=len(tagTemp2(j))+1 and j<Ubound(tagTemp2) Then
For k=j+1 to Ubound(tagTemp2)
If tagTemp2(k)<>empty and tagTemp2(k)<>"" Then
memValue = tagTemp2(k)
hasFound=true
Exit for
End If
Next
elseif instr(1,tagTemp2(j),memValue)+len(memValue)<len(tagTemp2(j))+1 then
memValue=right(tagTemp2(j),len(tagTemp2(j))-instr(1,tagTemp2(j),memValue)-len(memValue)+1)
hasFound=true
Exit for
else
End If
If hasFound=true Then
Exit for
End If
End If
Next
If hasFound=true Then
Exit for
End If
End If
Next
'Exit Do
else
err.Raise vbObjectError + 513,"","找不到关键字:" & memValue
End If
If not keyFlag Then
lineValue(row+1,0) = memKey
lineValue(row+1,1) = memValue
else
lineValue(position,1) = memValue
End If
else
If not keyFlag Then
lineValue(row+1,0) = memKey
lineValue(row+1,1) = memValue
else
lineValue(position,1) = memValue
End If
End If
set fs =createobject("scripting.filesystemobject")
If fs.FileExists("{MainDir}\tempData.txt") Then
fs.DeleteFile("{MainDir}\tempData.txt")
End If
set ts=fs.opentextfile("{MainDir}\tempData.txt",8,true,-1)
If keyFlag Then
For i =0 to row-1
ts.WriteLine(lineValue(i,0) & "$-----$" &lineValue(i,1))
Next
ts.Write(lineValue(row,0) & "$-----$" &lineValue(row,1))
else
For i =0 to row
ts.WriteLine(lineValue(i,0) & "$-----$" &lineValue(i,1))
Next
ts.Write(lineValue(row+1,0) & "$-----$" &lineValue(row+1,1))
End If
ts.close
End Sub
领导让把这段VB代码写成java的格式,怎么写啊?