Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.acorn.programmer > #252

Re: Toggling an Icon on the bar

From Martin Wuerthner <spamtrap@mw-software.com>
Newsgroups comp.sys.acorn.programmer
Subject Re: Toggling an Icon on the bar
Date 2011-04-29 12:38 +0200
Organization MW Software
Message-ID <faac7bcb51.martin@bach.planiverse.com> (permalink)
References <9330de2a-526b-4d39-b58f-2d389d8f02b9@k25g2000yqf.googlegroups.com> <819574cb51.martin@bach.planiverse.com> <6ca5e37b-b001-4d91-84d0-0ed450d8a76b@n10g2000yqf.googlegroups.com> <e26486bf-495f-48bc-a2f2-dcf4c21b066e@s4g2000yql.googlegroups.com>

Show all headers | View raw


In message <e26486bf-495f-48bc-a2f2-dcf4c21b066e@s4g2000yql.googlegrou 
ps.com>
          Martin Hansen <mhh@shrewsbury.org.uk> wrote:

> [...]

> The error I get when it meets the line $icon%="!MyTask"
> (second time around) is "abort on data transfer" at that line.

> [...]

> I don't know what that's telling me....

That is telling you that the value of icon% was corrupted, most 
probably because you used the same variable name for something else 
somewhere else in the program. Adding "*Report icon%" just before that 
line will tell you in an instant (using Martin Avison's Reporter - 
highly recommended).

For instance, a typical Mouse Event handler reads:

mouse_x% = blk%!0: mouse_y% = blk%!4: buttons% = blk%!8
window% = blk%!12
icon% = blk%!16

The last line corrupts your icon buffer pointer, so any attempt to 
write to the buffer afterwards leads to a data abort. Of course, the 
above handler should start with the line

LOCAL mouse_x%, mouse_y%, buttons%, window%, icon%

which helps avoiding clashes with global variables, but not fully, 
since any routine called from the handler still sees the local copy of 
the variable instead of the global one. So, to write reliable BASIC 
code, you should use some naming conventions, e.g., prefix every 
global variable with "g", so you have "DIM gIcon% ...", which avoids 
any clashes with local variables. This is even more important if you 
use libraries.

-- 
Martin
---------------------------------------------------------------------
Martin Wuerthner         MW Software      http://www.mw-software.com/
        RISC OS Software for Design, Printing and Publishing
---------------------------------------------------------------------

Back to comp.sys.acorn.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Toggling an Icon on the bar Martin Hansen <mhh@shrewsbury.org.uk> - 2011-04-28 19:12 -0700
  Re: Toggling an Icon on the bar James Lampard <dontreplytothis@mailinator.com> - 2011-04-28 20:32 -0700
  Re: Toggling an Icon on the bar Martin Wuerthner <spamtrap@mw-software.com> - 2011-04-29 11:21 +0200
    Re: Toggling an Icon on the bar James Lampard <dontreplytothis@mailinator.com> - 2011-04-29 03:01 -0700
      Re: Toggling an Icon on the bar Martin Hansen <mhh@shrewsbury.org.uk> - 2011-04-29 03:15 -0700
        Re: Toggling an Icon on the bar Martin Wuerthner <spamtrap@mw-software.com> - 2011-04-29 12:38 +0200
          Re: Toggling an Icon on the bar Martin Hansen <mhh@shrewsbury.org.uk> - 2011-04-29 03:56 -0700
        Re: Toggling an Icon on the bar Steve Fryatt <news@stevefryatt.org.uk> - 2011-04-29 11:52 +0100

csiph-web