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
A Timing Issue
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: A Timing Issue
Look up browserNewInstance and revBrowserInstances
It looks like your script might be getting caught in that last repeat loop if "item 2 of line 1" never changes from 0.. Also, it looks like your function will always return TRUE, so no real reason to have it as a function that returns..
It looks like your script might be getting caught in that last repeat loop if "item 2 of line 1" never changes from 0.. Also, it looks like your function will always return TRUE, so no real reason to have it as a function that returns..
Code: Select all
on mouseUp
if (revBrowserInstances() = EMPTY) then
newBrowser
end if
end mouseUp
on newBrowser
if (revBrowserOpen(the windowID of this stack) = EMPTY) then
# error
end if
end newBrowser
on browserNewInstance pBrowserID
# do what you need to do here as you are guaranteed to have the web browser object
end browserNewInstance
Re: A Timing Issue
Shaosean,
Thank you very much for calling to my attention 'browserNewInstance'.
Best,
Larry
Thank you very much for calling to my attention 'browserNewInstance'.
Best,
Larry
Re: A Timing Issue
No problem..
Fear of spiders is aracnaphobia, fear of tight spaces is claustrophobia, fear of Chuck Norris is called Logic
Fear of spiders is aracnaphobia, fear of tight spaces is claustrophobia, fear of Chuck Norris is called Logic