Author |
Topic: Capitalised Key Words (Read 1591 times) |
|
dje4816
New Member
member is offline


Posts: 11
|
 |
Capitalised Key Words
« Thread started on: Oct 25th, 2013, 11:30am » |
|
BBC Basic requires that the user types keywords in using capital letters. This is very tedious, as one is constantly changing from capitals back to lower case and vice versa.
A much better solution is that used in many other Basics. You can enter everything in lower case. The IDE will then capitalise all keywords automatically. This is much more convenient for the user and has a major advantage: Glancing at the listing will immediately show mis-typed keywords because they will remain in lower case.
Dave.
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: Capitalised Key Words
« Reply #1 on: Oct 25th, 2013, 1:28pm » |
|
on Oct 25th, 2013, 11:30am, dje4816 wrote:BBC Basic requires that the user types keywords in using capital letters. |
|
It's optional, under control of the Lowercase Keywords selection in the Options menu. Capital keywords is the default, and I recommend that option be used for compatibility with versions of BBC BASIC on other platforms. Also, if you choose the Lowercase Keywords option you may find that some programs written by other people don't run (because they have used a variable name which clashes with a keyword on your setup but not on theirs). However the choice is yours.
Quote:Glancing at the listing will immediately show mis-typed keywords because they will remain in lower case. |
|
Mis-typed keywords are obvious in either case, because they will not be syntax-coloured (they will be black, rather than orange, by default).
Richard.
|
|
Logged
|
|
|
|
dje4816
New Member
member is offline


Posts: 11
|
 |
Re: Capitalised Key Words
« Reply #2 on: Oct 26th, 2013, 1:39pm » |
|
Richard,
Many thanks! Hadn't spotted that option. It works fine.
Dave.
|
|
Logged
|
|
|
|
dje4816
New Member
member is offline


Posts: 11
|
 |
Re: Capitalised Key Words
« Reply #3 on: Nov 22nd, 2013, 11:34am » |
|
I've been working ok with keyword capitalisation switched off for a while. In options/customise I had "accept keyword abbreviations" switched off.
For no apparent reason keywords are being accepted again. I have ensured the option remains off (box unchecked). This is a real nuisance. It means that I can't use variables like "total" etc, as "to" is a keyword.
Any advice appreciated.
Dave.
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: Capitalised Key Words
« Reply #4 on: Nov 22nd, 2013, 1:26pm » |
|
on Nov 22nd, 2013, 11:34am, dje4816 wrote: It's just the way BBC BASIC has always worked. Most BASICs recognise a keyword only if it is followed by a space (or other punctuation character). The disadvantage of that scheme is that the program cannot be 'crunched' below a certain size because of all those essential spaces.
When BBC BASIC was designed, way back in 1981, every byte of memory was precious. On the Model A BBC Microcomputer, which had a total of 16K RAM, the highest resolution graphics mode left only about 5 Kbytes available for the user's program and data!
Because of this extreme scarcity of memory BBC BASIC's designers decided that the 'every keyword must be followed by a space' rule would be modified to 'only certain keywords need to be followed by a space'. This means that you can often omit spaces and reduce the size of the program by a worthwhile amount. The keywords which do need to be followed by a space (etc.) are shown in bold in this list.
Fast forward to 2013 and of course memory is no longer in short supply. But BBC BASIC still works the same way: most keywords need not be followed by a space and therefore they may not begin a variable name. TO is one of those keywords, and therefore variable names like TOTAL or TOAST are not allowed. By default keywords must be in capitals so this restriction is not very important (it means that a few Windows constants, which are also capitals, must be prefixed by an underscore).
But if you have enabled the Lowercase Keywords option it is much more of an issue, because a large number of variable names that you might like to use are forbidden. That's one of the main reasons why I don't recommend the use of that option. It's also why the Cross Reference utility draws attention to 'Variable names incompatible with lowercase keywords'. A workaround is to use 'title case', i.e. an initial capital letter like Total or Toast (although that may break the naming conventions).
This is one of the disadvantages (if you call it that) of BBC BASIC being such an old language. It has several features which don't make a lot of sense today, but we're stuck with.
Richard.
|
|
Logged
|
|
|
|
dje4816
New Member
member is offline


Posts: 11
|
 |
Re: Capitalised Key Words
« Reply #5 on: Nov 23rd, 2013, 07:53am » |
|
OK, Richard, I understand even if it's something of a minor nuisance. I'm a refugee from the now no-longer-supported IBasic, which was excellent, and also from Liberty Basic. I guess each of these dialects have pros and cons, but right now I'm getting a lot out of BB4W.
Regards,
Dave.
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: Capitalised Key Words
« Reply #6 on: Nov 23rd, 2013, 4:05pm » |
|
on Nov 23rd, 2013, 07:53am, dje4816 wrote:I'm a refugee from the now no-longer-supported IBasic, which was excellent, and also from Liberty Basic. |
|
I don't want to discourage you from using BBC BASIC, but (as you probably already know) LB Booster (LBB) will actually let you embed BBC BASIC statements - with care - in a Liberty BASIC program! Here's a hybrid LB/BBC program which runs OK:
Code: mainwin 80 24
locate 20, 10
!COLOR 1 : REM Embedded BBC BASIC statement
print "Is this Liberty BASIC or BBC BASIC?" Richard.
|
|
Logged
|
|
|
|
KenDown
Full Member
member is offline


Posts: 181
|
 |
Re: Capitalised Key Words
« Reply #7 on: Jul 19th, 2015, 3:33pm » |
|
The easiest solution is to press Shift and CapsLock together. This will give you capital letters in ordinary typing, but if you hold down Shift it gives you lower case. I find this the most convenient way of programming. (If you don't get what I describe above, try pressing the two keys simultaneously again. Sometimes they don't "take".)
|
|
Logged
|
|
|
|
rtr2
Guest
|
 |
Re: Capitalised Key Words
« Reply #8 on: Jul 19th, 2015, 5:07pm » |
|
on Jul 19th, 2015, 3:33pm, KenDown wrote:If you don't get what I describe above, try pressing the two keys simultaneously again. Sometimes they don't "take". |
|
On my PC (Windows 8.1) the behaviour you describe is what happens when I press Caps Lock on its own. That is, in normal Caps Lock mode holding down Shift reverts to lowercase. I'm not sure whether Shift+CapsLock is supposed to do something different, but it doesn't seem to here.
Richard.
|
|
Logged
|
|
|
|
KenDown
Full Member
member is offline


Posts: 181
|
 |
Re: Capitalised Key Words
« Reply #9 on: Jul 19th, 2015, 9:27pm » |
|
Interesting. I never tried that.
Incidentally, some may wonder why I hold down shift when writing lower case. Would it not be as simple to hold down shift for writing upper case?
The answer is that variables often end with % (for integer variables) or $ (for string variables). As variables should be in lower case, doing it my way means that you can type x% without having to change your hold on the shift key. Thus i%?memlocation% can be typed all in one go while holding down shift from beginning to end.
|
|
Logged
|
|
|
|
|