BBC BASIC
« Re: Endless Button Possibilities!! TRY THIS !! »

Welcome Guest. Please Login or Register.
Jan 20th, 2018, 6:12pm


Cross-platform BBC BASIC (Win32, Linux x86, Android, Mac OS-X, Raspberry Pi)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Re: Endless Button Possibilities!! TRY THIS !!  (Read 604 times)
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 689
xx Re: Endless Button Possibilities!! TRY THIS !!
« Thread started on: Apr 24th, 2016, 09:59am »

on Apr 24th, 2016, 03:44am, michael wrote:
Now it just needs to be perfected!!

Some comments:
  • It's very 'flickery' on my PC; even when 'idle' it seems to be constantly redrawing.

  • The 'constant redrawing' is using up about 30% of CPU time (according to the Profiler) which is quite wasteful of battery on a laptop such as mine.

  • The Cross Reference utility reports the program as being compatible with 'lowercase keywords', so why is there the comment "MAKE SURE TO DISABLE Lower Case Keywords"?

  • The Cross Reference utility is reporting several warnings, including as many as 16 'Shared variables which are not globals' in PROC_monitorbuttons!
Richard.
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 689
xx Re: Endless Button Possibilities!! TRY THIS !!
« Reply #1 on: Apr 24th, 2016, 4:29pm »

on Apr 24th, 2016, 2:30pm, michael wrote:
Ill also get some LOCALS set up

Thank you. I trust you understand why LOCALs (and PRIVATEs) are so important, I wouldn't want you to think they are needed simply to eliminate warnings from the Cross Reference utility! grin

It's possible that you have been influenced by other dialects of BASIC (e.g. Liberty BASIC) in which variables are automatically local unless explicitly declared as GLOBAL. BBC BASIC works more like languages such as JavaScript and LUA in requiring locals to be explicitly declared (although of course the formal parameters of functions and procedures are automatically local).

The Wikipedia article on Information Hiding explains the importance of limiting the scope of variables.

Richard.
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 689
xx Re: Endless Button Possibilities!! TRY THIS !!
« Reply #2 on: Apr 25th, 2016, 09:12am »

on Apr 25th, 2016, 04:30am, michael wrote:
This one should be as good as it gets.

That's what they call a hostage to fortune! There are still a few shortcomings (some of which you have identified yourself):
  • The main button array BTTNLIST$(0) is passed into PROC_monitorbuttons as a global rather than as a parameter. Consider the implications of this from the point of view of reusable code: anybody wanting to make use of your routine would be forced to use that specific name for their array whether they wanted to or not!

  • You pass the result from PROC_monitorbuttons back to the caller in a global variable 'response1$'. That is bad practice. You should instead change the procedure to a function (FN_monitorbuttons) and then you can return the result directly without the use of any globals.

  • The array 'array$()' is unnecessarily global. As you have found you cannot make it LOCAL because of the way it is created, but you can (and should) make it PRIVATE.
Richard.
« Last Edit: Apr 25th, 2016, 09:13am by Richard Russell » User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Donate $6.99 for 50,000 Ad-Free Pageviews!


This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls