The ISPF Edit services API (ISREDIT) provides programmatic access to ISPF editor functions, enabling programs to perform editor operations automatically. REXX scripts can use ISREDIT to open datasets, modify content, search and replace text, and save changes without user interaction. Understanding the Edit services API helps you automate editor operations and build powerful editing tools. This tutorial covers ISREDIT functions, programmatic editor access, REXX integration, and best practices.
ISREDIT enables automation of editor tasks that would otherwise require manual interaction. By programmatically accessing the editor, you can create scripts that modify datasets, perform batch edits, and automate repetitive editing tasks. Learning ISREDIT opens up powerful automation capabilities. This tutorial provides practical guidance for using the Edit services API.
ISREDIT is the API for programmatic editor access.
ISREDIT is:
ISREDIT provides:
ISREDIT is used from REXX scripts.
To use ISREDIT:
Example:
12345678910/*REXX*/ address isredit 'DATASET('"'"dsn"'"')' if rc <> 0 then do say 'Error opening dataset' exit 8 end /* Perform edit operations */ 'SAVE' exit 0
To open a dataset:
123456/*REXX*/ parse arg dsn address isredit 'DATASET('"'"dsn"'"')' if rc <> 0 then exit 8 exit 0
This opens the dataset for programmatic editing.
To open a PDS member:
123456/*REXX*/ parse arg dsn member address isredit 'DATASET('"'"dsn"("member")"'"')' if rc <> 0 then exit 8 exit 0
ISREDIT provides many editor functions.
Line manipulation functions:
Example adding a line:
1234567/*REXX*/ address isredit 'DATASET('"'"dsn"'"')' '(LINE) AFTER 10 "NEW LINE TEXT"' if rc <> 0 then say 'Error adding line' 'SAVE' exit 0
Search and replace functions:
Example search and replace:
1234567/*REXX*/ address isredit 'DATASET('"'"dsn"'"')' '(CHANGE) "OLD TEXT" "NEW TEXT" ALL' if rc <> 0 then say 'Error in replace' 'SAVE' exit 0
Navigation functions:
Functions to read line content:
Common patterns for ISREDIT usage.
Pattern for batch editing:
12345678910/*REXX*/ parse arg dsn address isredit 'DATASET('"'"dsn"'"')' if rc <> 0 then exit 8 /* Perform edits */ '(LINE) AFTER 1 "HEADER LINE"' '(CHANGE) "OLD" "NEW" ALL' 'SAVE' exit 0
Process dataset line by line:
123456789101112/*REXX*/ parse arg dsn address isredit 'DATASET('"'"dsn"'"')' if rc <> 0 then exit 8 do i = 1 to 100 '(LINE) i .ZCSR' if rc <> 0 then leave /* Process line content */ end 'SAVE' exit 0
Edit based on conditions:
123456789101112/*REXX*/ address isredit 'DATASET('"'"dsn"'"')' do i = 1 to 100 '(LINE) i .ZCSR' if rc <> 0 then leave if pos('PATTERN',.zcsr) > 0 then do '(LINE) i "REPLACED LINE"' end end 'SAVE' exit 0
Following best practices improves ISREDIT usage:
Think of ISREDIT like a robot that can edit documents for you:
So ISREDIT is like having a robot assistant that can edit documents automatically by following your programming instructions!
Complete these exercises to reinforce your ISREDIT skills:
Practice basics: write REXX script that opens dataset with ISREDIT, check return codes, understand ISREDIT basics, and learn dataset opening. Master basic ISREDIT usage.
Practice lines: write REXX script that adds lines to dataset, use LINE functions, test line addition, and learn line operations. Master line operations.
Practice replace: write REXX script that performs search and replace, use CHANGE function, test replacements, and learn search and replace. Master search and replace.
Practice processing: write REXX script that processes dataset line by line, read lines, modify based on content, and learn line processing. Master line processing.
Practice complete: write REXX script that performs complete editing automation, combine multiple ISREDIT operations, test full automation, and learn complete automation. Master ISREDIT automation.
1. What address is used for ISREDIT?
2. What ISREDIT function opens a dataset?
3. Can ISREDIT modify datasets programmatically?
4. What ISREDIT function searches for text?
5. What ISREDIT function saves changes?