Author |
Topic: Variable Program Lesson: (John-hnckleyj) (Read 924 times) |
|
Zaphod
Guest
|
 |
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?
|
|
Logged
|
|
|
|
DDRM
Administrator
member is offline


Gender: 
Posts: 321
|
 |
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 » |
Logged
|
|
|
|
hinckleyj
New Member
member is offline


Gender: 
Posts: 14
|
 |
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
|
|
Logged
|
|
|
|
hinckleyj
New Member
member is offline


Gender: 
Posts: 14
|
 |
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 » |
Logged
|
|
|
|
michael
Senior Member
member is offline


Posts: 335
|
 |
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)
|
|
Logged
|
I like making program generators and like reinventing the wheel
|
|
|
Zaphod
Guest
|
 |
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.
|
|
Logged
|
|
|
|
|