how to implement a callback function in UFT vbscript -
i've tried search online couldn't find answer need. here's task , requirement. have 2 function, first 1 checks condition , returns true , false. 2nd 1 starts timer , checks results of 1st function periodically , exit when return value becomes true. here's 2 funcitons
' 1st 1 checks if item exists in javalist public function existinjavalist(byref javalist, byval itemname) dim itemcount, i, ret ret = false itemcount = javalist.getroproperty("items count") i=0 itemcount -1 if javalist.getitem(i) = itemname ret = true exit end if next existinjavalist = ret end function ' 2nd 1 checks condition every 10 seconds , if condition true, ' returns true. otherwise, times out after 120 seconds , returns false. function waitforcondition(byval condition) dim starttime, existflag, accumulatetime starttime = timer() existflag = true until cbool(condition) wait(10) timeelapsed = timer() if timeelapsed - starttime > 120 existflag = false exit end if loop waitforcondition = existflag end function
how pass 1st function parameter of 2nd function it's called every 10 seconds in 2nd function?
appreciate advice. thanks.
sorry, original post not formatted properly. i've reposted here
function existinjavalist(byref javalist, byval itemname) dim itemcount, i, ret ret = false itemcount = javalist.getroproperty("items count") i=0 itemcount -1 if javalist.getitem(i) = itemname ret = true exit end if next existinjavalist = ret end function function waitforcondition(byval condition) dim starttime, existflag, accumulatetime starttime = timer() existflag = true until cbool(condition) wait(10) timeelapsed = timer() if timeelapsed - starttime > 120 existflag = false exit end if loop waitforcondition = existflag end function
Comments
Post a Comment