BBC BASIC for Windows
« Integer Variables.. my interpretation... »

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



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: Integer Variables.. my interpretation...  (Read 494 times)
michael
Senior Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 335
xx Integer Variables.. my interpretation...
« Thread started on: Mar 13th, 2016, 01:49am »

Here is Laymans terms for those who are trying to grasp the basics of (what gets the job done) variables

I have quoted much of this so as to give opportunity for others to correct my interpretation

32-bit variable- a%-z% or A%-Z% or I am guessing a custom variable like - mywierdvariable%

The number 2,147,483,647 (or hexadecimal 7FFF,FFFF16) is the maximum positive value for a 32-bit signed binary integer in computing.
sooo (which is probably more than you will EVER need for a storage range in a basic program)

a integer variable like a% or aaaaa% is normally the average default global style variable ( and it really redefines global when it can carry
values between programs) Its not a big deal but... oh well.

BUT
**********************************************************************************************************************************
*** Variant numeric variables have no suffix character and can contain either integers or real (floating-point) values.

Variant numeric variables can contain either a 64-bit signed integer value or an 80-bit (10-byte) floating-point value consisting of a 64-bit mantissa and
a 16-bit exponent. They have a range of approximately ±3.4E-4932 to ±1.1E4932 and a precision of approximately 19 significant figures.

This is equivilant to the storage of a wanna be black hole that didn't quite make it to being a black hole for storage....

So I take it they are variables like
A- which oddly enough doesn't need to be pre defined with a value.. :) ?????? Am I happy for a good reason?
a
b
c
and others.
If these variables really have a storage capacity in the described range.... its really overkill.. REALLY.. But they dont assume a value for some reason if
you just suddenly use them like this:
g= a+5

a- apparently needs a value at the start and so would g.. so odd
so you would need to do this
g=0
a=0 to activate them I guess.
I could be wrong, but it just seems that way.
**************************************************************************************************************************************
And then there is this style of integer variable: ( it really is the slim athlete that wanted to be everything in the basic program but didnt make it to the finish line)

Byte numeric variables have names which end with an ampersand sign (&). They are stored in 8 bits and can contain any whole number in the range 0 to +255
(byte variables are unsigned). Byte variables are particularly useful as structure members, because they can be used as building blocks to create data
structures of any size.

example:
a&=255 ????(max value)??? why not 2000? ( I donno.. I give up.. Ill just use A or a or A% or a% )

Im a man and I can change if I have to ...... I guess.....
***************************************************************************************************************************************


« Last Edit: Mar 13th, 2016, 3:03pm by michael » User IP Logged

I like making program generators and like reinventing the wheel
Zaphod
Guest
xx Re: Integer Variables.. my interpretation...:(
« Reply #1 on: Mar 13th, 2016, 2:21pm »

So let's start with the fact that a variable does not exist in memory unless there is something assigned to it.
Typically that means it has to appear on the left side of an "equation." Which is really not an equation in a mathematical sense. There is the optional word LET that makes it clearer as in:

LET a=23

Which assigns the value 23 to a variable which then is placed in something called a linked list behind the scenes so that it can be found again.

If you try to use "a" before it has had a value assigned to it then you will get an error because it does not yet exist.

This concept is fundamental to computing languages and perhaps a little background reading is appropriate.

There are other ways that a variable can get created in BB4W which are if it appears in a parameter list, or from the address of operator "^". But you may not be ready for that just yet.

The static integer variables A% through Z% do exist before any assignment as they are predefined locations in memory.

a& holds a byte, 8 bits. 2^8=256 so it can only hold a value of 0 through 255.

A declared integer with a % suffix is 4 bytes or 32 bits
A declared integer with a %% suffix is 8 bytes or 64 bits

A variable with no suffix is 80 bits and will contain an 80 bit floating point value or a 64 bit integer. It is termed a variant type in BB4W.

So to recap only the Static variables and any system variables (Look in the manual) exist prior to an assignment.

http://bbcbasic.co.uk/bbcwin/manual/bbcwin1.html#tutorial

Everything you asked about is in the manual. The information here is specific to version 6 of BB4W


« Last Edit: Mar 13th, 2016, 2:23pm by Zaphod » User IP Logged

Zaphod
Guest
xx Re: Integer Variables.. my interpretation...:(
« Reply #2 on: Mar 13th, 2016, 2:39pm »

It might be a good idea to start you on the right direction to point out that there are a set of conventions on naming variables that will help in programming and program maintenance and allow use of the Cross Reference Utility supplied with BB4W.

Global variables start with an upper case letter, Local variables are all lower case.

Getting to grips with the idea of the scope of a variable is also important. Global variables exist for the duration of the program, but Local variables exist only within the Function or Procedure in which they are defined. And unlike global variables they must defined as LOCAL before use or else they will be given global scope.

If this does not make sense then the manual and Wiki or Wikipedia may fill in the gaps.

https://en.wikipedia.org/wiki/Scope_%28computer_science%29
User IP Logged

michael
Senior Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 335
xx Re: Integer Variables.. my interpretation...:(
« Reply #3 on: Mar 13th, 2016, 2:48pm »

Quote:
If you try to use "a" before it has had a value assigned to it then you will get an error because it does not yet exist.

This concept is fundamental to computing languages and perhaps a little background reading is appropriate.


Thanks for the information. I will learn more about this interesting subject. Since 1982 I haven't seen anything like this except perhaps in C++, C#, Turbo Pascal, and... OMG that's quite a few that use pre definition.. Silly me!!

I would say that is the case in SOME basic languages. Not all. Unless for some reason my translated programs just so happened to work in the language they were originally made on without any definition before hand.. That's why I adopted upper case variables because it made the translation easy.
So perhaps on the previous basic platform it would have probably had some mechanism to assign variables automatically when used in a conditional statement.
If you look in Graphics and games section you will see what I mean..

And here is an example:

a=b+5
print a

This works on the previous platform I used and a and b do not need to be defined. It is interesting though that you brought this to my attention.


« Last Edit: Mar 14th, 2016, 2:07pm by michael » User IP Logged

I like making program generators and like reinventing the wheel
Zaphod
Guest
xx Re: Integer Variables.. my interpretation...
« Reply #4 on: Mar 13th, 2016, 4:06pm »

Quote:
This works on the previous platform I used and a and b do not need to be defined. It is interesting though that you brought this to my attention.


Certainly a language can assume that an unknown variable has a value of null and use that. BASIC was intended for beginners and so that might be assumed in some. BB4W is not quite so basic a BASIC but more powerful than most. I think that knowing that a variable has not been assigned rather than it assuming a null value is a useful feature, personally, but it does force you to be a little more disciplined.

BB4W does not require formal declaration of all variables by type as some of the languages you listed do and is in between both in difficulty, complexity and power. It does have the advantage, that is very real, of allowing immediate computation from the IDE without having to compile. But it can be compiled into fast and small executables unlike many BASICs. It also has the ability to not need the use of line numbers and "goto" and be faster and easier to read because of that, like most of its modern successors.
BB4W does have a distinct flavor that you will have to get to grips with but it will be worthwhile. It is not a C++ or C# but a higher level language, perhaps closer to the Pascals that used p-code interpreters which you may be familiar with. But perhaps the most unique feature is the full blown assembler built in just in case you need the speed of a compiled C++.

Welcome to the fold.

User IP Logged

michael
Senior Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 335
xx Re: Integer Variables.. my interpretation...
« Reply #5 on: Mar 13th, 2016, 10:01pm »

I had played with assembly language on my Trs-80 or CoCo3.(cant remember- I think it was the Trs-80)
I liked playing with it for a bit but basic dominated so...
I bought the assembly language book.. Where do these things disappear to?
**********************************************
The one thing is that back in 2010-2011 BBC basic was the FIRST basic I found since 1992 that resembled Qbasic and if I knew what I know now I would have stayed with it. ( I didn't even give it a chance mainly because of how it initially was displayed)
-I was like "Whats that? " and ran away.
The problem with BBC basic was the way the language was promoted in program structure. If a person were to judge it without looking at the manual they would not think it was basic.
BBC BASIC is BASIC.
A person just needs to present it in a super basic way, even though it may not be the way the advanced users would.
I think some would probably disagree with me but if you look carefully at my examples, you might understand and see why I made this point.
My examples are the most BASIC presentation of BBC Basic and extremely luring to a novice programmer.
Advanced users don't see this.
This platform has everything a person needs and new people need a different presentation.
Thanks for clearing up all this. This will help me and everyone.
I will make some super useful PROCedures for the community for filing and windows display and I plan to make them super easy to use. ( I am interested in making library functions..
I like a challenge..

« Last Edit: Mar 14th, 2016, 2:08pm by michael » User IP Logged

I like making program generators and like reinventing the wheel
Zaphod
Guest
xx Re: Integer Variables.. my interpretation...
« Reply #6 on: Mar 14th, 2016, 12:26am »

Code:
The problem with BBC basic was the way the language was promoted in program structure. If a person were to judge it without looking at the manual they would not think it was basic. 


Well it was developed as a BASIC to promote structured programming in an Educational setting. It has the same command set as other BASICs plus more of the structural elements that have since become standard in just about all languages as well as modern BASIC dialects.

BASICs are not typically used as a first coding language any more and programs like "Scratch" often used in the UK schools from about 8 years old, and then moving onto "Python" so I hear.

I am just worried that the simplistic approach you are advocating draws people into bad habits and does not let them get the skills to move onto more complicated programs such as C++, or even exploit the true power of BB4W.

Of course, I may be in a minority of two, as I expect Richard made similar comments. But I hope you will continue and draw in all these new coders where we elders have failed.











User IP Logged

Zaphod
Guest
xx Re: Integer Variables.. my interpretation...
« Reply #7 on: Mar 14th, 2016, 12:32am »

Quote:
Im a man and I can change if I have to ...... I guess..


Ah, now I understand, you are the Red Green of computing, with duct tape no doubt. smiley
User IP Logged

michael
Senior Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 335
xx Re: Integer Variables.. my interpretation...
« Reply #8 on: Mar 14th, 2016, 12:57am »

I actually sound like him too.. LOL

And actually I am more like him than you can imagine.

And I have lots of Duct tape..
User IP Logged

I like making program generators and like reinventing the wheel
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