Nonexecutable statement
Updated: 04/09/2024 by Computer Hope
A nonexecutable statement is a programming command not run or executed by the computer when it reads the program code. For example, a commonly used nonexecutable statement is REM (remark), used in batch files and other Microsoft Windows and DOS programs.
The following are characters or text used to remark, comment, or cause a line of code to be skipped.
REM | Used to add a comment in a batch file. Start a line with "REM" to not execute the code. "@echo off" must also be included for a REM comment to be ignored. The following is an example of how this may look. @echo off REM Batch file comment example |
:: | Two colons are used to add a comment in a batch file, like REM, but does not require "@echo off" to be included. Start a line with "::" to not execute the code. The following is an example of how this may look. :: Batch file comment example |
# | The pound symbol comments a line in programming languages such as Perl, PHP (PHP: Hypertext Preprocessor), Python, and Ruby, and in bash scripts. This symbol is only required once at the beginning of what you want ignored. The following is an example of how this may look. # Commented line of code example |
; | The semicolon is used to remark a line in an INI file and in AutoHotkey. This symbol is only required once at the beginning of the line. Note that it must be at the beginning of the line in an INI file. The following is an example of how this may look. ; Beginning of INI file - comment example |
! | The exclamation mark is used in programming languages like Perl and Ruby, and scripting programs, like a bash script, to comment on a line. This symbol is commonly required at the beginning of the line. The following is an example of how this may look. ! Perl & Ruby comment example |
/* */ | Used to add a comment to a line in C, CSS (Cascading Style Sheets), PHP, and other programming languages. The comment must begin with "/*" and end with "*/" to be ignored and not executed. The following is an example of how this comment may look. /* Computer Hope comment */ |
// | Two forward slashes at the beginning of a line add a comment to C, C++, Dart, Java, JavaScript, and PHP. The following is an example of how this may look. //JavaScript comment example |
<!-- --> | Used in HTML (HyperText Markup Language), XHTML (eXtensible HyperText Markup Language), and XML (extensible markup language). Begin the comment with "<!--" and end it with "-->" to not execute the code. The following is an example of how this comment may look. <!-- Computer Hope comment --> |
' | In FoxPro, QBasic, RPG (Report Program Generator), and VBScript, starting a line with a single quote creates a nonexecutable line. The following is an example of how this may look. ' Commenting a line of code |
Examples of nonexecutable statements
Below are basic examples of how nonexecutable statements (comments) may appear using various programming languages, including C#, HTML, JavaScript, Perl, PHP, and Python. Notice that comments can begin at the beginning of the line or inline after executable code. If a comment is added after executable code, the remainder of the line is considered a comment and not executed.
Batch file
@echo off REM Create 'myName' variable and set a value (not displayed with echo off) set myName=Nathan ::Display greeting text (won't display with or without echo off) echo Hello %myName%, how are you?
C#
var myName = "Nathan"; //Create variable with value /*Display greeting text with 'myName' value*/ Console.WriteLine($"Hello, {myName}, how are you?");
JavaScript & HTML
<-- Create line where text is displayed --> <p id="example">Display Javascript output here</p> var name = "Nathan"; //set 'name' variable to Nathan //Display text document.getElementById("example").innerHTML = "Hello ${name}, how are you?";
Perl
use strict; #Use strict to prevent errors. my $name = "Nathan"; #Set the name variable to Nathan #Print greeting text print "Hello $name, how are you?\n";
PHP
// create variable and set value var myName = "Nathan"; echo "Hello, $myName, how are you?"; //Display greeting
Python
myname = "Nathan" #Create variable, set value #Display greeting text when code is executed print(f"Hello {myname}, how are you?")