#rem & #endrem, something I noticed.

Michael 2727

Senior Member
Something I noticed when using the Directives
#rem and
#endrem
See the code example below, the explanation is half way down.
This caught me out when trying several versions of a similar code.

Also #REM works but #ENDREM in capitals does not seem to work.
And I'm still using Prog-Editor ver 5.0.0.7 :p
Code:
#rem  
'Code is REV-ED HEX WALKER code as an example.
'*** Program constants
' Delay to slow down servo motion (30ms default)
symbol servo_delay = 30
'*** Initialisation
init:
' set servos to known position
servo 1,120
servo 2,120
servo 4,120
pause servo_delay
'*** Move forward
move_forward:
for b1 = 90 to 230
servo 1,b1
pause servo_delay
next b1
for b1 = 90 to 230
servo 4,b1
servo 2,b1
pause servo_delay
next b1
for b1 = 150 to 230 step -1
servo 1,b1
pause servo_delay
next b1
for b1 = 150 to 230 step -1
servo 4,b1
servo 2,b1
pause servo_delay
next b1
goto move_forward
'
'
'#endrem   '<<<<<<<<<<*** CODE = 73 BYTES AS IS ***. 
          '<<<<<<<<<< BUT IF THIS #enderm IS COMMENTED
          '<<<<<<<<<< OUT e.g.('#endrem) THE CODE BELOW 
          '<<<<<<<<<< APPEARS TO BE READY FOR DOWNLOADING.
          '<<<<<<<<<< BUT CHECKING THE SYNTAX REVEALS 
          '<<<<<<<<<< ONLY 3 BYTES USED.
          '<<<<<<<<<< I think I downloaded 3 bytes a few times
          '<<<<<<<<<< and wondered why nothing was working ???
'
'
'SECOND VRESION OF THE CODE BELOW
'
'#rem

'*** Program constants
' Delay to slow down servo motion (30ms default)
symbol servo_delay = 30
'*** Initialisation
init:
' set servos to known position
servo 1,120
servo 2,120
servo 4,120
pause servo_delay
'*** Move forward
move_forward:
for b1 = 90 to 230
servo 1,b1
pause servo_delay
next b1
for b1 = 90 to 230
servo 4,b1
servo 2,b1
pause servo_delay
next b1
for b1 = 150 to 230 step -1
servo 1,b1
pause servo_delay
next b1
for b1 = 150 to 230 step -1
servo 4,b1
servo 2,b1
pause servo_delay
next b1
goto move_forward
'
'
#endrem
 

hippy

Technical Support
Staff member
It's the standard problem of nesting code comments which can occur in many programming languages ( and even in HTML ).

A safer way to choose between two sections of code is to use #DEFINE plus #IFDEF/#ELSE/#ENDIF.

The #ENDREM in capitals does work ( in that it ends the comment ) it's just that the colour syntax isn't switched back from the comment colour. It is confusing though.
 
Top