Purpose |
Indicate that the remainder of a line in source code files is to be regarded as a Remark or Comment, and excluded from the compiled code. |
Syntax |
REM comment text ' comment text ; comment in an Inline Assembler statement |
Remarks |
The PowerBASIC compiler ignores Remarks; they do not take up space in your generated code, so use them abundantly - useful comments greatly increase the readability and maintainability of source code. Comment text is any sequence of characters. A comment can appear on a line with other statements, but it must be the last thing on that line, and a colon must precede it. For example, the assignment below will not be compiled or executed because the compiler cannot tell where the comment ends and the statement begins: REM now add the numbers: a = b + c The following works: a = b + c : REM now add the numbers The apostrophe ( ' ) is an alternate form of REM. When you use an apostrophe, you do not need a colon to separate the remark from the other statements on the same line. When using the Inline Assembler, use the semi-colon ( ; ) to indicate that the remainder of the line should be ignored. An apostrophe ( ' ) can still be used for comments, however. In addition, the compiler treats text that appears after the line continuation character as a remark. However, we still recommend that such comments are preceded by a REM or an apostrophe ( ' ) symbol to clearly distinguish remarks from the actual code. For example: DECLARE FUNCTION Call32& _ The prototype LIB "CALL32.DLL" _ The DLL name ALIAS "Call32" _ ' The exported name (Param1 AS ANY, _ ' 1st parameter BYVAL id&) ' 2nd parameter For situations where a large section of code needs to be REMmed out (yet preserved within the source code file), it is often easier to enclose the code with #IF 0/#ENDIF metastatements. For example: #IF 0 ' Exclude the following lines Code and text in between the #IF 0 and #ENDIF metastatements is ignored by the compiler. DIM a$(1 TO 1000) ' This line is ignored too. INCR x& ' As is this line! #ENDIF Since the #IF expression evaluates to false (zero), this forces the compiler to exclude the enclosed block of code from the compilation process, in exactly the same way as if a REM statement had been prefixed to each line. |
See also |
|
Example |
x% = 10 : REM This is a comment y% = 20 ' This is another form of comment ! MOV EAX,"ABCD" ; An Inline Assembler comment |