Making a block of code inactive like with this";"

Satchid

Member
Hallo everyone,
I am coding in Picaxe basic, i know how to put comments with " ' " or " ; ". But when i have more to say as comment than one line, or if i want to comment out a bigger block of code out of a program, then i dont want to comment out line by line. I know there is a way in Picaxe basic to inactivate a block of line at once. I can not find it, i can not find the right question to get the right answer.
Is there antibody that can give me the answer to this please?
Thank You
 
Two ways...

Select a block of code and right-click and choose "Comment -> Comment"

or

insert #REM before the desired code and #ENDREM after it.
 
Avoid comments all together ... they just take the fun out of programming down the road. When you open up a program you wrote 5 years ago, you want to feel the thrill of rediscovering things!

Cave explorers don't just look at a map of a cave and say, "Well, that looks fun!" NO! They go into that cave and explore it! Sometimes the same cave more than once!
 
...and yet another way: blocks of code scattered throughout your program can be included or excluded by using the complier directives #Define/#IfDef/#IfNDef/#Else/#EndIf. You just use or disable (comment out) the #Define directive. Refer to "Pre-Processor and Directives" in Manual 2.

Example: Several years ago, I was commissioned to program a 3-metre tall clock called "Little Ben" in a public park. During daylight hours it played the appropriate Westminister Chimes on everyquarter hour. I wrote the code on my computer in my home office and, because the real bells were located several kilometres away, I used the piezo sounder to simulate the bells when debugging the code. (The PICAXE 28X2 was also connected to a GPS module to keep accurate time). The following code is an example of conditional compilation.
Rich (BB code):
#Define UsePiezo      'Placed at the top of the program (Ie use Piezo speaker rather than solenoids)
'      
' ----- Subroutine QuarterPast: One Chime - #1 ------------------------------------
'
QuarterPast:        'Note: Directives must be on their own lines
         #IfDef UsePiezo
            Tune oPiezo, 12, (nGsharp6q, nFsharp6q, nE6q, nB5h)  'The "Bing-bong-ding-dong" sequence
         #Else
            Chime1      'Macro defined to play the real chimes on the bells
         #EndIf
         Return
         
 
Last edited:
Back
Top