Copyright Information

SHARE Inc. is hereby granted a non-exclusive license to copy, reproduce or republish this presentation in whole or Exploiting XEDIT in part for SHARE activities only, and the further right to permit others to copy, reproduce, or republish this presentation in whole or in part, so long as such permission is consistent with SHARE's By -laws, Canons Phil Smith III of Conduct, and other directives of the SHARE Board of Linuxcare, Inc. Directors SHARE 99 August 2002 Session 9201

Introduction: Why XEDIT? XEDIT Power Tools

• Extremely powerful, (almost) infinitely tailorable • Display management • Macros allow subcommand/function extensions • Available on Windows, MS-DOS, OS/2, • Automated text processing • If you have VM, you have XEDIT – You need to at least be able to use the system editor • Editing extensions • Few users fully exploit XEDIT! • XEDIT on other platforms • Note that editors are theology: I like XEDIT, therefore XEDIT is best! • XEDIT for ISPF users

XEDIT Power Tools Line Targets

• Line targets • Programmable keys • One ofXEDIT’s most powerful, least understood features • Chained LOCATEs (PF, PA, Enter) • Many subcommands use line targets • Little known subcommands • Macros • Four types: • Column commands • APIs – Absolute • SOS commands • Selective line editing – Relative • Prefix macros – String • Invocation options – Named • SET and QUERY • Display management • Any of these is valid anywhere line a target is used • 327x keys • Text processing

1 Line Targets (continued) Line Targets (continued)

Absolute: File line number; begins with colon: • Most subcommands start at current line :18 :197 • LOCATE subcommand means “go to this line target” Relative: Offset (# of lines) relative to current line: – Use 5 rather than DOWN 5 5 +11 -8 – Use -11 rather than UP 11 String: Delimited string; may use “NOT” sign, logical • Named lines are often easier, faster than string targets or operators: counting lines /abc/ -/def/ ¬/

/ /x/|/y/ Named: Line name, set via SET POINT or .xxxx prefix subcommand: .a .here

Chained LOCATEs “Programming” via Chained LOCATEs

• LOCATE subcommands may be chained together • Allow primitive programming without macros: • Subcommand may be specified after a LOCATE /:h1./&/Topics/ 1 /:h3./:h2./ • If LOCATE succeeds, subcommand is executed • This command: • If LOCATE fails, subcommand is not executed 1. Locates next line containing :h1. and Topics • Reduces terminal I/O (useful on slow lines!) 2. Moves to next line 3. Changes :h3. to :h2. 4.CHANGE is executed only if LOCATE successful

Chained LOCATEs and REPEAT Obscure Subcommands

• Use chained LOCATEs with REPEAT for complex • XEDIT has almost 100 subcommands operations: /:h1./&/Topics/ 1 c/:h3./:h2./ • Most users only (knowingly) use a handful repeat * • Same as previous, but repeated through rest of file • Even sophisticated users often fail to exploit

2 LPrefix — Logical Prefix COMPress/EXPand — Reformat Columns

• Executes prefix subcommand on current line • COMPRESS compresses files at tab stops – Available even in line-mode XEDIT! • EXPAND un-compresses • Faster than moving cursor to current line, then back to • If tab settings change between COMPRESS and prefix area, typing prefix subcommand, pressing Enter EXPAND, columns are reformatted at new tab stops • Example: move data in columns 20, 30, 40 • Example: delete a section from a file: to columns 20, 40, 60: – LOCATE start of section – SET TABS 1 20 30 40 – Set pending DD prefix subcommand with LP DD – COMP * – TOP end of section – LOCATE – SET TABS 1 20 40 60 – Use another LP DDto delete section – EXP *

SHIFT — Shift Data Columns REPEat — Re -execute to Target

• Moves data left or right • Use with subcommands such as CDELETE which • Data moved, not file view like LEFT, RIGHT, RGTLEFT operate on current line • Deletes/spills data if necessary • Also use with chained LOCATE subcommands • Respects ZONE columns • With no operands, equivalent to NEXT followed by re- typing previous subcommand • REPEAT target performs process until target reached or non-zero return code

Merge — Merge Lines RESET — Cancel Prefix Subcommands

• Overlays groups of lines at specific column position • Prefix subcommands not yet executed are pending • Two line targets specify what to merge, column position • Use QUERY PENDING to locate operand specifies where • RESET avoids having to locate to cancel • Complex rules govern merging blank/non-blank data • Complicated usage, but more efficient than other techniques • Typically used in macros

3 UPPercase/LOWercase — Convert Text CANCEL — QUIT Unmodified Files

• Convert one or more lines to upper/lower case • XEDIT can edit many files at once • Text between ZONE columns is changed • CANCEL quits all unmodified files • Useful after text uppercased by SET CASE UPPER • Changed files remain, QQUIT or FILE individually • Easier than pressing PF3 many times • Safer than typing QQ many times!

COUnt — Count String Occurrences LOAD — Load File into Memory

• Counts string occurrences • Legal only in PROFILE XEDIT • Use to: • Must be first subcommand (causes error later) – Check quote or parenthesis nesting – Executing other subcommands forces implicit LOAD – Determine scope of change before starting • Prefix any CMS commands issued before LOAD with • String to be counted must match exactly ADDRESS COMMAND – Actually uses CHANGE code under the covers • LOAD specifies fileid to be edited, options not honored (like ) – CASE IGNORE CHANGE • Sophisticated PROFILE can default filetype or entire – KEDIT adds second IGNORE for CHANGE, which fileid, resolve partial fileids, force options KEDIT COUNT honors

Column Commands Column Commands

• Column pointer points to a column position • CLOCATE sets column pointer to column target • Setting shown at top of screen, on SCALE line • CDELETE deletes columns to column target • Query via QUERY/TRANSFER/EXTRACT COLUMN • SET STREAM ON lets string targets span lines • Column commands set/use column pointer • CFIRST/CLAST set column pointer to first/second – Some use column target operand: ZONE column • Subset of line target varieties: absolute, relative, string • CINSERT, CREPLACE, COVERLAY insert, replace, (including logical NOT) overlay string at column pointer – No logical AND, logical OR, or names – Combine with REPEAT for multi-line operation – Often avoids need for single-purpose • CAPPEND macro (sort of) does “column append”

4 SOS Commands SOS Commands

• SOS: Screen Operation Simulation • Operands include: • Legacy of EDGAR, early full-screen CMS editor – Field tabs • SOS functions use screen cursor position – Tab to command line (backwards or forwards) • Simulates terminal actions (keystrokes) – Save/restore cursor position – “Press” a PFkey • Designed for use from macros or PF keys – Add/remove trailing nulls on current line – Add, delete file line at cursor position • Cannot “press” PAkeys, Enter key • No SOS TEXT (text insertion) • Limited function, but still useful

XEDIT Command Options Invocation Options

• WIDTH • NAMETYPE, BFSLINE – Sets maximum LRECL settable by SET LRECL – Byte File System (BFS—Unix file system) support – Required because of static internal buffers – Read BFS documentation to learn concepts – WIDTH, LRECL, TRUNC, and ZONE all interact — – Can also XEDIT files in BFS directly, without first ing BFS directory read about, experiment ACCESS • NOLOCK • MEMBER membername – Avoids acquiring SFS/BFS lock on entry – XEDITsa MACLIB member – Use for Read/Only editing to avoid conflicts – Changed member replaced in MACLIB on FILE/SAVE

Options Useful for Applications More Invocation Options

• NOMSG • NOSCREEN – Suppresses XEDIT messages – Forces “line-mode” – Avoids SET MSGMODE OFF in applications – Use to test line-mode operation • NOCLEAR • PROFILE profilename or NOPROFILE – From display-management applications, avoids screen – Specifies inital macro filename flash on XEDIT entry – Bypasses PROFILE, avoids surprises – Causes MORE... if in line-mode

5 Update Mode: Create Source Updates Update Mode: Create Source Updates

• Allows creating discrete updates to source files • UNTIL updatename applies updates only through • Changes made while editing are automatically saved as updatename, showing code image before a specific updates update • Supports source files up to LRECL 255 • SIDcode string creates Service IDentifier codes in columns 64-71 of updates • CTL ctlfn applies updates using CMS multi-level update scheme (CNTRL and AUX files) • Merge merges all updates into single update • The only way to do product maintenance! • Seq8/NOSeq8 control whether 5- or 8-character sequence numbers are expected on source • Incr n controls minimum update line increment

SET and QUERY Customizing the Screen

• 80+ SET options provide extensive tailorability • Many SET commands change screen appearance • Some poor defaults (SCALE, STAY, MSGLINE) (CMDLINE, PREFIX, SCALE, etc.) • Things to learn about: • Customize screen to yourtaste – QUERY options which have no matching SET – Experiment with SET PREFIX NULLS, (RING, NBFile, LENGTH, TARGET, LASTLORC) SET NUMBER ON, SET SHADOW OFF – CASE IGNORE • Consider: – Complex synonyms, LINEND option – SET MSGLINE ON 2 23 OVERLAY or – Uses for SET NULLS ON, SET FULLREAD ON – SET MSGLINE ON -1 24 OVERLAY with SET CMDLINE TOP • STATUS macro displays/saves current settings

Customizing the Screen 327x Keys

• Some screen features (title line, TOF/EOF lines, etc.) • Few users fully exploit 327x architecture cannot be changed directly • If available, use Entry Assist (see GA23-0119) • XEDIT builds many of these from message repository • Use hardware (field) tab keys • Customize with user override for the repository! • Use Return key – Add WIDTH, last subcommand to top line of screen • Use Field Mark key—tab character – Add userid to bottom right • Use Erase EOF key—restores changed line – Add end/top of range info to top/end of range lines (Erase EOF + single blank clears line) • Understand and use Clear key—restores screen

6 Programmable Keys Programmable Keys

• PFkeys, PAkeys, Enter key are all programmable • Use key to switch among sets of PFkeys • Most users don’t set keys • Consider setting Enter key: • Consider whether defaults are effective for you: – Default setting: CURSOR CMDLINE PRIORITY 30 – Do you use all PFkeys regularly? – Meaningless when cursor on command line – Do you have 24 PFkeys? – PF12 (CURSOR HOME) performs same function – Are there commands you type frequently? • Instead, Enter might do: – Do you have SET NULLS ON in your PROFILE? – NEXT when on command line (If so, default PA2 is wasted) – Tab cursor to next word when in file • Understand BEFORE/AFTER/ONLY/IGNORE operands • See AUTONEXT XEDIT on the Web page

Macros Easy, Useful Macro Examples

• XEDIT macros invoked like subcommands • US — Uppercase string on current line – Some native subcommands are actually implemented • LS — Lowercase string on current line as macros (ALL, JOIN…) • LSERIAL — Locate serial number in UPDATE mode • If you dislike XEDIT behavior, change it with a macro! • UPFIRST — Uppercase first letter of each word – Can replace native subcommands • ETW — (Edit-To-Width) — Reformat paragraphs • Use ad hoc macros for special editing tasks • RAC (Right-Align-Comment) — Right-justify comments in • Beware non-alphabetic macro filenames: and C programs – THING2 invokes THING with parameter 2 • QXT — Perform EXTRACT, display output – Can use MACRO THING2 instead – Useful when writing macros – Useful to avoid accidental invocation

Macro Tips An XEDIT API: DMSXFLxx

• EXTract — Put information into macro variables • DMSXFLxx manipulate in -memory files – Often returns information unavailable by other means • Call DMSXFLxx from assembler programs to: – Check existence of a file — Save/restore most settings • PREServe/Restore – Read from a file • CURsor — Position cursor on screen – Write to a file • COMMAND — Force subcommand execution – Locate a specific line • Used extensively by FILELIST, RECEIVE, others • MACRO — Force macro execution • Similar to CMS file I/O interface • MSG/EMSG/CMSG — Display messages • Documented in CMS Application Development Guide for Assembler, and in DMSXFL comments

7 Another API: DMSXMS Selective Line Editing

• DMSXMS MODULE performs SORT function • Most users know of the ALL macro – SORT actually only front-end macro for DMSXMS – Uses SET SELECT/DISPLAY/SCOPE • Use similar macro/MODULE combination for other high- • More macros improve selective line editing: performance XEDIT extensions TALL — After ALL, toggle between selective/full display – Uses CMS SUBCOM interface TN, TU — Go to next/previous selected line after TALL – Examples: DMSXDB and DMSXUQ to delete ALSO — After ALL, add to selection (e.g., after changing blank/duplicate lines ZONE) EXCLUDE — After ALL, remove lines from selection ALLSIZE — Displays count of lines in current selection

Prefix Macros Useful Prefix Macro Examples

• Most users use prefix subcommands: C, F/B, etc. • G — Embed (get) lines from another file – Many are unaware of prefix macros • R — Recover deleted lines • SI, >, < prefix subcommands are prefix macros • U — Convert lines to uppercase • SET PREFIX SYNONYM maps prefix subcommands • L — Convert lines to lowercase to macros • ETW — (Edit-To-Width)—Reformat paragraphs • Unrecognized prefix subcommands invoke macros • ? — Set current line and move cursor to command line • Add prefix subcommands using prefix macros • Any frequent task that requires moving cursor to • Prefix macros receive special parameter list command line is a candidate for a prefix macro! – Can support both command line and prefix invocation

Display Management Display Management: READ

• XEDIT can be used for display management • READ subcommand in macros traps (stacks) user input: – Not a true screen manager keys, screen changes, etc. – Best for small, simple applications – Useful for prompting from macros – Advantages: portability, price • READ ALL traps input to fields in RESERVED lines • SET RESERVED defines static lines on screen • READ NOCHANGE reflects screen changes to macro without changing file • SET CTLCHAR allows user-defined input fields, highlighting, etc. in RESERVED lines • READ ALL NOCHANGE interprets CTLCHARs in file lines, not just RESERVED lines – Allows use of file as display template

8 XEDIT Text Processing XEDIT Text Processing

• Typical example: alter file under program control • Use READ to prompt user – PROFILE option passes control to application macro • Indicate result via SAVE followed by QUIT rc – NOMSG option suppresses XEDIT messages • Exploit in-memory sort—faster than CMS SORT – Pass macro arguments after closing parenthesis: • Clean up after errors—avoid leaving user in unexpected XEDIT session! 'XEDIT A FILE (NOMSG PROFILE XYZ)' args • Perhaps use “skeleton” file as starting point: – Alter default values with CHANGE – Insert, delete lines as appropriate

Example: Hygiene XEDIT-based File Search Utility

• Common problem: search CMS files for a string • Prefix all subcommands in macros with COMMAND to • Many public-domain tools, vendor products exist force subcommand execution • Free solution: XEDIT, using macro as PROFILE • Prefix all macro invocations with MACRO – XFINDtakes search string, file specification • Avoid short names or synonyms for macros which may – Searches file(s), lists occurrences be destructive if invoked inadvertently • Crude but usable—and less than 50 lines of code! • Avoid synonyms to override native subcommands • Handles PACKed files, unlike most such tools – Many macros don’t use COMMAND • Can be extended with controls for column, case, ARBCHAR, output, etc…

Hygiene XEDIT on Other Platforms

• Always specify SET — never rely on implicit SET • KEDIT — Mansfield Software Group • Use SET LINEND OFF in macros that execute user – XEDIT for Windows, MS-DOS, OS/2 input or file data to avoid surprises – Very similar to CMS XEDIT • Consider SET AUTOSAVE if system unstable – Extensions exploit workstation capabilities • Save file when you stop to think — even stable systems – Mature, popular product can fail! – Macros use Rexx or KEXX (built-in REXX subset) – Windows version beautifully merges Windows and 3270 paradigms: intuitive, configurable — usable! – www.kedit.com offers many powerful macros

9 XEDIT on Other Platforms XEDIT for ISPF Users

• THE — The Hessling Editor • ISPF users have a particular challenge: – Freeware UNIX editor by Mark Hessling – XEDIT is too close: they’re constantly confused – Modeled on XEDIT, with KEDIT DOS influences – Some of the confusion can be destructive – Uses Rexx macros – Customization through macros can help a lot! – Includes ISPF compatibility features • Example: ISPF Line commands – Check out www.lightlink.com/hessling/ – XEDIT calls them Prefix subcommands • uni-Xedit — The Workstation Group – Use synonyms to change behavior – XEDIT for UNIX – uni-Rexx, uni-SPF also available • ISPF users can make XEDIT tolerable! – Check out www.wrkgrp.com

ISPF “Line” Commands ISPF Primary Commands

• B undefined in XEDIT, means Before in ISPF • “Regular” ISPF commands are often similar to XEDIT – Synonym to P in XEDIT subcommands: • R undefined in XEDIT, means Repeat in ISPF – CHANGE syntax is different – Synonym to “ (duplicate) in XEDIT – BOUNDS is like XEDIT SET ZONE • A means Add in XEDIT, After in ISPF – EXCLUDE is similar to ALL, but syntax different – Synonym to F in XEDIT – Commands like DELETE, SORT have operands • Some others much harder to simulate, but can at least related to excluded lines come close – FIND is like XEDIT string LOCATE – LOCATE is like subset of XEDIT LOCATE – XEDIT does not support UNDO at all

Conclusions Contact Info

• XEDIT is powerful, rich in function • Inexperienced users can add skills easily Phil Smith III • Learning more about it increases productivity • Clones enable skills transfer to other platforms • Read the manual! 703.568.6662 • Note unfamiliar facilities, try them [email protected] • Experimenting is fun and easy! www.linuxcare.com

ØWhat XEDIT tips can you share?

10