BBC BASIC for Windows
« Variable Program Lesson: (John-hnckleyj) »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 10:13pm



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: Variable Program Lesson: (John-hnckleyj)  (Read 924 times)
Zaphod
Guest
xx Re: Variable Program Lesson: (John-hnckleyj)
« Reply #4 on: Apr 9th, 2016, 2:52pm »

I think it would be helpful if people took notice of this.

http://www.bbcbasic.co.uk/bbcwin/manual/bbcwin2.html#conventions

Of course, your programs will work for you without adhering to this formality. However, it might help others to understand the code without too much work. More importantly it would allow the Cross Reference Utility to be useful to you.

In Richard's absence I would like to ask that people posting programs run the Cross Reference Utility on them before posting and look for the warnings and details it produces. It will pick up or highlight many potential errors, typos, unused variables and so on. It would show the potential for names that maybe won't work with LOWERCASE keywords set. It is a very valuable tool that will often show up the problem you are having. And if the program passes the 'test' without warnings you have probably got a program that will make sense to others.
It does not check for logic errors, of course, but it often picks up the 'silly' mistakes that we all make.
It will tell you when variables are global, local or shared so you can think about the scope of the variables.

If anyone has a reference about how to use the 'scope' of variables in BB4W that would be useful to append or post. Or does anyone want me to write something?
User IP Logged

DDRM
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 321
xx Re: Variable Program Lesson: (John-hnckleyj)
« Reply #5 on: Apr 9th, 2016, 5:16pm »

Can I reinforce Zaphod's comment? While everyone is welcome to program in their own style, it makes help more helpful if it has a standard format, and doesn't make assumptions like lowercase keywords (or not). Using correct scoping of variables is a good habit to get into, though I admit I often don't! I try to be good when I post here, though....

I'm pleased to see people offering, and accepting, help though - I think we need to work together to keep BB4W active.

Zaphod, if you want to offer us a brief guide to scope, I'm sure that would be valuable to lots of us.

Best wishes,

D
« Last Edit: Apr 9th, 2016, 5:17pm by DDRM » User IP Logged

hinckleyj
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 14
xx Re: Variable Program Lesson: (John-hnckleyj)
« Reply #6 on: Apr 10th, 2016, 8:46pm »

Thanks to Michael and Zaphod for all your help.

Appreciate the time you guys have taken to put this information up here.

Regards,

John
User IP Logged

hinckleyj
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 14
xx Re: Variable Program Lesson: (John-hnckleyj)
« Reply #7 on: Apr 10th, 2016, 8:50pm »

on Apr 9th, 2016, 2:52pm, Zaphod wrote:
If anyone has a reference about how to use the 'scope' of variables in BB4W that would be useful to append or post. Or does anyone want me to write something?


That would be most helpful if you have time?

Many thanks

John
« Last Edit: Apr 10th, 2016, 8:51pm by hinckleyj » User IP Logged

michael
Senior Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 335
xx Re: Variable Program Lesson: (John-hnckleyj)
« Reply #8 on: Apr 11th, 2016, 12:51pm »

Here is the latest post on the scope of variables..

http://bb4w.conforums.com/index.cgi?board=language&action=display&num=1460304820

( I would note that libraries have some Global variables too, and I am just working out what they are and what commands they are associated with in windows commands)
User IP Logged

I like making program generators and like reinventing the wheel
Zaphod
Guest
xx Re: Variable Program Lesson: (John-hnckleyj)
« Reply #9 on: Apr 11th, 2016, 2:05pm »

That is correct, you can have Globals in Libraries but it isn't very common and you would use names that would not occur in the user program.
Richard uses the @ in the name such as Q@% say, with the assumption that users don't use @ in variable names so there won't be a clash.

Eventlib has globals for the event queue, and Comlib has globals for transferring variant data but I don't think many others do, although I am sure there are some. They do use system variables which are, of course, global as being part of the language implementation and are predefined.

If you find yourself having to use several assigned globals in a library you are probably not on the right lines and it would be better to reorganize the code. The need for assigned globals in correctly written libraries is quite unusual.
User IP Logged

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