Execute a php script

Execute a php script

Postby Marco Turco » Tue Jun 25, 2013 1: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
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: Execute a php script

Postby Antonio Linares » Tue Jun 25, 2013 2: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41365
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Execute a php script

Postby Rick Lipkin » Tue Jun 25, 2013 2: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
Last edited by Rick Lipkin on Tue Jun 25, 2013 2:49 pm, edited 2 times in total.
User avatar
Rick Lipkin
 
Posts: 2633
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Execute a php script

Postby Antonio Linares » Tue Jun 25, 2013 2:47 pm

Rick,

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41365
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Execute a php script

Postby Rick Lipkin » Tue Jun 25, 2013 2: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
User avatar
Rick Lipkin
 
Posts: 2633
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Execute a php script

Postby Marco Turco » Tue Jun 25, 2013 3: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
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: Execute a php script

Postby Antonio Linares » Tue Jun 25, 2013 5: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41365
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Execute a php script

Postby Rick Lipkin » Tue Jun 25, 2013 5: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
User avatar
Rick Lipkin
 
Posts: 2633
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Execute a php script

Postby Marco Turco » Thu Jun 27, 2013 8: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
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 31 guests