A Timing Issue
Posted: Wed Jul 31, 2013 6:54 pm
My program has the ability to open 3 different internal browsers concurrently. I keep a list of those browsers in a global variable called gBrowserList. Each line in the list contains the name of the browser stack and the browser ID comma delimited. I have a command called 'newBrowser' which when called from the File Menu will open, connect and update that list. I can call that menu manually and end up with gBrowserList looking like:
Browser1,5
Browser2,8
Browser3,22
With all browsers closed thee list looks like:
Browser1,0
Browser2,0
Browser3,0
If a browser is open and I do something that needs to access it, it does so without a problem. The issue comes when no browsers are open and I want to access one. Right now I have to go to the File Menu to take 'newBrowser' and then issue the command to do something with it. I would like to make it so that when no browsers are present, a command that requires the use of a browser will open it automatically and use it.
To that end I have written the following function:
function CheckForBrowser
global gBrowserList
put false into bFound
repeat with i=1 to number of lines of gBrowserList
put line i of gBrowserList into tLine
if item 2 of tLine > 0 then
put true into bFound
exit repeat
end if
end repeat
if bFound is false then
newBrowser
repeat
put item 2 of line 1 of gBrowserList into tID
if tID > 0 then
put true into bFound
exit repeat
else
wait 2 ticks
end if
end repeat
end if
return bFound
end CheckForBrowser
With no break points set the function just hangs. Command-Period stops it at the command 'wait 2 ticks'. If I put a break point at the command 'wait 2 ticks' and execute the function it stops at that point and when I tell it to continue everything works just fine.
Any suggestions on how I might make this work?
Thanks,
Larry
Browser1,5
Browser2,8
Browser3,22
With all browsers closed thee list looks like:
Browser1,0
Browser2,0
Browser3,0
If a browser is open and I do something that needs to access it, it does so without a problem. The issue comes when no browsers are open and I want to access one. Right now I have to go to the File Menu to take 'newBrowser' and then issue the command to do something with it. I would like to make it so that when no browsers are present, a command that requires the use of a browser will open it automatically and use it.
To that end I have written the following function:
function CheckForBrowser
global gBrowserList
put false into bFound
repeat with i=1 to number of lines of gBrowserList
put line i of gBrowserList into tLine
if item 2 of tLine > 0 then
put true into bFound
exit repeat
end if
end repeat
if bFound is false then
newBrowser
repeat
put item 2 of line 1 of gBrowserList into tID
if tID > 0 then
put true into bFound
exit repeat
else
wait 2 ticks
end if
end repeat
end if
return bFound
end CheckForBrowser
With no break points set the function just hangs. Command-Period stops it at the command 'wait 2 ticks'. If I put a break point at the command 'wait 2 ticks' and execute the function it stops at that point and when I tell it to continue everything works just fine.
Any suggestions on how I might make this work?
Thanks,
Larry