@NewLine (JavaScript)
Returns the newline character.
Defined in
@Functions (JavaScript)Syntax
@NewLine() : string
Return value | Description |
---|---|
string |
The newline character. |
Usage
The newline character is Unicode 10. JavaScript™ escapes it as\n
.Examples
This example parses a string on its newlines.function p(stuff) {
print("<<<" + stuff + ">>>");
}
// Create string with newlines
var line1 = "Line one";
var line2 = "Line two";
var line3 = "Line three";
var lines = line1 + "\n" + line2 + "\n" + line3;
// Parse string into separate lines
var oneline = "";
while(lines.length > 0) {
if(@Contains(lines, @NewLine())) {
oneline = @Left(lines, @NewLine());
lines = @Right(lines, @NewLine());
} else {
oneline = lines;
lines = "";
}
p(oneline);
}