Repository navigation
Language Basics
Daniel Long edited this page Sep 29, 2026
·
3 revisions
All programs begin with **FREE to indicate free-format RPG IV:
**FREE
// Declarations go here
DCL-S name VARCHAR(40);
// Executable statements
name = 'World';
DSPLY ('Hello, ' + %TRIM(name) + '!');
*INLR = *ON;
RETURN;DSPLY follows IBM i's rules. An expression must be in parentheses —
DSPLY ('Total: ' + x);, not DSPLY 'Total: ' + x; — and the message may be
at most 52 characters, judged at compile time from the declared lengths of
what it shows ('Hello, ' + a VARCHAR(40) + '!' is 48). To show something
longer, assign it to a VARCHAR(52) work field and display that; the
assignment keeps the first 52 characters.
// Single-line commentStatements end with a semicolon (;), one statement to a line: after the
semicolon only a comment may follow (IBM: RNF5508). A statement may run over
several lines.
total = 0; // fine: a comment after the semicolon
count = 0; i = 1; // rejected: two statements on one line- Installation
- Quick Start
- CLI Reference
- Language Basics
- Data Types
- Variables and Constants
- Data Structures
- Arrays
- Varying-Dimension Arrays
- Control Flow
- Procedures
- Procedure Overloading
- Built-In Functions
- Error Handling
- Operation Extenders
- Enumerations
- Program Status Data Structure
- Data Areas
- SND-MSG
- Embedded SQL
- Record-Level Access
- Display Files (WORKSTN)
- Program-Described Files (I-Specs and O-Specs)
- DATA-INTO and DATA-GEN
- XML-INTO
- Fixed-Format Source
- Database Connections
- Multi-Module Programs
- Environment Variables
- Testing
- Complete Example: Employee Report
- IBM i Conformance Results
- IBM i Execution Results