BBC BASIC
« Re: "mygraphics" Library (required for button too »

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


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: "mygraphics" Library (required for button too  (Read 467 times)
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 689
xx Re: "mygraphics" Library (required for button too
« Thread started on: Nov 7th, 2016, 11:59am »

on Nov 6th, 2016, 8:35pm, michael wrote:
This program will be needed later for the 2 major projects I am working on.

Something not right here:

Code:
      DEFPROCrect(x%,y%,w%,h%)
      LOCAL sx%,sy%
      sx%=x%:sy%=y%
      IF x%>w% THEN x%=w%:w%=sx%
      IF y%>h% THEN y%=h%:h%=sy%
      ry%=y%
      y%=ry% 

Those last two lines are definitely strange!

Also, the variables sx% and sy% appear to be unnecessary. Let's examine this code in isolation:

Code:
      sx%=x%
      IF x%>w% THEN x%=w%:w%=sx% 

First note that sx% is used only in this code snippet. That means we can move it into the conditional clause without affecting the functionality:

Code:
      IF x%>w% THEN sx%=x%:x%=w%:w%=sx% 

But having made that change, we can see that the code is identical in its operation (but slower than) this:

Code:
      IF x%>w% THEN SWAP x%,w% 

Richard.
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