BBC BASIC for Windows
« Obvious bug or I'm idiot »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 11:51pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Obvious bug or I'm idiot  (Read 396 times)
Endymion
New Member
Image


member is offline

Avatar

Write spaghetti-code for food!


PM

Gender: Male
Posts: 7
question Obvious bug or I'm idiot
« Thread started on: May 23rd, 2012, 05:56am »

Code:
      print fn_Func1(0)
      end
      
      def fn_Func1(Number%)
      print "Init"
      local Answer% = Number%
      print "Calc"
      = Answer% 


Why I don't see "Calc"?
User IP Logged

I wanted to do something. I wanted to do something as badly as a genie who's been let out of his bottle for the first time in a thousand years. Anything at all: Raise up castles, lay waste cities, program in Basic, or embroider in cross-stitch. -- Nochnoy Dozor (The Night Watch) By Sergei Lukyanenko
admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
question Re: Obvious bug or I'm idiot
« Reply #1 on: May 23rd, 2012, 08:29am »

on May 23rd, 2012, 05:56am, Endymion wrote:
Code:
      print fn_Func1(0)
      end
      
      def fn_Func1(Number%)
      print "Init"
      local Answer% = Number%
      print "Calc"
      = Answer% 


Why I don't see "Calc"?

Because you're trying to initialise a variable in the LOCAL statement. I agree that it would be nice if you could, but BBC BASIC has never had that facility: you have to separate it into two statements as follows:

Code:
      PRINT FN_Func1(0)
      END
      
      DEF FN_Func1(Number%)
      PRINT "Init"
      LOCAL Answer%
      Answer% = Number%
      PRINT "Calc"
      = Answer% 

Now you know why it didn't work, it would be a useful exercise for you to work out why it didn't produce an error message (hint: a statement starting with an equals sign = is valid, and BBC BASIC doesn't always need a colon separating statements)!

Richard.
User IP Logged

Endymion
New Member
Image


member is offline

Avatar

Write spaghetti-code for food!


PM

Gender: Male
Posts: 7
question Re: Obvious bug or I'm idiot
« Reply #2 on: May 23rd, 2012, 10:43am »

In other words, BBC BASIC understand my code like this:

Code:
      print fn_Func1(0)
      end
      
      def fn_Func1(Number%)
      print "Init"
      local Answer%
      = Number%
 


Very funny. There is even a peculiar charm in such unexpected unobviousnesses, which has an own logic.
User IP Logged

I wanted to do something. I wanted to do something as badly as a genie who's been let out of his bottle for the first time in a thousand years. Anything at all: Raise up castles, lay waste cities, program in Basic, or embroider in cross-stitch. -- Nochnoy Dozor (The Night Watch) By Sergei Lukyanenko
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls