March 28, 2024, 10:55:57 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Basic Clarity 1

Started by GWS, June 13, 2012, 03:18:01 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

GWS

Hi folks,

For years I've had to sit and listen to folk in books and on the Web, deriding Basic as some kind of toy which 'real programmers' would consider beneath them.

Some of their comments indicate that their last encounter with Basic was back in the Sinclair ZX81 home computer days.  They still think you have to use line numbers and goto's.

So I thought I'd post a few very short example of Basic code which to my mind illustrate the beauty of the language, and which I would now choose as the best of all the languages I've used over my working lifetime.

I just wish I'd have had access to even the unassuming Creative Basic all those years ago.

I hope you will enjoy the simplicity of these little examples - compare them with other languages you may have around, and see if you agree ..  :)

Here's the first one:


openconsole
cls

' Basic Clarity 1 ..

x = 5
x = x + 1


print "The value of x is ",x
do:until inkey$<>""
closeconsole
end


What does this illustrate ?  Simply initialising a variable, and using it in just two statements.

Notice the variable  'x' is set to the value 5 in just 3 characters.

To change it's value we use another statement, which should be read as: 'change the right-hand side of the equation, and set the left-hand quantity to the result'.

Note, there's not a colon or semi-colon in sight, which there would be in other languages.

Very pretty I think .. Hope I won't bore you with these ideas.

All the best, :)

Graham

Tomorrow may be too late ..