Return to the Home Page... Features on BBC BASIC programming... Your questions and answers... Buy or Sell an NC... The NC200 manual and data sheets for BBC BASIC... Information about BBC BASIC on the NC... Free software for you to download...

Tim's Amstrad NC Users' Site

Tim's Tips for Programming

You will notice if you read programs written by me on the software page that I tend to stick to certain conventions. This is something which I would advise you to do when programming in BASIC so as to get into a 'good habit'.

Some of the things I do are:

O Keep some variable names strictly for special functions, like:
  • G -- Always contains the value obtained from a GET or INKEY input.
  • G$ -- As above, but for string inputs.
  • I or A -- General purpose loop variables in a FOR statement.
  • K -- Channel number when using the OPEN filing commands.
  • X,Y -- General purpose graphics co-ordinates.
  • TX,TY -- General purpose text co-ordinates.

It is best to only use I or A as loop variables in functions or procedures, otherwise you run the risk of defining a loop I in the main program, then calling an FN/PROC where there is another loop with the variable I or A, returning from the FN/PROC, and finding that the value of I or A is now wrong. (This can be very annoying when you can't see how the program could have gone wrong!)

O Always put a few REM lines at the start of a program giving the title/author/date/version.
Also put REM's in long lists of similar lines to make it easier to find a specific line. (e.g., DATA lines with lots of numbers.)
O After the first REM lines put any DIM statements that are needed so that you cannot get a 'Bad DIM' error by using GOTO to go back to a line before the DIM.
O Use sensible names for variables, arrays and FN/PROCs. Keep to one case - upper or lower, except for those 'special' variables mentioned before.
O Re-number a listing before printing it out to give to someone. It is very annoying to get a listing that looks as if it's line numbers are multiples of ten, only to find after typing it in using AUTO, that extra lines have been slipped in! It is especially annoying to see this in books -- see pages 197 and 201 of the Notebook manual!
O Remove spaces from program lines to save memory.
O To save memory when writing long files, use BPUT to store numbers between 0 and 255 rather than PRINT#, since BPUT uses only one byte of memory to store the number.
1997–2017 Tim Surtell

Tim's Amstrad NC Users Site

Return to top of page...

| Home | Features | Data Sheets | Questions | BBC BASIC | Software |