Thursday, 28 January 2010

Hello World

While Programming is a relevantly new trade it is old enough to have at least one tradition. This tradition is that the first program any budding programmer writes is the famous 'Hello World' Program. It involves one command and two words of quote marked text. The aim of the program is simply to use the editor, run the program and save it. then open the program again.

Note the PRINT command dates back to the days before monitors so in those days PRINT meant PRINT on paper.














Note: In all the following lessons I will use a line to show the start of the program and another at the end.

__________________________________________________
REM The Famous Hello World Program
REM is an ignored command and is used by
REM programmers to allow 
REM them to remark their on the program.
REM anything after the rem statement 
REM on the same line is just a remark


PRINT "Hello World"


REM that's the Whole Program!
___________________________________________________

Now make a note of the program and open the QBasic  Editor and type it in. Then when you have finished click on run and observe the results.








Then press any key to return to the Editor.











Once you return to the editor Click on the file menu and save the project. Name the Project 'HWorld'  all as one word.

Note: Back in the days of DOS file names could not be more than 8 characters long (I forgot). It is very important to remember this as  longer  names will overwrite the extension name which identifies the file as a Basic file. QBasic will create the extension when you save the file so you don't have to write the .BAS extension on the end yourself. Just remember, limit the name to 8 characters otherwise when you go to open your program in the editor it will look as if it is not there.










For more on extensions I will write a short piece on it and post it on the right hand side.

No comments:

Post a Comment