use the "Timer" action instead of "Delay" ?

Questions and information about creating Internet aware NeoBook applications. Including PHP, HTML, FTP, HTTP, Email, etc.

Moderator: Neosoft Support

Locked
User avatar
fkapnist
Posts: 348
Joined: Mon Nov 17, 2014 4:24 pm
Location: Greece
Contact:

use the "Timer" action instead of "Delay" ?

Post by fkapnist »

If for example I manually load the following urls in Neobook, each will display with no problem:

http://www.salon.com/
http://time.com/
http://www.newsweek.com/

----

But if I load them with a "Delay" action, I often get script errors and Neobook freezes :

BrowserGoTo "WebBrowser1" "http://www.salon.com/"
Delay "30000"
BrowserGoTo "WebBrowser1" "http://time.com/"
Delay "30000"
BrowserGoTo "WebBrowser1" "http://www.newsweek.com/"

----

If I use the "Timer" action instead of "Delay" will I get better results? How would I do that?

:?:
.
User avatar
Gaev
Posts: 3782
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada
Contact:

Re: use the "Timer" action instead of "Delay" ?

Post by Gaev »

fkapnist:

Not sure what you are trying to achieve with the 3 second delay ... but ...

1) the time it takes to service a http request can vary from time to time (depending on Internet traffic at the time)

2) Delay would pause the servicing of script commands (NeoBook does not wait for the BrowserGoTo command to return the requested html document before servicing the next command)

3) Timer tasks are performed in an independant task ... so when they are serviced depends only on ...
- when the Timer object is started
- the Timer Interval


You might try and invoke your "Pause" (Delay/Timer) in the Navigate Complete event section of the Web Browser object e.g. ...

- If the Variable to store current address (URL) is http://www.salon.com/, then do "Pause" ... followed by a request for http://time.com/
- If the Variable to store current address (URL) is http://time.com/, then do the "Pause" ... followed by a request for http://www.newsweek.com/
User avatar
fkapnist
Posts: 348
Joined: Mon Nov 17, 2014 4:24 pm
Location: Greece
Contact:

Re: use the "Timer" action instead of "Delay" ?

Post by fkapnist »

30000 is a half minute, not three seconds.... I don't understand what you mean by "Delay would pause the servicing of script commands." Do you think if I add a "Pause" it will prevent script errors? I often get a message about a script error but I don't know if it is a script from the page I loaded, or if it is a script in my Neobook Functions....

:wink:

.
User avatar
Gaev
Posts: 3782
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada
Contact:

Re: use the "Timer" action instead of "Delay" ?

Post by Gaev »

fkapnist:
30000 is a half minute, not three seconds....
Oops, my bad (eyes) ... please ignore my previous post.

Probably a better option would be to use a Timer object ...

- store URLs in arrayed variable e.g. [myURL1], [myURL2], [myURL3]
- setup a variable for number of URLs e.g. [maxURLCount] = 3
- setup a counter e.g. [thisURLCount] = 1
- start the Timer
- in the Interval code, request to navigate to [myURL[thisURLCount]] ... then increment [thisURLCount]
- depending on your requirement, when [thisURLCount] exceeds [maxURLCount], reset [thisURLCount] to 1 ... or stop the Timer
I don't understand what you mean by "Delay would pause the servicing of script commands."
In the single-threaded environment, NeoBook just waits for the specified period before "servicing the next NeoBook command within your event section.
Do you think if I add a "Pause" it will prevent script errors?
Not sure what you are referring to ... I don't see any such command within NeoBook.
I often get a message about a script error but I don't know if it is a script from the page I loaded, or if it is a script in my Neobook Functions....
a) what is the exact text of the error message ?

b) just (temporarily) load a different page e.g. home page of this forum ... if the error message goes away, it is the script in your loaded page.
User avatar
virger
Posts: 540
Joined: Mon Sep 18, 2006 12:21 pm
Location: Costa Rica, America Central

Re: use the "Timer" action instead of "Delay" ?

Post by virger »

Try this, its a button

Code: Select all

{NeoBook 5 Objects}
NeoBookVer=5,80
ObjectType=3
Name=PushButton1
X=161
Y=28
W=274
H=50
Anchor=0
Text=Next [Next]¶View [view]
Align=2
ImageStyle=0
XPTheme=Yes
ObjAction=if "[Next]" "=" ""¶    setvar "[view]" "www.salon.com"¶    setvar "[Next]" "2"¶    BrowserGoTo "WebBrowser1" "http://www.salon.com/"¶else¶    if "[Next]" "=" "2"¶        setvar "[view]" "time.com"¶        setvar "[Next]" "3"¶        BrowserGoTo "WebBrowser1" "http://time.com/"¶    else¶        setvar "[view]" "www.newsweek.com"¶        setvar "[Next]" ""¶        BrowserGoTo "WebBrowser1" "http://www.newsweek.com/"¶    endif¶endif
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=3
Tkx for ReadMe
COSTA RICA
PURA VIDA
User avatar
fkapnist
Posts: 348
Joined: Mon Nov 17, 2014 4:24 pm
Location: Greece
Contact:

Re: use the "Timer" action instead of "Delay" ?

Post by fkapnist »

virger wrote:Try this, its a button

Code: Select all

{NeoBook 5 Objects}
NeoBookVer=5,80
ObjectType=3
Name=PushButton1
X=161
Y=28
W=274
H=50
Anchor=0
Text=Next [Next]¶View [view]
Align=2
ImageStyle=0
XPTheme=Yes
ObjAction=if "[Next]" "=" ""¶    setvar "[view]" "www.salon.com"¶    setvar "[Next]" "2"¶    BrowserGoTo "WebBrowser1" "http://www.salon.com/"¶else¶    if "[Next]" "=" "2"¶        setvar "[view]" "time.com"¶        setvar "[Next]" "3"¶        BrowserGoTo "WebBrowser1" "http://time.com/"¶    else¶        setvar "[view]" "www.newsweek.com"¶        setvar "[Next]" ""¶        BrowserGoTo "WebBrowser1" "http://www.newsweek.com/"¶    endif¶endif
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=3
Tkx for ReadMe

Thanks for the manual button... but I would like an automated rotate

:)
User avatar
fkapnist
Posts: 348
Joined: Mon Nov 17, 2014 4:24 pm
Location: Greece
Contact:

Re: use the "Timer" action instead of "Delay" ?

Post by fkapnist »

Gaev wrote:fkapnist:
30000 is a half minute, not three seconds....
Oops, my bad (eyes) ... please ignore my previous post.

Probably a better option would be to use a Timer object ...

- store URLs in arrayed variable e.g. [myURL1], [myURL2], [myURL3]
- setup a variable for number of URLs e.g. [maxURLCount] = 3
- setup a counter e.g. [thisURLCount] = 1
- start the Timer
- in the Interval code, request to navigate to [myURL[thisURLCount]] ... then increment [thisURLCount]
- depending on your requirement, when [thisURLCount] exceeds [maxURLCount], reset [thisURLCount] to 1 ... or stop the Timer
I don't understand what you mean by "Delay would pause the servicing of script commands."
In the single-threaded environment, NeoBook just waits for the specified period before "servicing the next NeoBook command within your event section.
Do you think if I add a "Pause" it will prevent script errors?
Not sure what you are referring to ... I don't see any such command within NeoBook.
I often get a message about a script error but I don't know if it is a script from the page I loaded, or if it is a script in my Neobook Functions....
a) what is the exact text of the error message ?

b) just (temporarily) load a different page e.g. home page of this forum ... if the error message goes away, it is the script in your loaded page.
the error message is about a script taking too long.... even if I cancel the script the damage is done and Neobook crashes... the error only comes up if I automate the page loading (using Delay).... if I load the page manually I don't get an error message. That's why I wanty to replace Delay with a Timer action... I will study the tips you gave me:
store URLs in arrayed variable e.g. [myURL1], [myURL2], [myURL3]
- setup a variable for number of URLs e.g. [maxURLCount] = 3
- setup a counter e.g. [thisURLCount] = 1
- start the Timer
- in the Interval code, request to navigate to [myURL[thisURLCount]] ... then increment [thisURLCount]
- depending on your requirement, when [thisURLCount] exceeds [maxURLCount], reset [thisURLCount] to 1 ... or stop the Timer


Thanks,
User avatar
virger
Posts: 540
Joined: Mon Sep 18, 2006 12:21 pm
Location: Costa Rica, America Central

Re: use the "Timer" action instead of "Delay" ?

Post by virger »

Try this.
In "WebBrowser1", Acction "Download Complete" this code:

Code: Select all

if "[Type]" "=" "2"
    ifex "[u]<4 AND [WebBrowser1Status]=Finalizado"
        delay "5000"
        setvar "[WebBrowser1Status]" ""
        Math "[U]+1" "" "[U]"
        BrowserGoTo "WebBrowser1" "http://[Url[U]]/"
    endif
endif
Create 2 Buttons
Button1

Code: Select all

{NeoBook 5 Objects}
NeoBookVer=5,80
ObjectType=3
Name=BtType1
X=338
Y=8
W=224
H=38
Anchor=0
Text=Type 1¶[Url[U]]
Align=2
ImageStyle=0
XPTheme=Yes
ObjAction=setvar "[Type]" "1"¶strparse "www.salon.com;time.com;www.newsweek.com" ";" "[Url]" "[NumUrl]"¶loop "1" "[NumUrl]" "[U]"¶    setvar "[WebBrowser1Status]" ""¶    BrowserGoTo "WebBrowser1" "http://[Url[U]]/"¶    while "[WebBrowser1Status]" "<>" "Finalizado"¶    endwhile¶endloop¶setvar "[Url[u]]" "Finish"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=2
And Button2

Code: Select all

{NeoBook 5 Objects}
NeoBookVer=5,80
ObjectType=3
Name=BtType2
X=336
Y=47
W=224
H=38
Anchor=0
Text=Type 2¶[Url[U]]
Align=2
ImageStyle=0
XPTheme=Yes
ObjAction=setvar "[Type]" "2"¶¶strparse "www.salon.com;time.com;www.newsweek.com" ";" "[Url]" "[NumUrl]"¶SetVar "[U]" "1"¶BrowserGoTo "WebBrowser1" "http://[Url[U]]/"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=1
And test, select do you like/need

Tkx For ReadMe
COSTA RICA
PURA VIDA
User avatar
fkapnist
Posts: 348
Joined: Mon Nov 17, 2014 4:24 pm
Location: Greece
Contact:

Re: use the "Timer" action instead of "Delay" ?

Post by fkapnist »

virger wrote:Try this.
In "WebBrowser1", Acction "Download Complete" this code:

Code: Select all

if "[Type]" "=" "2"
    ifex "[u]<4 AND [WebBrowser1Status]=Finalizado"
        delay "5000"
        setvar "[WebBrowser1Status]" ""
        Math "[U]+1" "" "[U]"
        BrowserGoTo "WebBrowser1" "http://[Url[U]]/"
    endif
endif
Create 2 Buttons
Button1

Code: Select all

{NeoBook 5 Objects}
NeoBookVer=5,80
ObjectType=3
Name=BtType1
X=338
Y=8
W=224
H=38
Anchor=0
Text=Type 1¶[Url[U]]
Align=2
ImageStyle=0
XPTheme=Yes
ObjAction=setvar "[Type]" "1"¶strparse "www.salon.com;time.com;www.newsweek.com" ";" "[Url]" "[NumUrl]"¶loop "1" "[NumUrl]" "[U]"¶    setvar "[WebBrowser1Status]" ""¶    BrowserGoTo "WebBrowser1" "http://[Url[U]]/"¶    while "[WebBrowser1Status]" "<>" "Finalizado"¶    endwhile¶endloop¶setvar "[Url[u]]" "Finish"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=2
And Button2

Code: Select all

{NeoBook 5 Objects}
NeoBookVer=5,80
ObjectType=3
Name=BtType2
X=336
Y=47
W=224
H=38
Anchor=0
Text=Type 2¶[Url[U]]
Align=2
ImageStyle=0
XPTheme=Yes
ObjAction=setvar "[Type]" "2"¶¶strparse "www.salon.com;time.com;www.newsweek.com" ";" "[Url]" "[NumUrl]"¶SetVar "[U]" "1"¶BrowserGoTo "WebBrowser1" "http://[Url[U]]/"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=1
And test, select do you like/need

Tkx For ReadMe
I tried this code. Only the first link opens. Then the application freezes and the second button does nothing.

:?:
User avatar
fkapnist
Posts: 348
Joined: Mon Nov 17, 2014 4:24 pm
Location: Greece
Contact:

Re: use the "Timer" action instead of "Delay" ?

Post by fkapnist »

My main question is if I should use the Delay action or the Timer...

I am currently using this simple action:
Delay "[RotatorDelay]"
(The user selects the duration of the delay)

Below is a (3 link) sample Neobook code I am using for a 36 link slide show type of URL rotator:

[syntax=neobook] FocusObject "WebBrowser1"
GoSub "ScrollHome"
SetVar "[ScrollStatus]" ""
EndIf
Else
GotoLine "EndSurf"
EndIf
If "[SurfState]" "=" "ON"
Delay "[RotatorDelay]"
SetVar "[SlideNum]" "3"
EndIf
:SurfSlot03
SetVar "[SlotFilter]" "[Slot03]"
GoSub "AutoSurfSlotFilter"
If "[GotoNextSlot]" "=" "Yes"
GotoLine "SurfSlot04"
EndIf
If "[SurfState]" "=" "ON"
ShowObject "WebBrowser1" "[ExitEffect]" "[ExitFb]"
BrowserGoTo "WebBrowser1" "[Slot03]"
SetVar "[TextEntry1]" "[Slot03]"
SetVar "[PausePoint]" "Slot03"
Call "ThumbVideo"
GoSub "AutoRefresh"
GoSub "ScrollDown"
Call "SliderPanel"
If "[ScrollStatus]" "=" "BeforeHome"
FocusObject "WebBrowser1"
GoSub "ScrollHome"
SetVar "[ScrollStatus]" ""
EndIf
Else
GotoLine "EndSurf"
EndIf
If "[SurfState]" "=" "ON"
Delay "[RotatorDelay]"
SetVar "[SlideNum]" "4"
EndIf[/syntax]
User avatar
fkapnist
Posts: 348
Joined: Mon Nov 17, 2014 4:24 pm
Location: Greece
Contact:

Re: use the "Timer" action instead of "Delay" ?

Post by fkapnist »

The simple solution:


Long story short, If I run the code below, "time.com" freezes and Neobook crashes. I think Time may have an adware script that prevents url redirect or automatic loading of another page...

Code: Select all

BrowserGoTo "WebBrowser1" "http://www.newyorker.com/"

Delay "30000"
BrowserGoTo "WebBrowser1" "http://time.com/"

Delay "30000"
BrowserGoTo "WebBrowser1" "http://www.villagevoice.com/"

But if I use any of the codes below, the Time script stops long enough to load another page...

Code: Select all

BrowserGoTo "WebBrowser1" "http://www.newyorker.com/"

Delay "30000"
BrowserStop "WebBrowser1"
BrowserGoTo "WebBrowser1" "http://time.com/"

Delay "30000"
BrowserStop "WebBrowser1"
BrowserGoTo "WebBrowser1" "http://www.villagevoice.com/"
------------

Code: Select all

BrowserGoTo "WebBrowser1" "http://www.newyorker.com/"

Delay "30000"
RefreshObject "WebBrowser1"
BrowserGoTo "WebBrowser1" "http://time.com/"

Delay "30000"
RefreshObject "WebBrowser1"
BrowserGoTo "WebBrowser1" "http://www.villagevoice.com/"

:P
.
Locked