I ask as I know that normaly it is difficult for others to read my code, as my normal style developed over the last 32 years of writing code is not what most expect to see.
I hope that this is readable easily to others. Though if it is not I would apreciate any feedback on how to improve the readability.
This is just a short example of the style I intend to apply to the larger programs (that are already written, in my old way so will need modified).
Here is an Example, target OS is RISC OS, language is ARM BASIC (BBC BASIC V):
Code: Select all
REM > !RunImage REM * Simple program to answer the question of code readability. The prrogram REM * just places an Icon Sprite on the IconBar, and quits when the Icon REM * clicked on. Poor example of program, good readability. ON ERROR PRINT "LINE : " + STR$(ERL) + " ERROR : " + REPORT$ : END _TaskMagic% = &4B534154 _WimpVer% = 310 :REM Minimum WIMP version. _TaskName$ = "Readable" :REM Name for WIMP task. _AppIcon$ ="!readable" :REM Name of IconBar Icon. _IconSprite% = &00000002 :REM Icon flag is Sprite. _IconFlagClick% = &00003000 :REM Icon Flag button type click. _TempSize% = 256 :REM Size of Temp Work space. _PollFlags% = &00002301 :REM Poll flags, for minimum CPU. TaskHandle% = 0 Icon% = 0 IconHandle% = 0 DIM TempWork% _TempSize% PROCStart END DEF PROCPoll : REM *** Poll Loop, handling Poll reasons. *************** LOCAL quit%, reason% quit% = FALSE REPEAT SYS "Wimp_Poll",_PollFlags%,TempWork% TO reason% CASE reason% OF WHEN 6: :REM If clicked on our Icon, quit. IF TempWork%!8 = -2 THEN quit% = TRUE WHEN 17,18: :REM If user message is quit, we quit. IF TempWork%!16 = 0 THEN quit% = TRUE UNTIL quit% ENDPROC DEF PROCStart :REM *** Our Entry Point ********************************* LOCAL x0%,y0%,x1%,y0%,flags%,data% x0% = 4: y0% = 8: x1% = 12: y1% = 16 flags% = 20: data% = 24 SYS "Wimp_Initialise",_WimpVer%,_TaskMagic%,_TaskName$,0 TO TaskHandle% Icon% = TempWork% !Icon% = -1 : REM Window handle of IconBar. Icon%!x0% = 0 Icon%!y0% = 0 Icon%!x1% = 64 Icon%!y1% = 64 Icon%!flags% = _IconFlagClick% OR _IconSprite% $(Icon%+data%) = _AppIcon$ SYS "Wimp_CreateIcon",,Icon% TO IconHandle% PROCPoll SYS "Wimp_CloseDown",TaskHandle%,_TaskMagic% ENDPROC
I am attaching the complete application including the Sprite file and the two obey files. The attachment also contains a text copy of the source so those that do not have RISC OS may read the source code with ease.
If you intend to run this, then only unzip in RISC OS, so as to preserve file types.