1. Home
  2. /
  3. Rpg
  4. /
  5. Counter and Theme Toggle

Counter and Theme Toggle - Rpg Typing CST Test

Loading…

Counter and Theme Toggle — Rpg Code

Demonstrates a simple counter with theme toggling using RPG variables and WRITE statements.

D COUNT           S              5I 0 INZ(0)
D ISDARK          S              1A   INZ('0')

C     *ENTRY    PLIST
C               PARM                    

C     UPDATEUI  BEGSR
C               WRITE 'Counter:' COUNT
C               IF ISDARK = '1'
C                 WRITE 'Theme: Dark'
C               ELSE
C                 WRITE 'Theme: Light'
C               ENDIF
C               ENDSR

C     INCREMENT  BEGSR
C               COUNT += 1
C               PERFORM UPDATEUI
C               ENDSR

C     DECREMENT  BEGSR
C               COUNT -= 1
C               PERFORM UPDATEUI
C               ENDSR

C     RESET      BEGSR
C               COUNT = 0
C               PERFORM UPDATEUI
C               ENDSR

C     TOGGLETHEME BEGSR
C               IF ISDARK = '0'
C                 ISDARK = '1'
C               ELSE
C                 ISDARK = '0'
C               ENDIF
C               PERFORM UPDATEUI
C               ENDSR

C     *MAIN      BEGSR
C               PERFORM UPDATEUI
C               PERFORM INCREMENT
C               PERFORM INCREMENT
C               PERFORM TOGGLETHEME
C               PERFORM DECREMENT
C               PERFORM RESET
C               ENDSR

Rpg Language Guide

RPG (Report Program Generator) is a high-level programming language primarily used for business applications, especially on IBM midrange systems like AS/400 and IBM i, for generating reports and handling data processing tasks.

Primary Use Cases

  • ▸Generating business reports
  • ▸Batch data processing
  • ▸Financial calculations
  • ▸Inventory and logistics management
  • ▸Legacy enterprise application maintenance

Notable Features

  • ▸Column-based fixed format (original RPG)
  • ▸Integrated file handling for database records
  • ▸Procedural and calculation-oriented
  • ▸Evolved into free-format RPG IV
  • ▸Strong IBM i ecosystem support

Origin & Creator

Developed in 1959 by IBM, originally for IBM 1401 systems; evolved into RPG IV on IBM i platforms.

Industrial Note

RPG powers many legacy enterprise applications in banks, manufacturing, and government systems, often running critical business processes on IBM i (AS/400) systems.

More Rpg Typing Exercises

RPG Fibonacci SequenceRPG Factorial CalculatorRPG Prime CheckerRPG Sum of ArrayRPG Reverse StringRPG Multiplication TableRPG Temperature ConverterRPG Simple Alarm SimulationRPG Random Walk Simulation

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher