Pascal Script Quick Guide for JavaScript Programmers
This page provides a fast introduction to the Pascal Script language for people familiar with JavaScript.It explains the essential syntax and concepts you need to start writing and reading Pascal code.
Pascal Script is a procedural language with a strong type system and block structure.
It uses `begin ... end` blocks, requires variable declarations, and emphasizes clarity and explicit code.
General Structure
- Statements end with a semicolon (`;`).
- Blocks of code use `begin ... end` instead of `{ ... }`.
- Programs, procedures, and functions must declare all variables before use.
Basic Types
- Integer: Whole numbers (like
int
in JS, but strongly typed). - Boolean:
True
orFalse
(nottrue
/false
lowercase). - String: Unicode text.
- Double: Floating-point numbers.
Variables
- Variables must be declared before use, specifying their type.
- Use the
var
keyword before a block to declare variables.
var
Count: Integer;
Name: String;
Control Structures
- If statements:
if Count > 0 then begin ... end;
- For loops:
for i := 1 to 10 do begin ... end;
- While and Repeat loops available.
Functions and Procedures
- Procedure: Subroutine without return value.
- Function: Returns a value, specify type after colon.
procedure SayHello(Name: String);
begin
// code here
end;
function Add(A, B: Integer): Integer;
begin
Result := A + B;
end;
Comments
- Single-line:
// This is a comment
- Multi-line:
{ This is a block comment }
Key Differences from JavaScript
- No implicit variable creation – all must be declared.
- Types are checked at compile time.
- Blocks use
begin ... end
(not curly braces). - Assignment uses
:=
(not=
). - Equality test uses
=
(not==
).
Sample Program Structure
program Example;
var
Message: String;
begin
Message := 'Hello, Pascal Script!';
ShowMessage(Message);
end.
Essential Built-in Procedures
- ShowMessage: Display a dialog box with a message.
- InputBox: Get input from the user.
Tips
- Indent code for clarity (recommended, not required).
- Use descriptive names for variables and routines.
- Remember Pascal is case-insensitive (
MyVar
is the same asmyvar
).
Pascal Script – Quick Guide for JavaScript Developers
This guide covers the core syntax and principles of base Pascal Script as used in the Hyper Scripting System.It is intended for programmers familiar with JavaScript or similar languages.
General Syntax Principles
-
Each statement ends with a semicolon ;.
-
Assignment to variables uses the := symbol.
-
System procedures such as init, After_Showing, and After_Edit must be placed after your custom procedures and functions.
-
Line breaks do not affect code execution.
Symbols and Their Meaning
Symbol | Description |
---|---|
; | End of statement, procedure, or function. |
:= | Assigns a value to a variable. |
' ' | String values use single quotes. |
= | Comparison for equality in conditions (IF). |
< , > , <= , >= , <> | Comparison operators: less, greater, less or equal, greater or equal, not equal. |
// , { } | Comments: // for single line, { } for multi-line. |
Operators
Operator | Description |
---|---|
+ | Addition for numbers and concatenation for strings. |
- , * , / | Subtraction, multiplication, division. |
DIV | Integer division (no remainder). |
MOD | Remainder after integer division. |
Variables
-
Variables are declared using the keyword VAR, once at the start of each procedure or function.
-
Variables must be declared right after the procedure/function name.
-
Each variable declaration must include its name and type.
-
Assignment must be done in a separate statement, not during declaration.
Supported Data Types
Type | Min | Max | Description |
---|---|---|---|
Integers | |||
Integer | -2147483648 | 2147483647 | 32-bit signed integer. |
Int64 / LongInt | -9223372036854775808 | 9223372036854775807 | 64-bit signed integer. |
Word | 0 | 65535 | 16-bit unsigned integer. |
Cardinal | 0 | 4294967295 | 32-bit unsigned integer. |
LongWord | 0 | 4294967295 or 18446744073709551615 | Unsigned, platform-dependent. |
Decimals | |||
Double | 2.23e-308 | 1.79e+308 | Double-precision floating point, up to 15 decimals. |
Extended | 2.23e-308 or 3.37e-4932 | 1.79e+308 or 1.18e+4932 | Long double. Not recommended for cross-platform code. |
Currency | -922337203685477.5808 | 922337203685477.5807 | Decimal with up to 4 digits after decimal point. |
Text / Booleans | |||
String | Unicode string, unlimited length. | ||
Char | 0 | 16 | Single Unicode character (16-bit). |
Boolean | 0 | 16 | TRUE/FALSE flag. |
Variant | Generic type, can store any value or object. |
String Concatenation
Strings are surrounded by single quotes.Concatenation is performed with the + operator.
Procedures and Functions
-
A procedure does not return a value.
-
A function returns a value with the result keyword.
-
Use the Exit statement to stop execution inside procedures or functions.
Return type for functions must be specified.
Conditional Statements – IF
-
Single-statement IF: place the statement on the same or next line.
-
Multiple statements: use Begin ... End block.
-
No semicolon before Else or Else If.
Short-form IF (Ternary)
Pascal Script allows a short-form IF for single-statement assignments.This is similar to JavaScript's ternary operator but uses boolean expressions.
Only valid for direct True/False assignments.
CASE Statements
The case statement is used for multi-branch conditions.Works for numbers and text.
Text comparison is case-sensitive.
Loops
-
Declare the loop variable at the top of the procedure/function.
-
Continue skips to the next iteration.
-
Break exits the loop.
WHILE loops repeat while a condition is true.
REPEAT ... UNTIL loops always run at least once.
Exception Handling: Try ... Except
Use Try ... Except ... End for error handling in code that may fail.No need to use Begin ... End inside the blocks.
Finally block is always executed.
Nested Try blocks are allowed.
Arrays
-
Declare arrays at the top of the procedure/function.
-
Dynamic arrays require explicit sizing with SetLength.
-
Array indexing starts at 1 for static arrays.