Kids sometimes say, “I call dibs on it” meaning they want to be first in line or are claiming a priority over something or somebody. Also known as “I call front seat!”
In QBasic64 we don’t call this idea dibs we call it DIM. DIM is used to define and claim variables. People don’t like messy surprises and neither do computers. To minimize programming surprises, you need to define variables to give the computer a heads-up of what you will be doing with data.
For example, if you plan on working with data, you need to give names to your variables such as num1, num2 ,x, y, z, Bob or Mr.Jingles. You usually name variables that are easy for you to remember. However, QBasic does have a few rules about how you name a variable, for example, the name can contain only letters and digits. You cannot use a QBasic reserved word.
That’s right, QBasic calls dibs on a lot of words such as PRINT, CLS and DIM so you can’t use those as variables. They are generally commands and functions of the QBasic language.
But wait, there’s more, not only do you get to name variables, you get to define them. There are two basic data types, numbers and characters. If you’re working with whole numbers, maybe define your variable as INTEGER. If you’re working with or characters (text) define your variables as STRING.
DIM Num1 AS INTEGER
DIM Num2 AS INTEGER
DIM Ans AS INTEGER
DIM Corr AS INTEGER
DIM x as STRING
DIM MrJingles as STRING
Make sure your variables blend with your data and program logic otherwise you will learn the complier will let you know in no uncertain terms.
“Will it Blend on a Dibs CommercialWill it Blend on a Dibs Commercial” posted by ntbreaththis.
No comments:
Post a Comment