Learn Natural-scripting - 10 Code Examples & CST Typing Practice Test
Natural Scripting refers to the use of the Natural programming language (from Software AG) to create applications, automate business logic, and interact with databases, especially within mainframe and enterprise environments.
View all 10 Natural-scripting code examples →
Learn NATURAL-SCRIPTING with Real Code Examples
Updated Nov 27, 2025
Code Sample Descriptions
Simple Natural Program
DEFINE DATA LOCAL
END-DEFINE
WRITE 'Hello, Natural World!'
END
Print a greeting message.
Natural Loop Example
DEFINE DATA LOCAL
1 I (N)
END-DEFINE
FOR I = 1 TO 5
WRITE 'Number: ' I
END-FOR
END
Loop through numbers 1 to 5 and display them.
Natural Database Read Example
DEFINE DATA LOCAL
1 CUSTOMER-VIEW VIEW OF CUSTOMER
2 CUST-ID
2 CUST-NAME
END-DEFINE
FIND CUSTOMER-VIEW BY CUST-ID = 10001
DISPLAY CUST-NAME
END-FIND
END
Read records from an Adabas file and display a field.
Natural Conditional Example
DEFINE DATA LOCAL
1 AGE (N)
END-DEFINE
READ 'Enter age: ' AGE
IF AGE >= 18
WRITE 'Adult'
ELSE
WRITE 'Minor'
END-IF
END
Check a value and print messages based on condition.
Natural Input and Display Example
DEFINE DATA LOCAL
1 NAME (A20)
END-DEFINE
INPUT 'Enter your name: ' NAME
WRITE 'Welcome, ' NAME
END
Prompt user for name and display a welcome message.
Natural Arithmetic Example
DEFINE DATA LOCAL
1 A (N)
1 B (N)
1 SUM (N)
1 PROD (N)
END-DEFINE
INPUT 'Enter A: ' A
INPUT 'Enter B: ' B
SUM := A + B
PROD := A * B
WRITE 'Sum: ' SUM
WRITE 'Product: ' PROD
END
Compute sum and product of two numbers.
Natural Loop with Database
DEFINE DATA LOCAL
1 CUSTOMER-VIEW VIEW OF CUSTOMER
2 CUST-ID
2 CUST-NAME
END-DEFINE
FIND CUSTOMER-VIEW WITH CUST-ID NE 0
DISPLAY CUST-ID CUST-NAME
END-FIND
END
Loop through all customer records and display names.
Natural Subroutine Example
DEFINE DATA LOCAL
1 USERNAME (A20)
END-DEFINE
INPUT 'Enter your name: ' USERNAME
PERFORM GREET(USERNAME)
END
DEFINE SUBROUTINE GREET(NAME)
WRITE 'Hello, ' NAME
END-SUBROUTINE
Call a subroutine to greet a user.
Natural String Manipulation
DEFINE DATA LOCAL
1 INPUT-STR (A20)
1 UPPER-STR (A20)
END-DEFINE
INPUT 'Enter string: ' INPUT-STR
UPPER-STR := CONVERT(INPUT-STR, 'UPPER')
WRITE 'Uppercase: ' UPPER-STR
END
Convert input string to uppercase and display.
Natural Exit Condition in Loop
DEFINE DATA LOCAL
1 NUM (N)
END-DEFINE
DO
INPUT 'Enter number (0 to quit): ' NUM
IF NUM = 0
EXIT
ENDIF
WRITE 'You entered: ' NUM
END-DO
END
Loop until user enters 0.
Frequently Asked Questions about Natural-scripting
What is Natural-scripting?
Natural Scripting refers to the use of the Natural programming language (from Software AG) to create applications, automate business logic, and interact with databases, especially within mainframe and enterprise environments.
What are the primary use cases for Natural-scripting?
Automating enterprise business processes. Building database-centric applications on mainframes. Creating batch jobs for reporting and transaction processing. Rapid prototyping of business logic applications. Integrating with legacy systems and middleware
What are the strengths of Natural-scripting?
Rapid development for business applications. Readable and maintainable syntax. Efficient database operations for large datasets. Mature, stable language with decades of use. Compatible with legacy mainframe and server systems
What are the limitations of Natural-scripting?
Proprietary, mainly tied to Software AG ecosystem. Limited modern IDE and tooling support compared to contemporary languages. Steep learning curve for newcomers unfamiliar with 4GLs. Less community support than mainstream languages. Primarily suited for database-centric applications, not general-purpose programming
How can I practice Natural-scripting typing speed?
CodeSpeedTest offers 10+ real Natural-scripting code examples for typing practice. You can measure your WPM, track accuracy, and improve your coding speed with guided exercises.