Source language: Translate to:

:[Variable]_OnChange

Post your suggestions for future versions of NeoBook

Moderator: Neosoft Support

:[Variable]_OnChange

Postby smokinbanger » Fri Apr 26, 2013 12:17 pm

We have some really nice features like
Code: Select all
:CommandLine_OnChange
:ObjectName_OnOpen/OnClose
etc.
I think it would be awesome to expand these "OnChange" Subroutines to include a
Code: Select all
:[Variable]_OnChange
where [Variable] could be any Neobook (User created or global) variable. The sub would be executed any time the variables changes with the exception of being cleared (SetVar "[Variable]" "").
This would prove VERY useful for things like error logging.
Example:
Syntax: [ Download ] [ Hide ]
Using Neobook Syntax Highlighting
:[LastError]_OnChange
     FileWrite "[PubDir]ErrorLog.txt" "Append" "[DateShort] [Time] [LastError]"
Return

:[DbpError]_OnChange
     FileWrite "[PubDir]ErrorLog.txt" "Append" "[DateShort] [Time] [LastError]"
Return
Parsed in 0.006 seconds, using GeSHi 1.0.8.10

I'm not sure how easy it would be to implement this (or if it's even possible), but it would sure be COOL! 8)
Just Sayin'...
smokinbanger
 
Posts: 198
Joined: Mon Jan 16, 2012 9:53 am
Location: United States

Re: :[Variable]_OnChange

Postby CN_Iceman » Sat Apr 27, 2013 4:44 am

Good idea!!
Greetings/Saludos, Jose.
www.icemansoft.es
User avatar
CN_Iceman
 
Posts: 297
Joined: Tue Mar 01, 2011 11:04 am
Location: España

Re: :[Variable]_OnChange

Postby dec » Sat Apr 27, 2013 5:28 am

Hello,

Maybe I'am wrong, but, I think this it's not a good idea, at the least in terms of efficiency. Check for a variable change have a cost, and check for every variable changes... and call the appropiate subroutines (after test if really exists)... probably take down the publication performance. NeoBook provide mechanism like the "Timer" object that can be used, for example, to check certain variable changes. Then, you can also call the appropiate subroutine or just do whatever you wanted. With a reasonable Timer interval and just the needed variables checks probably the publication continue running without performance losses.
.
Enhance your NeoBook applications!
.
57 plugins, 1113 actions and 230 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Re: :[Variable]_OnChange

Postby mishem » Sat Apr 27, 2013 6:41 am

In this topic I was trying to explain how you can monitor variables.
Here you can download a sample

In general, a good idea. But it would be better to add events for objects.
The mouse button is pressed, the button is held down, the scroll wheel mouse and monitor. Then monitor objects and variables disappear.
mishem
 
Posts: 574
Joined: Mon Oct 08, 2012 1:51 pm

Re: :[Variable]_OnChange

Postby Gaev » Sat Apr 27, 2013 7:56 am

Interesting discussion ... I faintly recall making a similar suggestion years ago.

If the main purpose of requesting such a feature is to be able to custom handle errors ..

a) the use of the Timer object might not work ... as NeoBook can handle many script commands between Timer Intervals.

b) might be a better suggestion to ask for an onError subroutine facility

In any case, the tricky part would be the handling of 'subsequent errors' ... i.e. errors encountered within the onError subroutine ... abort further processing of the subroutine ? ... abort all processing of the Application ? ... otherwise, could get into an endless loop.

Also, what is to be done after the onError routine is successfully serviced ? ... return to script command following the erroneous command ? ... skip the rest of the script section ?


If the request was more global (i.e. specify routine for change to ANY SPECIFIED NeoBook variable) ... what happens when the variable in question is updated inside the associated subroutine ? ... or SPECIFIED variable B is updated within the onChange subroutine of variable A ?
User avatar
Gaev
 
Posts: 3718
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: :[Variable]_OnChange

Postby smokinbanger » Sat Apr 27, 2013 8:46 am

Gaev wrote:b) might be a better suggestion to ask for an onError subroutine facility
Good idea, too.

Gaev wrote:In any case, the tricky part would be the handling of 'subsequent errors' ... i.e. errors encountered within the onError subroutine ... abort further processing of the subroutine ? ... abort all processing of the Application ? ... otherwise, could get into an endless loop.
I didn't think of that one but yes, there could be a potential endless loop.

Gaev wrote:Also, what is to be done after the onError routine is successfully serviced ? ... return to script command following the erroneous command ? ... skip the rest of the script section ?
Most likely Return but every situation is different...


Gaev wrote:If the request was more global (i.e. specify routine for change to ANY SPECIFIED NeoBook variable) ... what happens when the variable in question is updated inside the associated subroutine ? ... or SPECIFIED variable B is updated within the onChange subroutine of variable A ?
We would have to be carefull not not create "conflicting" :[Variable]_OnChange subs; If we had
Code: Select all
 :[VarA]_OnChange
SetVar "[VarB]" "123etc"
Return
and
Code: Select all
:[VarB]_OnChange
SetVar "[VarA]" "etc123"
Return
it could alse create an endless loop :twisted:
Just Sayin'...
smokinbanger
 
Posts: 198
Joined: Mon Jan 16, 2012 9:53 am
Location: United States

Re: :[Variable]_OnChange

Postby Neosoft Support » Mon Apr 29, 2013 11:50 am

It's an interesting idea, but it could impact performance quite a bit as variables change constantly. What might work would be to add individual variables to a watch list and trigger a subroutine only when one of those variables changes.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5593
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Re: :[Variable]_OnChange

Postby Gaev » Mon Apr 29, 2013 12:40 pm

What might work would be to add individual variables to a watch list and trigger a subroutine only when one of those variables changes
That would be a big improvement to NeoBook ... but Developers need to be careful about the same variable being part of other Objects ... could trigger more than one event ... which one comes first ? ... and what happens if the first event code changes the variable again ?
User avatar
Gaev
 
Posts: 3718
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada


Return to NeoBook Suggestions

Who is online

Users browsing this forum: No registered users and 0 guests

cron