BBC BASIC
« Search Results »

Welcome Guest. Please Login or Register.
Jul 26th, 2017, 02:35am


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

Search Results

Total results: 10


 1   General Board / Re: Happy 15th Birthday BB4W!  on: Jul 23rd, 2017, 5:24pm
Started by Richard Russell | Post by Geum
Hi there Richard,
So glad to see you are still trundling along! I did join your 'company' way back (2005?) to keep my hand in and to solve Sudoku puzzles when they first came to my attention, but other matters intervened.
I still have a note of my Serial No: 116-2183-659 if that makes sense, as I intended to pass on some ecological software I wrote when teaching (1985 - 90 or so), but I suppose there may not be much interest in that aspect now. However, am delighted to see you've expanded into other OS - I'm not really sure I see the point of all these other languages when BBC is so versatile!
I still have some BBC bits and pieces, and ever wishful, hope to exercise the old brain again - sometime!
With my best wishes for BBC4W,
Jim K
(aka Geum)
 
  Reply Quote Notify of replies

 2   BBC BASIC Language / Re: Care with compound assignment  on: Jul 19th, 2017, 4:59pm
Started by Richard Russell | Post by Richard Russell
on Jul 19th, 2017, 11:57am, Richard Russell wrote:
BBC BASIC behaves exactly as you would expect it to, given left-to-right evaluation

If anybody is unsure about that, here is a breakdown of exactly what happens internally in each case:

Code:
      *float 80

      REM (1) x = x + FNf
      x = 0
      address_of_x = ^x : REM Left hand side of assignment
      value_of_x = x
      x = x + 10        : REM Side-effect of FNf
      value_of_FNf = 1
      |address_of_x = value_of_x + value_of_FNf
      PRINT x

      REM (2) x += FNf
      x = 0
      address_of_x = ^x : REM Left hand side of assignment
      x = x + 10        : REM Side-effect of FNf
      value_of_FNf = 1
      |address_of_x = |address_of_x + value_of_FNf
      PRINT x 

Richard.

 
  Reply Quote Notify of replies

 3   BBC BASIC Language / Re: Care with compound assignment  on: Jul 19th, 2017, 11:57am
Started by Richard Russell | Post by Richard Russell
on Jul 19th, 2017, 08:20am, DDRM wrote:
If I understand Raymond Chen's blog correctly (quite likely not the case!) that suggests that BBC BASIC in it's various forms has right to left evaluation of these compound functions

Erm, BBC BASIC is an interpreted language; 'right to left' evaluation would be difficult and messy to achieve! No, BBC BASIC evaluates left-to-right as do the vast majority of programming languages. Indeed wasn't Raymond's point that people expect that, even if only subconsciously, so whilst it might seem superficially 'wrong' changing it would cause far more confusion than it would solve.

BBC BASIC behaves exactly as you would expect it to, given left-to-right evaluation and a na´ve understanding of how an interpreter works (because that's exactly how it does work!). The reason for my post wasn't to suggest that anything 'surprising' happens - it doesn't - but that the simplistic description of 'a += b' as being equivalent to 'a = a + b' isn't always correct.

Richard.

 
  Reply Quote Notify of replies

 4   BBC BASIC Language / Re: Care with compound assignment  on: Jul 19th, 2017, 11:40am
Started by Richard Russell | Post by Richard Russell
on Jul 19th, 2017, 08:40am, michael wrote:
this should fix the issue.

There's nothing to "fix" since BB4W and BBCSDL are working entirely correctly! I deliberately stated that Acorn's BASIC V worked the same way, as confirmation of that.

Quote:
Even with the issue, this is a fascinating way of using a FN if a person were to use global variables.

Of course one should ideally not modify global variables in a function, so the issue wouldn't arise if good practice was adhered to.

Richard.

 
  Reply Quote Notify of replies

 5   BBC BASIC Language / Re: Care with compound assignment  on: Jul 19th, 2017, 08:40am
Started by Richard Russell | Post by michael
this should fix the issue.
Code:
      x = 0
      x = x + FNf
      PRINT x
      END

      DEF FNf
      x += 10
      = 1+x
 

prints 11

OR to make it a bit more compact:

Code:
     
      x = 0
      x = FNf
      x = FNf
      PRINT x
      END

      DEF FNf
      x += 10
      = 1+x
 


Even with the issue, this is a fascinating way of using a FN if a person were to use global variables.
prints 22

Do I win?
 
  Reply Quote Notify of replies

 6   BBC BASIC Language / Re: Care with compound assignment  on: Jul 19th, 2017, 08:20am
Started by Richard Russell | Post by DDRM
Hi Richard,

Hmm, interesting! And this:
Code:
    x = 0
      x = FNf+x
      PRINT x
      END

      DEF FNf
      x += 10
      = 1
 
returns 11 again.

So in your second case, the x (which is still 0) is analysed before FNf changes it to 10, and then the result of FNf (i.e. 1) is added, and the sum (1) is assigned to x. In my version, the value of x has already been changed to 10 in the function before it is added.

So in the compound form the addition occurs last, and uses the value of x that is true at that time, rather than at the beginning of the statement?

If I understand Raymond Chen's blog correctly (quite likely not the case!) that suggests that BBC BASIC in it's various forms has right to left evaluation of these compound functions, unlike the C# he is talking about? Whether that's a good or a bad thing appears to be a moot point, but it's useful to be aware of it!

Is another take-home message that you should use local variables inside functions or be very careful about what you are doing? :-)

Best wishes,

D
 
  Reply Quote Notify of replies

 7   BBC BASIC Language / Care with compound assignment  on: Jul 18th, 2017, 9:24pm
Started by Richard Russell | Post by Richard Russell
BBC BASIC supports compound assignment operators such as +=. It is usual to explain these by asserting that these operations are equivalent:

Code:
      a += b 

and

Code:
      a = a + b 

and they usually are, but there are exceptions. Consider the following program:

Code:
      x = 0
      x += FNf
      PRINT x
      END

      DEF FNf
      x += 10
      = 1 

When run it prints 11. Now convert it as follows:

Code:
      x = 0
      x = x + FNf
      PRINT x
      END

      DEF FNf
      x += 10
      = 1 

Now it prints 1. So in this case the compound assignment isn't equivalent to the expanded version! You should be able to work out why.

I have confirmed that these same results are obtained in Acorn's BASIC V, BBC BASIC for Windows and BBC BASIC for SDL 2.0.

My thanks are due to Raymond Chen who raised this issue in his Microsoft blog.

Richard.

 
  Reply Quote Notify of replies

 8   Announcements / BBC BASIC for Windows version 6.11a released  on: Jul 16th, 2017, 11:44am
Started by Richard Russell | Post by Richard Russell
I'm pleased to announce the release of BBC BASIC for Windows version 6.11a. This is a maintenance release to address a couple of minor issues that have arisen since the release of v6.10a, as follows:
  1. A bug affecting the *HARDCOPY command, which very regrettably was introduced in v6.10a, has been fixed.

  2. The *DISPLAY and *MDISPLAY commands now accept 'top down' BMP files, despite their validity being somewhat doubtful. A recent thread here discussed this issue.

  3. As a bonus side-effect of (2), the *DISPLAY and *MDISPLAY commands can now flip the image horizontally and/or vertically by specifying a negative width and/or height (but not if the 'transparent colour' option is used).
To upgrade your copy of BBC BASIC for Windows to version 6.11a download and install UPGRADE.EXE from here:

http://www.rtrussell.co.uk/bbcwin/download.html

You may receive security warnings from Windows. That issue will resolve itself eventually when the files have been downloaded a sufficient number of times for them to have gained a 'reputation' for safety.

Richard.
 
  Reply Quote Notify of replies

 9   Integrated Development Environment / Re: Calling ARM programmers  on: Jul 16th, 2017, 07:45am
Started by Richard Russell | Post by hellomike
I was just wondering.

After all the praise I expressed about BB4W to all and everyone for years and years, I feel offended that apparently, you find me capable of commenting anything negative huh

 
  Reply Quote Notify of replies

 10   Android / Re: Android Touch IDE  on: Jul 16th, 2017, 02:20am
Started by Richard Russell | Post by Richard Russell
on Jul 15th, 2017, 11:15pm, jgharston wrote:
Being a new tablet user, and having never used a touch-screen device ever before and being a committed keyboard jockey, I too was stumped by many operations

You can find some of the answers here. If there are other aspects of the 'Touch IDE' that you think could usefully be added to that page let me know.

Richard.

 
  Reply Quote Notify of replies


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