Newbie help - BB4W vs BBC-SDL

Discussions about the BBC BASIC language, with particular reference to BB4W and BBCSDL
JohnnyRockets
Posts: 7
Joined: Fri 28 Jun 2019, 23:41
Location: Michigan, USA

Newbie help - BB4W vs BBC-SDL

Post by JohnnyRockets »

Hi all,

A quick question.

I cannot seem to get any results with the debug commands in SDLIDE 1.37a.

When I run the same code in BB4W I have good results.

The code is just a simple test.

print "jumboshrimp"
print 2 + 3
prin


SDLIDE just says "mistake"

BB4W executes the first 2 lines and then says "mistake" - I find this a bit more helpful.

What am I doing wrong I wonder?

Thx!


Johnny
Hated Moron

Re: Newbie help - BB4W vs BBC-SDL

Post by Hated Moron »

JohnnyRockets wrote: Fri 10 Nov 2023, 21:08 I cannot seem to get any results with the debug commands in SDLIDE 1.37a.
When I run the same code in BB4W I have good results.
What platform? If it's Windows, both BB4W and BBCSDL use (effectively) the identical BASIC interpreter, so code that runs in one but errors in the other really shouldn't be possible.

Therefore I suspect 'finger trouble', for example if you really are entering keywords in lowercase (don't do that!) perhaps one is in *lowercase on mode and the other is in *lowercase off mode.

Below is a screenshot of your code (corrected to use keywords in capitals) running in BBCSDL:

mistake.png
You do not have the required permissions to view the files attached to this post.
JohnnyRockets
Posts: 7
Joined: Fri 28 Jun 2019, 23:41
Location: Michigan, USA

Re: Newbie help - BB4W vs BBC-SDL

Post by JohnnyRockets »

Hi!

Hey, thanks for your help!

I know what my issue was.

I had no line numbers, so all it said was "mistake" with no indication of where, and I thought, "man that is not too helpful!", but it makes sense that the interpreter did not know how to reference the the mistake line.

No it all makes sense, thanks, sometimes just seeing someone else do the same thing, shows your own mistake.


Johnny


Sidenote: Your version is 1.38, but mine is only 1.37, is that because you're the developer?
Hated Moron

Re: Newbie help - BB4W vs BBC-SDL

Post by Hated Moron »

JohnnyRockets wrote: Sat 11 Nov 2023, 18:02 I had no line numbers, so all it said was "mistake" with no indication of where
If you're debugging (Run.. Debug Program, or the Beetle button in the toolbar) the line which caused the error is highlighted in reverse video, so you don't normally need line numbers. I do occasionally add them, but only temporarily for debugging purposes; I dislike line numbers in 'finished' programs, this isn't the 1980s!
Sidenote: Your version is 1.38, but mine is only 1.37, is that because you're the developer?
Well, yes, but it's more because I keep procrastinating and putting off releasing 1.38! I really will make an effort to do that in the next few days.
JohnnyRockets
Posts: 7
Joined: Fri 28 Jun 2019, 23:41
Location: Michigan, USA

Re: Newbie help - BB4W vs BBC-SDL

Post by JohnnyRockets »

Thank you again, this if very helpful!

If I could ask another question, is it best to type in all caps, or turn on lowercase letters and then type that way? (I'm on Windows FWIW)

I believe the interpreter does not like lower case letters generally, correct?

Thank you,


John
Hated Moron

Re: Newbie help - BB4W vs BBC-SDL

Post by Hated Moron »

JohnnyRockets wrote: Sat 11 Nov 2023, 20:29 is it best to type in all caps, or turn on lowercase letters and then type that way? (I'm on Windows FWIW)
Traditionally, BBC BASIC requires keywords to be entered in capitals. That includes the original Acorn versions (going back to 1981), Brandy and its derivatives (e.g. Matrix Brandy), and most other versions. With those, you have no choice.

I added the option to enable Lowercase Keywords in BBC BASIC for Windows and BBC BASIC for SDL 2.0, primarily for those moving from a dialect of BASIC which allows them (several do, for example Liberty BASIC). Some users find capital keywords 'ugly' or 'old fashioned'.

But enabling that option is not without issues. For example you may find that programs that you copy-and-paste from other places (for example here or the supplied demos) don't run, because they happen to contain a lowercase variable name which is recognised as a keyword.

And of course there's the issue that a lot of variable names become unusable, because with Lowercase Keywords enabled they start with a keyword e.g. printer (PRINT er), total (TO tal) etc., remembering that you can often omit spaces in BBC BASIC.

So it's up to you to weigh up the pros and cons. Incidentally the supplied 'Cross Reference' utility warns you if you've used a variable name which would be illegal in Lowercase Keywords mode.
User avatar
JeremyNicoll
Posts: 73
Joined: Sun 26 Jul 2020, 22:22
Location: Edinburgh

Re: Newbie help - BB4W vs BBC-SDL

Post by JeremyNicoll »

JohnnyRockets wrote: Sat 11 Nov 2023, 20:29 Thank you again, this if very helpful!

If I could ask another question, is it best to type in all caps, or turn on lowercase letters and then type that way? (I'm on Windows FWIW)a
It's only the reserved words of the language that this matters for.

If you turn on CAPS LOCK then you lose easy access to mixed case for
variable names and comments.

Comments, in particular, are much easier to read in mixed case.


Even when I've had to write code in languages where everything in the
code had to be in upper case, I used to put comments in mixed case to
make them stand out.
Hated Moron

Re: Newbie help - BB4W vs BBC-SDL

Post by Hated Moron »

JeremyNicoll wrote: Sat 11 Nov 2023, 21:55 If you turn on CAPS LOCK then you lose easy access to mixed case for variable names and comments.
Nobody is suggesting using capitals for everything, we've moved on from the days of the Teletype (or the ZX80)! The Help Documentation has this to say about Naming Conventions:
  • You are recommended to adopt the following conventions when naming variables:

    Local variables (e.g. variables with only a limited scope, formal parameters of functions and procedures, and variables declared in a LOCAL or PRIVATE statement) should be entirely in lower case (except for the static integer variables). For example
    number%, text$.

    Global variables (i.e. those declared and used throughout your main program, and possibly accessed in functions or procedures) should use a mixture of lower case and capital letters. For example
    Click%, Title$.

    Constants (i.e. variables set to a constant value during initialisation and never changed again) should be in all capitals. For example
    MAXFILES, VERSION$.

    Following these recommendations will make your programs easier to understand and avoid problems such as an interrupt routine erroneously accessing a local variable instead of a global variable.
The Cross Reference utility assumes that these recommendations are followed.
JohnnyRockets
Posts: 7
Joined: Fri 28 Jun 2019, 23:41
Location: Michigan, USA

Re: Newbie help - BB4W vs BBC-SDL

Post by JohnnyRockets »

Thanks a ton guys! I'm obviously crazy new to BBC Basic, LOL!

I'm sure I'll have lots more very basic BBC questions, thanks for bearing with me!

I am really enjoying this language though. 😃

Johnny
Hated Moron

Re: Newbie help - BB4W vs BBC-SDL

Post by Hated Moron »

JeremyNicoll wrote: Sat 11 Nov 2023, 21:55 It's only the reserved words of the language that this matters for.
For completeness, whilst that is true of the Lowercase Keywords selection in the Options menu, the *LOWERCASE command is more far-reaching. That affects keywords, the 'e' in scientific notation numbers and hexadecimal constants.

So this code runs:

Code: Select all

      *lowercase on
      PRINT EVAL("pi")
      PRINT 123e4
      PRINT &abcd
and produces the result:

Code: Select all

3.14159265
   1230000
     43981