FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Execute a php script
Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
Execute a php script
Posted: Tue Jun 25, 2013 01:47 PM

Hi all,
I should execute a php script via IE every 1 minute.
I made the following routine and it seems runs well but I'm in doubt if calling oIE:Navigate several time I could have a memory leak.
What do you think about ?

function main()

cVar:="http://www.scritps/scripts.php"

oIE:=CreateObject("InternetExplorer.Application")
oIE:Visible := .f.

do while .t.
oIE:Navigate(cVar)
while oIE:Busy()
    SecondsSleep( 1 )
enddo
n:=seconds()
do while .t.
sysrefresh()
if seconds()>n+60
    exit
endif
enddo
Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Execute a php script
Posted: Tue Jun 25, 2013 02:40 PM

Marco,

The source code looks fine, so there should not be any leaks.

Is it behaving fine ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Execute a php script
Posted: Tue Jun 25, 2013 02:43 PM

Marco

Looking at your code .. I would say YES .. (if) you will be opening another instance of IE each time you initialize oIE:=CreateObject("InternetExplorer.Application").

I do not see how you are re-calling your program after it exits .. but I would insert oIE:Quit() in the appropriate place to keep from Opening another instance of IE .. navigating thru the current instance of IE will not necessarily consume memory .. opening new instances of IE without closing the current version will eventually cause problems.

You can quickly check to see how many instances of IE are open by looking at the task manager.

Rick Lipkin

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Execute a php script
Posted: Tue Jun 25, 2013 02:47 PM

Rick,

He only creates it once and then remains in a loop in his code.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Execute a php script
Posted: Tue Jun 25, 2013 02:55 PM

Antonio

I understand .. I just did not see how Marco was evaluating his instance of IE every 60 seconds ..

It appears that a new tab may be created each time the loop 'navigates' to the same URL .. to check, I would make IE visible to verify that.

Rick Lipkin

Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
Re: Execute a php script
Posted: Tue Jun 25, 2013 03:01 PM

Hi Rick,
I forgot to past in the sample the "enddo" at the end of the code to restart the process.

Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Execute a php script
Posted: Tue Jun 25, 2013 05:04 PM

Rick,

good point. I would say it does not open a new tab, but I have not tested it.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Execute a php script
Posted: Tue Jun 25, 2013 05:06 PM

Marco

No Problem .. I have done a lot with IE automation on a program about a year ago and like Antonio suggests .. it seems fine to me as well. I am still curious if the code as it loops around to navigate to the same URL creates a new tab each time ?

If you do not mind setting IE to visible and watch the browser to see if it spins off a new tab each time it navigates to the same URL .. if it does not .. I see nothing wrong with your code ..

Still curious what your browser is looking for and how you evaluate your results ?

Thanks
Rick Lipkin

Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
Re: Execute a php script
Posted: Thu Jun 27, 2013 08:10 AM

Thanks all to share opinions. It seems to runs well and the loop runs inside a single IE tab.

Best Regards,



Marco Turco

SOFTWARE XP LLP

Continue the discussion