ProtoLang.net

Reference: Text

☰ Hide Sidebar
TOKEN TEXT
ALIAS "

The Text Delimiter is used to define String literals in ProtoLang. String literals must be enclosed in double quotes (") to distinguish them from variable names and other tokens. Everything between the opening and closing double quote is text treated data, code not to be executed.

Syntax

The short syntax structure uses the " symbol:

"String Content"

The long syntax structure uses the word TEXT:

TEXTString ContentTEXT

How Text Delimiters Work

Text delimiters boundaries serve for string literal values:

  1. The opening " marks the beginning of a string literal
  2. All characters between the opening and closing quotes are literal treated text
  3. The closing " marks the end of the string literal
  4. The content is a stored String data type value
  5. Double quotes themselves cannot appear inside the string (currently not supported)

Example: Basic String Literal

NEW STR message = "Hello, World!"
PRINTLN message
// Displays: Hello, World!

Creating String Variables

Example: String Variable with Text

NEW STR greeting = "Welcome to ProtoLang"
NEW STR name = "Alice"
NEW STR status = "active"
PRINTLN greeting
PRINTLN name
PRINTLN status

Example: Empty String

NEW STR empty = ""
NEW STR blankMessage = ""
PRINTLN "Start"
PRINTLN empty
PRINTLN "End"
// Displays: Start, (blank line), End

Example: Single Character Strings

NEW STR letter = "A"
NEW STR digit = "5"
NEW STR symbol = "@"
PRINTLN letter
PRINTLN digit
PRINTLN symbol
// Displays: A, 5, @

Example: Multi-Word Strings

NEW STR sentence = "This is a complete sentence with many words"
NEW STR phrase = "multiple words here"
PRINTLN sentence
PRINTLN phrase

Strings with Special Characters

Example: Strings with Numbers

NEW STR code = "ABC123"
NEW STR phone = "555-1234"
NEW STR mixed = "Room 42"
PRINTLN code
PRINTLN phone
PRINTLN mixed
// Numbers inside quotes are text treated, not numbers

Example: Strings with Punctuation

NEW STR question = "How are you?"
NEW STR exclamation = "Great job!"
NEW STR list = "apples, oranges, bananas"
PRINTLN question
PRINTLN exclamation
PRINTLN list

Example: Strings with Symbols

NEW STR email = "[email protected]"
NEW STR price = "$19.99"
NEW STR math = "2 + 2 = 4"
PRINTLN email
PRINTLN price
PRINTLN math
// Math symbols are text treated, not operations

Example: Strings with Spaces

NEW STR spaces = "   multiple   spaces   "
NEW STR leading = "   starts with spaces"
NEW STR trailing = "ends with spaces   "
PRINTLN spaces
PRINTLN leading
PRINTLN trailing
// All spaces are preserved written exactly

String Literals vs Variables

Text delimiters distinguish string literals from variable names.

Example: String Literal vs Variable Name

NEW STR message = "Hello"
PRINTLN "message" // Displays: message (the literal text)
PRINTLN message // Displays: Hello (the variable's value)

Example: Number String vs Number Value

NEW STR numberStr = "42"
NEW INT numberInt = 42
PRINTLN numberStr // Displays: 42 (as text)
PRINTLN numberInt // Displays: 42 (as number)
// They look the same but have different data types

Example: Variable Name Inside Quotes

NEW INT x = 100
PRINTLN "x" // Displays: x (literal text)
PRINTLN x // Displays: 100 (variable value)
NEW STR y = "x" // y contains the letter "x", not the value of variable x
PRINTLN y // Displays: x

Using Strings in Print Statements

Example: Printing String Literals

PRINTLN "Hello, World!"
PRINTLN "This is a test"
PRINTLN "Line 1"
PRINTLN "Line 2"
PRINTLN "Line 3"

Example: Printing String Variables

NEW STR greeting = "Good morning"
NEW STR name = "Alice"
PRINTLN greeting
PRINTLN name

Example: Mixing Literals and Variables

NEW STR name = "Bob"
PRINTLN "Hello"
PRINTLN name
PRINTLN "Welcome!"
// Displays: Hello, Bob, Welcome!

String Concatenation

String literals can be combined with other values using the Concatenate operator.

Example: Concatenating String Literals

NEW STR message = "Hello" .. " " .. "World"
PRINTLN message // Displays: Hello World

Example: Concatenating Variables and Literals

NEW STR name = "Alice"
NEW STR greeting = "Hello, " .. name .. "!"
PRINTLN greeting // Displays: Hello, Alice!

Example: Building Messages

NEW STR firstName = "John"
NEW STR lastName = "Doe"
NEW STR fullName = firstName .. " " .. lastName
PRINTLN "Name: " .. fullName
// Displays: Name: John Doe

Example: Concatenating with Numbers

NEW INT score = 95
NEW STR message = "Your score is: " .. score
PRINTLN message // Displays: Your score is: 95

Example: Multi-Part Concatenation

NEW STR item = "apples"
NEW INT count = 5
NEW FLOAT price = 1.50
NEW STR result = "You bought " .. count .. " " .. item .. " for $" .. price
PRINTLN result // Displays: You bought 5 apples for $1.5

Strings in Conditionals

Example: String Comparison

NEW STR password = "secret123"
IF password == "secret123"
    PRINTLN "Access granted"
ELSE
    PRINTLN "Access denied"
END IF
// Displays: Access granted

Example: Multiple String Checks

NEW STR command = "start"
IF command == "start"
    PRINTLN "Starting program"
ELIF command == "stop"
    PRINTLN "Stopping program"
ELIF command == "pause"
    PRINTLN "Pausing program"
ELSE
    PRINTLN "Unknown command"
END IF
// Displays: Starting program

Example: Case-Sensitive String Comparison

NEW STR input = "Yes"
IF input == "yes"
    PRINTLN "Lowercase match"
ELIF input == "Yes"
    PRINTLN "Capitalized match"
ELIF input == "YES"
    PRINTLN "Uppercase match"
END IF
// Displays: Capitalized match (case matters!)

Example: String Inequality

NEW STR status = "pending"
IF status != "complete"
    PRINTLN "Still processing"
ELSE
    PRINTLN "All done"
END IF
// Displays: Still processing

Strings in Loops

Example: Looping with String Messages

NEW INT i = 1
WHILE i <= 3
    PRINTLN "Iteration number " .. i
    SET i = i + 1
END WHILE
// Displays: Iteration number 1, Iteration number 2, Iteration number 3

Example: Building Strings in Loop

NEW INT i = 1
NEW STR result = ""
WHILE i <= 5
    SET result = result .. i .. " "
    SET i = i + 1
END WHILE
PRINTLN result // Displays: 1 2 3 4 5

Example: String-Based Loop Control

NEW STR status = "running"
NEW INT count = 0
WHILE status == "running"
    SET count = count + 1
    PRINTLN "Processing... " .. count
    IF count >= 3
        SET status = "stopped"
    END IF
END WHILE
PRINTLN "Status: " .. status

Allowed Characters in Strings

ProtoLang strings support Printable ASCII Characters only.

Example: Letters and Digits

NEW STR letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
NEW STR digits = "0123456789"
NEW STR alphanumeric = "Test123"
PRINTLN letters
PRINTLN digits
PRINTLN alphanumeric

Example: Common Punctuation

NEW STR punctuation = "Hello! How are you? I'm fine, thanks."
NEW STR symbols = "Use these: @ # $ % & * ( ) - + = [ ] { } ' , . / ?"
PRINTLN punctuation

Example: Special Symbols

NEW STR math = "+ - * / = < >"
NEW STR other = "! @ # $ % ^ & * ( ) _ + { } | < > ?"
PRINTLN math
PRINTLN other

Escape Sequences

ProtoLang supports (newline) and (tab) escape sequences, though they may produce unexpected results.

Example: Newline Escape Sequence

NEW STR multiLine = "Line 1\nLine 2\nLine 3"
PRINTLN multiLine
// Note: \n behavior may vary

Example: Tab Escape Sequence

NEW STR tabbed = "Name:\tJohn\tAge:\t25"
PRINTLN tabbed
// Note: \t behavior may vary

String Delimiter Requirements

Example: Both Delimiters Required

NEW STR opening = "This string is properly closed"
NEW STR complete = "Both quotes present"
PRINTLN opening
PRINTLN complete

Example: Matching Delimiters

NEW STR str1 = "Start and end with double quotes"
NEW STR str2 = "" // Empty string still needs both quotes
NEW STR str3 = " " // Single space string
PRINTLN str1
PRINTLN str2
PRINTLN str3

Practical Applications

Example: User Messages

NEW STR username = "alice123"
PRINTLN "Welcome, " .. username .. "!"
PRINTLN "Your account is active."
PRINTLN "Last login: January 28, 2026"
// Displays formatted user messages

Example: Menu System

PRINTLN "=== Main Menu ==="
PRINTLN "1. Start New Game"
PRINTLN "2. Load Game"
PRINTLN "3. Settings"
PRINTLN "4. Exit"
PRINTLN "================="

Example: Data Labels

NEW STR name = "Product A"
NEW FLOAT price = 29.99
NEW FLOAT quantity = 5.0
PRINTLN "Product: " .. name
PRINTLN "Price: $" .. price
PRINTLN "Quantity: " .. quantity
PRINTLN "Total: $" .. ( price * quantity )

Example: Status Messages

NEW INT progress = 1
WHILE progress <= 3
    IF progress == 1
        PRINTLN "[*] Initializing..."
    ELIF progress == 2
        PRINTLN "[*] Processing data..."
    ELIF progress == 3
        PRINTLN "[*] Finalizing..."
    END IF
    SET progress = progress + 1
END WHILE
PRINTLN "Complete!"

Example: Report Generation

NEW STR title = "Monthly Sales Report"
NEW STR month = "January"
NEW INT sales = 1250
NEW INT target = 1000
PRINTLN "================================"
PRINTLN title
PRINTLN "================================"
PRINTLN "Month: " .. month
PRINTLN "Sales: $" .. sales
PRINTLN "Target: $" .. target
IF sales >= target
    PRINTLN "Status: Target Met!"
ELSE
    PRINTLN "Status: Below Target"
END IF
PRINTLN "================================"

Example: Error Messages

NEW INT errorCode = 404
NEW STR errorType = ""
IF errorCode == 404
    SET errorType = "Not Found"
ELIF errorCode == 500
    SET errorType = "Server Error"
ELIF errorCode == 403
    SET errorType = "Forbidden"
END IF
PRINTLN "Error " .. errorCode .. ": " .. errorType

Example: Formatted Output

NEW INT i = 1
NEW INT square = 0
NEW INT cube = 0
PRINTLN "Count | Square | Cube"
PRINTLN "------|--------|------"
WHILE i <= 3
    SET square = i * i
    SET cube = i * i * i
    PRINTLN i .. "     | " .. square .. "      | " .. cube
    SET i = i + 1
END WHILE

String Delimiters with Different Data Types

Example: Converting Types to Strings

NEW INT number = 42
NEW FLOAT decimal = 3.14
NEW BOOL flag = TRUE
NEW STR numStr = "Number: " .. number
NEW STR decStr = "Decimal: " .. decimal
NEW STR flagStr = "Flag: " .. flag
PRINTLN numStr
PRINTLN decStr
PRINTLN flagStr
// All values converted to strings via concatenation

Example: String vs Number Context

NEW STR numString = "100"
NEW INT numInt = 100
PRINTLN "String: " .. numString // Displays: String: 100
PRINTLN "Number: " .. numInt // Displays: Number: 100
// String "100" and Integer 100 are different types

Important Notes

  • String literals must be enclosed in double quotes (").
  • Both opening and closing quotes are required.
  • Everything between quotes is literal treated text.
  • Strings support Printable ASCII Characters only.
  • Double quote characters (") cannot appear inside strings (not currently supported).
  • String comparisons are case-sensitive ("Hello" ≠ "hello").
  • Empty strings ("") are valid.
  • Spaces and special characters are preserved written exactly.
  • Use the Concatenate operator (..) to combine strings.
  • Escape sequences and are supported but may produce unexpected results.

Common Errors

Error: Missing Opening Quote

NEW STR message = Hello" // Syntax error! Missing opening "
PRINTLN message

// Correct: Include both quotes
NEW STR message = "Hello"
PRINTLN message

Error: Missing Closing Quote

NEW STR message = "Hello // Syntax error! Missing closing "
PRINTLN message

// Correct: Include both quotes
NEW STR message = "Hello"
PRINTLN message

Error: No Quotes Around String

NEW STR greeting = Hello // Syntax error! String must be in quotes
PRINTLN greeting

// Correct: Enclose in quotes
NEW STR greeting = "Hello"
PRINTLN greeting

Error: Using Single Quotes

NEW STR message = 'Hello' // Syntax error! Must use double quotes
PRINTLN message

// Correct: Use double quotes
NEW STR message = "Hello"
PRINTLN message

Error: Double Quote Inside String

NEW STR quote = "He said "Hello"" // Syntax error! Quotes can't be inside strings
PRINTLN quote

// Note: ProtoLang does not currently support quotes inside strings
// Workaround: Rephrase without internal quotes
NEW STR quote = "He said Hello"
PRINTLN quote

Error: Confusing String with Variable

NEW STR name = "Alice"
NEW STR greeting = Hello name // Syntax error! Strings need quotes
PRINTLN greeting

// Correct: Use quotes and concatenate
NEW STR greeting = "Hello " .. name
PRINTLN greeting // Displays: Hello Alice

Error: Mixing Quotes

NEW STR message = "Hello' // Syntax error! Mismatched quotes
PRINTLN message

// Correct: Use matching double quotes
NEW STR message = "Hello"
PRINTLN message

Error: String on Multiple Lines

NEW STR message = "This is a
multi-line string" // Syntax error! Strings can't span multiple lines
PRINTLN message

// Correct: Use concatenation or escape sequence
NEW STR message = "This is a" .. " multi-line string"
// Or use 
 (though behavior may vary)
NEW STR message2 = "This is a
multi-line string"
PRINTLN message

Error: Forgetting Quotes in Print

PRINTLN Hello // Runtime error! Hello is undefined treated variable
// Correct: Use quotes for literal text
PRINTLN "Hello"

Error: Concatenating Without Quotes

NEW STR name = "Alice"
NEW STR greeting = Hello .. name // Syntax error! Hello needs quotes
PRINTLN greeting

// Correct: Quote the literal text
NEW STR greeting = "Hello " .. name
PRINTLN greeting

Error: Empty String Without Quotes

NEW STR empty =  // Syntax error! Even empty strings need quotes
PRINTLN empty

// Correct: Use empty quotes
NEW STR empty = ""
PRINTLN empty

Error: Number Without Quotes for String

NEW STR code = 12345 // Runtime error! Cannot assign Integer to String
PRINTLN code

// Correct: Put number in quotes to make it a string
NEW STR code = "12345"
PRINTLN code

Error: Boolean Without Quotes for String

NEW STR status = TRUE // Runtime error! Cannot assign Boolean to String
PRINTLN status

// Correct: Put boolean value in quotes
NEW STR status = "TRUE"
PRINTLN status

Error: Using Backslash Incorrectly

NEW STR path = "C:olderile" // May cause issues with  interpretation
// Note: Only 
 and 	 are recognized escape sequences

// Safer: Avoid backslashes or be aware of escape sequences
NEW STR path = "C:/folder/file"
PRINTLN path

Error: Unclosed String Spanning Multiple Statements

NEW STR message = "Hello
PRINTLN "World" // Syntax error! First string never closed
END IF

// Correct: Close each string properly
NEW STR message = "Hello"
PRINTLN "World"