mpe ix command file tips and techniques by jack bailie
Download
Skip this Video
Download Presentation
MPE/iX Command File Tips and Techniques by Jack Bailie

Loading in 2 Seconds...

play fullscreen
1 / 50

MPE/iX Command File Tips and Techniques by Jack Bailie - PowerPoint PPT Presentation


  • 112 Views
  • Uploaded on

MPE/iX Command File Tips and Techniques by Jack Bailie. MPE/iX Command File Tips and Techniques. Style Techniques Examples Parameters Predefined variables Help Functions Errors Debugging. Style. PARM [email protected] LISTFILE !fileset, DISC Meaningful parameter names

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'MPE/iX Command File Tips and Techniques by Jack Bailie' - francois


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
mpe ix command file tips and techniques
MPE/iX Command File Tips and Techniques
  • Style
  • Techniques
  • Examples
  • Parameters
  • Predefined variables
  • Help
  • Functions
  • Errors
  • Debugging
style
Style
  • Meaningful parameter names
  • Keywords and Commands in Upper Case
  • Variables in lower case
  • Blank lines
documentation
Documentation
    • PARM [email protected]
    • COMMENT Title: LISTFILE a file set
    • COMMENT File: L.CMD
    • COMMENT By: J.D. Bailie
    • COMMENT Rev: 3/12/91
    • LISTFILE !fileset, DISC
  • Comments to document command files
  • Save command files in a special group (CMD)
hppath
HPPATH
    • SETVAR HPPATH “CMD.CAPS,CMDD.CAPS,PUB,!!hpgroup,PUB.SYS”
  • HPPATH is a system predefined variable
  • Change the HPPATH in a logon UDC
  • Order for searching :
    • CMD.CAPS
    • CMDD.CAPS
    • Account PUB
    • Current group
    • PUB.SYS
parameters
Parameters
anyparm
ANYPARM
  • May only have one
  • Must be the last parameter
  • Reads everything else, including punctuation
  • May have default value

:L [email protected], DETAIL;PASS

mpe help
MPE HELP

:HELP L

    • USER DEFINED COMMAND FILE: L.CMD.CAPS
    • PARM [email protected]
    • ANYPARM format=DISC
    • LISTFILE !fileset, !format
  • Shows the name of file
  • Lists contents of file
  • Can be very complex
  • Not very useful to a user
  • USER DEFINED COMMAND FILE: L.CMD.CAPS
  • PARM [email protected]
  • ANYPARM format=DISC
  • LISTFILE !fileset, !format
mpe help9
MPE HELP
    • PARM [email protected]
    • ANYPARM format=DISC
    • COMMENT
    • COMMENT L LISTFILE a fileset
    • COMMENT
    • COMMENT Syntax
    • COMMENT :L fileset [,format]
    • COMMENT
    • COMMENT Parameters
    • COMMENT :L fileset [,format]
    • COMMENT
    • COMMENT Parameters
    • COMMENT fileset The file[set] to LISTF; default @
    • COMMENT format The LISTFILE format; default DISC
    • COMMENT
    • LISTFILE !fileset,!format
  • Use COMMENTs to describe command
mpe help10
MPE HELP
  • USER DEFINED COMMAND FILE: L.CMD.CAPS
  • PARM [email protected]
  • ANYPARM format=DISC
  • COMMENT
  • COMMENT L LISTFILE a fileset
  • COMMENT
  • COMMENT Syntax
  • COMMENT :L fileset [,format]
  • COMMENT
  • COMMENT Parameters
  • COMMENT :L fileset [,format]
  • COMMENT
  • COMMENT Parameters
  • COMMENT fileset The file[set] to LISTF; default @
  • COMMENT format The LISTFILE format; default DISC
  • COMMENT
  • LISTFILE !fileset,!format
    • USER DEFINED COMMAND FILE: L.CMD.CAPS
    • PARM [email protected]
    • ANYPARM format=DISC
    • COMMENT
    • COMMENT L LISTFILE a fileset
    • COMMENT
    • COMMENT Syntax
    • COMMENT :L fileset [,format]
    • COMMENT
    • COMMENT Parameters
    • COMMENT :L fileset [,format]
    • COMMENT
    • COMMENT Parameters
    • COMMENT fileset The file[set] to LISTF; default @
    • COMMENT format The LISTFILE format; default DISC
    • COMMENT
    • LISTFILE !fileset,!format
  • Gives user information
  • Still lists all commands
  • Cluttered
echo help
ECHO HELP
    • PARM fileset=?
    • ANYPARM format=DISC
    • IF "!fileset" = "?" THEN
    • ECHO
    • ECHO L LISTFILE a fileset
    • ECHO
    • ECHO Syntax
    • ECHO :L fileset [,format]
    • ECHO
    • ECHO Parameters
    • ECHO fileset The file[set] to LISTF; default @
    • ECHO format The LISTFILE format; default DISC
    • ECHO
    • ELSE
    • LISTFILE !fileset, !format
    • ENDIF Use
  • ECHO command
  • "?" default parameter
echo help12
ECHO HELP

:L

    • L LISTFILE a fileset
    • Syntax
    • :L fileset [,format]
    • Parameters
    • fileset The file[set] to LISTF; default @
    • format The LISTFILE format; default DISC
  • Clearer yet
  • Only information the user needs
  • L LISTFILE a fileset
  • Syntax
  • :L fileset [,format]
  • Parameters
  • fileset The file[set] to LISTF; default @
  • format The LISTFILE format; default DISC
fancier echo help
Fancier ECHO HELP
    • IF "!fileset" = "?" THEN
    • SETVAR S CHR(14)
    • SETVAR B CHR(14)+':'+CHR(15)
    • ECHO
    • ECHO ![S+'R,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,T']
    • ECHO ![B+' L LISTFILE a fileset '+B]
    • ECHO ![S+'@9999999999999999999999999999999999999999999999999[']
    • ECHO ![B+' Syntax '+B]
    • ECHO ![B+' :L fileset [,format] '+B]
    • ECHO ![B+' '+B]
    • ECHO ![B+' Parameters '+B]
    • ECHO ![B+' fileset The file[set] name to LISTF, @ '+B]
    • ECHO ![B+' format The LISTFILE format; DISC '+B]
    • ECHO ![S+'F,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,G']
    • DELETEVAR S,B
    • ELSE
    • LISTFILE !fileset,!format
    • ENDIF
  • Use line drawing characters
fancier echo help14
Fancier ECHO HELP

:L

    • L LISTFILE a fileset
    • Syntax
    • :L fileset [,format]
    • Parameters
    • fileset The file[set] name to LISTF; @
    • format The LISTFILE format; DISC
  • Help information is outlined
  • L LISTFILE a fileset
  • Syntax
  • :L fileset [,format]
  • Parameters
  • fileset The file[set] name to LISTF; @
  • format The LISTFILE format; DISC
variables
VARIABLES
    • PARM file
    • SETVAR _find_creator FINFO('!file','CREATOR')
    • LISTFILE !file, QUALIFY
    • ECHO Creator is !_find_creator
    • DELETEVAR [email protected]
  • Set variables
  • Use unique names for variables
  • Delete variables when done
finfo
FINFO
    • PARM file
    • SETVAR _find_creator FINFO('!file','CREATOR')
    • LISTFILE !file, QUALIFY
    • ECHO Creator is !_find_creator
    • DELETEVAR [email protected]
  • FINFO - find out 44 different things about a file, ie. EOF, Exists, Creator, Various Dates, Size,
  • 1st argument of FINFO is Command file parameter
  • Use option names with FINFO not numbers
prompt for parameters
Prompt for Parameters
    • PARM file=' '
    • IF '!file' = ' ' THEN
    • INPUT _find_file;PROMPT='Enter a file name ';WAIT=60
    • ELSE
    • SETVAR _find_file '!file'
    • ENDIF
    • SETVAR _find_creator FINFO(_find_file,'CREATOR')
    • LISTFILE !_find_file, QUALIFY
    • ECHO Creator is !_find_creator
    • DELETEVAR [email protected]
  • Prompt if parameter is not entered
  • Alternative or in addition to help
  • INPUT with WAIT
  • 1st argument of FINFO is variable
input from a file
INPUT from a file
    • PARM file
    • SETVAR _find_creator FINFO('!file','CREATOR')
    • INPUT _find_line < !file
    • LISTFILE !file, QUALIFY
    • ECHO Creator is !_find_creator
    • ECHO First line is
    • ECHO !_find_line
    • DELETEVAR [email protected]
  • INPUT Command reads only the first line of file
input from message file
INPUT from message file
    • PARM fileset
    • FILE FINDTEMP;MSG
    • LISTFILE !fileset,QUALIFY > *FINDTEMP
    • RESET FINDTEMP
    • WHILE (FINFO('FINDTEMP','EOF') > 0) DO
    • INPUT _find_file < FINDTEMP
    • SETVAR _find_file RTRIM(_find_file)
    • SETVAR _find_creator FINFO(_find_file,'CREATOR')
    • ECHO !_find_file !_find_creator
    • ENDWHILE
    • DELETEVAR [email protected]
    • PURGE FINDTEMP,TEMP
  • Write LISTF to a message file
  • 1st argument of FINFO is the filename
  • Read from message file, one line at a time
  • Trim blanks from right end of input line
style20
Style
    • PARM fileset
    • FILE FINDTEMP;MSG
    • LISTFILE !fileset,QUALIFY > *FINDTEMP
    • RESET FINDTEMP
    • WHILE (FINFO('FINDTEMP','EOF') > 0) DO

INPUT _find_file < FINDTEMP

SETVAR _find_file RTRIM(_find_file)

SETVAR _find_creator FINFO(_find_file,'CREATOR')

ECHO !_find_file !_find_creator

  • Parenthesis around WHILE statement conditions
  • Indent WHILE statement logic
  • DO is optional
  • Clean up after yourself
input from a flat file
INPUT from a Flat File
    • PARM [email protected]
    • LISTFILE !fileset,QUALIFY > FINDTEMP
    • XEQ FINDIT < FINDTEMP
    • PURGE FINDTEMP,TEMP
  • LISTF to a flat file
  • Execute another command file and give it the flat file as input
input from a flat file22
INPUT from a Flat File
    • SETVAR _find_I 1
    • SETVAR _find_eof FINFO('FINDTEMP','EOF')
    • WHILE (_find_i <= _find_eof) DO

SETVAR _find_file INPUT()

SETVAR _find_file RTRIM(_find_file)

SETVAR _find_creator FINFO(_find_file,'CREATOR')

ECHO !_find_file !_find_creator

SETVAR _find_i _find_i + 1

  • Called from another command file
  • No parameters
  • Input from file created by the other command
  • 3 times faster than message files
  • Requires two command files
entry points
Entry Points
    • PARM [email protected]
    • PARM entry=MAIN
    • IF ('!entry' = 'MAIN') THEN
    • LISTFILE !fileset,QUALIFY > FINDTEMP
    • XEQ FIND ENTRY='NOTMAIN' < FINDTEMP
    • PURGE FINDTEMP,TEMP
    • ELSE
    • SETVAR _find_i 1
    • SETVAR _find_eof FINFO('FINDTEMP','EOF')
    • WHILE (_find_i <= _find_eof) DO
    • SETVAR _find_file INPUT()
    • SETVAR _find_file RTRIM(_find_file)
    • SETVAR _find_creator FINFO(_find_file,'CREATOR')
    • ECHO !_find_file !_find_creator
    • SETVAR _find_i _find_i + 1
    • ENDWHILE
    • ENDIF
  • Use an "ENTRY POINT" of the same file
  • Do not need multiple command files
handle error conditions
Handle Error Conditions
    • PARM fileset
    • LISTFILE !fileset,QUALIFY > FINDTEMP
    • IF (FINFO('FINDTEMP','EXISTS')) THEN
    • ...
    • ...
    • ELSE
    • ECHO
    • ECHO No files in the fileset !fileset
    • ECHO
    • ENDIF
  • Handle all possible conditions
  • Test command files
handle error conditions25
Handle Error Conditions
    • PARM fileset
    • ERRCLEAR
    • LISTFILE !fileset,QUALIFY > FINDTEMP
    • IF (HPCIERR = 0) THEN
    • ...
    • ...
    • ELSE
    • ECHO
    • ECHO No files in the fileset !fileset
    • ECHO
    • ENDIF
  • Another way to handle errors
  • ERRCLEAR zeros predefined error variables
fancy error messages
Fancy Error Messages
fancy error messages27
Fancy Error Messages
    • SETVAR ON CHR(27)+"&dB"
    • SETVAR OFF CHR(27)+"[email protected]"
    • ECHO
    • ECHO !on No files in ![UPS("!fileset")] !off
    • ECHO
  • SETVARs easier (shorter) to use and reuse
  • ON Turns on highlighting
  • OFF Turns off highlighting
  • UPS upshifts the input

No files in [email protected]

handle error conditions28
Handle Error Conditions

"NO MATCH FOUND FOR THIS VARIABLE SET"

handle error conditions29
Handle Error Conditions
continuation lines
Continuation Lines
    • PARM what=" "
    • SETVAR _S_WHAT UPS("!what")
    • IF ("!_s_what" = " " &
    • OR "!_s_what" = "S" &
    • OR "!_s_what" = "J") THEN
    • SHOWJOB [email protected]!_s_what
    • ELSEIF ("!_s_what" = "M") THEN
    • SHOWME
    • ELSEIF ("!_s_what" = "O") THEN
    • SPOOLF @;SHOW
    • ENDIF
  • Continuation lines
  • ELSEIF
  • Multiple commands in a single command file
purging files
Purging Files
    • ...
    • PURGE !file
    • ...
  • Error message if file does not exist
purging files32
Purging Files
    • ...
    • SETVAR _find_savemsg HPMSGFENCE
    • SETVAR HPMSGFENCE 2
    • PURGE !file
    • SETVAR HPMSGFENCE _find_savmsg
    • ...
  • No error message if file does not exist
  • Suppresses all error messages
  • If command is aborted it leaves messages off
purging files33
Purging Files
    • ...
    • IF (FINFO("!file","EXISTS")) THEN
    • PURGE !file
    • ENDIF
  • No error message if file does not exist
purging files34
Purging Files
    • ...
    • PURGE !file > $NULL
    • ...
  • Simpler
debugging
Debugging
    • SETVAR HPCMDTRACE TRUE
  • Can set it interactively
  • Lists every command executed
  • Be sure to turn it off
debugging36
Debugging
    • OPTION LIST
  • Add to command file
  • Lists commands executed
  • Use LIST and NOLIST to list selected parts
debugging37
Debugging
    • ...
    • PARM debug=0
    • ...
    • IF (!debug > 0) THEN
    • SETVAR HPCMDTRACE TRUE
    • SETVAR HPMSGFENCE 0
    • ELSE
    • ...
    • IF !debug = 0 THEN
    • PURGE FINDTEMP,TEMP > $NULL
    • ENDIF
  • Add a debug parameter
  • Reference it as a keyword parameter

:FIND [email protected], DEBUG=1

  • Most users do not know it exists
  • Skip file purge in debug mode
documentation38
Documentation
  • DESCR List files in a fileset with FSEDIT Descriptions
  • Syntax
  • :DESCR [fileset] [,find-string]
  • Parameters
  • fileset The HP fileset desired; default @.CMD
  • find-string A string to search for
  • Command file to list descriptions of commands
  • Keyword search feature
documentation39
Documentation

:DESCR [email protected]

    • Files in the fileset [email protected] with FSEDIT Descriptions
    • A - ABORT Command file
    • ACCTINFO - Formatted output of System Accounting Structure
    • ADDR - Print address labels
    • AJ - ABORTJOB
    • AS - Alter spool file PRI to 12 so it will print
    • ...
  • Descriptions are in the file User Label
  • Enter descriptions with FSEDIT or GSCAN
setvar function in while
SETVAR Function in WHILE
    • PARM [email protected]
    • PARM entry=MAIN
    • IF ('!entry' = 'MAIN') THEN
    • LISTFILE !fileset,QUALIFY > FINDTEMP
    • XEQ FIND ENTRY='NOTMAIN' < FINDTEMP
    • PURGE FINDTEMP,TEMP
    • ELSE
    • SETVAR _find_i 0
    • SETVAR _find_eof FINFO('FINDTEMP','EOF')
    • WHILE (SETVAR(_find_i,_find_i+1) <= _find_eof) DO
    • SETVAR _find_file INPUT()
    • SETVAR _find_file RTRIM(_find_file)
    • SETVAR _find_creator FINFO(_find_file,'CREATOR')
    • ECHO !_find_file !_find_creator
    • ENDWHILE
    • ENDIF
  • Use SETVAR Function to increment index within the WHILE statement
finfo function in while
FINFO Function in WHILE
    • PARM [email protected]
    • PARM entry=MAIN
    • IF ('!entry' = 'MAIN') THEN
    • LISTFILE !fileset,QUALIFY > FINDTEMP
    • XEQ FIND ENTRY='NOTMAIN' < FINDTEMP
    • PURGE FINDTEMP,TEMP
    • ELSE
    • SETVAR _find_i 0
    • WHILE SETVAR(_find_i,_find_i+1) <= FINFO('FINDTEMP','EOF')
    • SETVAR _find_file INPUT()
    • SETVAR _find_file RTRIM(_find_file)
    • SETVAR _find_creator FINFO(_find_file,'CREATOR')
    • ECHO !_find_file !_find_creator
    • ENDWHILE
    • ENDIF
  • Use the FINFO in the WHILE statement too
  • Shorter command files
  • Not as easy to follow
  • Has the command file name in it
choose your own name
Choose Your Own Name
    • SETVAR _my_name "!-1"
  • "! 1" gives the last command executed
  • As 1st command in file it gives name of file
choose your own name44
Choose Your Own Name
    • SETVAR _my_name "!-1"
    • SETVAR _my_name UPS(_my_name)
    • IF POS("XEQ ",_my_name) > 0 THEN
    • SETVAR _my_name _my_name "XEQ "
    • ENDIF
    • SETVAR _my_name LTRIM(_my_name)
    • IF POS(" ",_my_name) > 1 THEN
    • SETVAR _my_name LFT(_my_name,POS(" ",_my_name)-1)
    • ENDIF
  • Clean it up to use it
  • Upshift
  • Strip off "XEQ"
  • Strip off leading blanks
  • Strip off trailing parameters
choose your own name45
Choose Your Own Name
    • ...
    • IF ('!entry' = 'MAIN') THEN
    • LISTFILE !fileset,QUALIFY > FINDTEMP
    • XEQ !_my_name, ENTRY="NOTMAIN" < FINDTEMP
    • PURGE FINDTEMP,TEMP
    • ELSE
    • ...
  • Substitute line in FIND command file
  • Use it to call other entry point
  • I'll call it FIND
  • You can call it WHEREIS
choose your own name46
Choose Your Own Name
    • ...
    • ECHO !_my_name LISTF a fileset with Creators name
    • ...
  • Can even use it in help
system message spacing
System Message Spacing
    • CHKDAT.COMMAND.CSLXL
    • SHOWDEV !ldev > CKTEMP
    • ...
    • SETVAR _chkdat_avail STR(_chkdat_ckin,11,1)
    • SETVAR _chkdat_vol STR(_chkdat_ckin,43,1)
    • SETVAR _chkdat_den STR(_chkdat_ckin,57,1)
    • IF _chkdat_avail = "A" AND _chkdat_vol ="(" AND &
    • ( _chkdat_den = "1" OR _chkdat_den = "6") THEN
  • Depends on spacing in SHOWDEV command
  • Changed from 3.1 to 4.0
  • Expect changes with 5.0
documentation48
Documentation
  • PARM fileset="@.CMD", find =" ", entry=MAIN
  • IF "!fileset" = "?" then
  • SETVAR S,CHR(14)
  • SETVAR B CHR(14)+':'+CHR(15)
  • ECHO ![S+'R,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,T'],
  • ECHO ![B+' DESCR List files in a fileset with FSEDIT Description'+B]
  • ECHO ![S+'@9999999999999999999999999999999999999999999999999999999999[']
  • ECHO ![B+' '+B]
  • ECHO ![B+' Syntax '+B]
  • ECHO ![B+' :DESCR fileset [,find_string] '+B]
  • ECHO ![B+' '+B]
  • ECHO ![B+' Parameters '+B]
  • ECHO ![B+' fileset The fileset to look at; default @.CMD '+B]
  • ECHO ![B+' find_string a string to search for '+B]
  • ECHO ![B+' '+B]
  • ECHO ![S+'F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;G']
  • DELETEVAR S,B
  • RETURN
  • ENDIF
  • IF '!entry' = 'MAIN' THEN
  • ERRCLEAR
  • SETVAR _descr_find '!find'
  • LISTFILE !fileset,QUALIFY > DESCRTMP
  • SETVAR _descr_i 0
  • IF HPCIERR = 0 THEN
  • SETVAR _descr_eof FINFO('DESCRTMP','EOF')
  • ECHO Files in the fileset !fileset with FSEDIT Descriptions
  • ECHO
  • XEQ DESCR ENTRY='NOTMAIN' < DESCRTMP
  • ELSE
  • ECHO File !fileset NOT found
  • ENDIF
  • PURGE DESCRTMP,TEMP
  • DELETEVAR [email protected]
  • ELSE
  • Documentation
  • WHILE SETVAR(_descr_i,_descr_i+1) <=_descr_eof DO
  • SETVAR _descr_file INPUT()
  • COMMENT Does it have User Labels Written?
  • IF FINFO(_descr_file,10) > 0 THEN
  • COMMENT Yes, read the fisrt user label
  • SETVAR _descr_file_descr RHT(FINFO(_descr_file,25),64)
  • IF LFT(_descr_file_descr,1) < " " OR &
  • LFT(_descr_file_descr,1) >= "}" THEN
  • SETVAR _descr_file_descr RPT(".",64)
  • ENDIF
  • SETVAR _descr_len 9-POS(".",_descr_file)
  • SETVAR _descr_file_descr RTRIM(_descr_file)+ &
  • RPT(" ",_descr_len)+" "+_descr_file_descr
  • IF _descr_find <> " " THEN
  • IF POS(UPS(_descr_find),UPS(_descr_file_descr)) <> 0 THEN
  • ECHO !_descr_file_descr
  • ENDIF
  • ELSE
  • ECHO !_descr_file_descr
  • ENDIF
  • ENDIF
  • ENDWHILE
  • ENDIF
further research
Further Research
    • @.COMMAND.CSLXL
    • AUTOPAT.PATCHXL.TELESUP
    • TREELIST.PUBXL.TELESUP
    • MKACCT.PUB.SYS
  • Lots of examples
  • Very complex
  • AUTOPAT stores STREAM file data in bottom of file
  • MKACCT uses MKMSGS.MPEXL for messages
references
References
  • MPE XL Commands Reference Manual 32650-90003
  • CI Access and Variables Programmers Guide 32650-90011
  • INTERACT Page Title / Author
  • Nov 88 44 New Features of MPE XL User Interface
  • Thomas Shem & Jeff Vance
  • Sept 89 26 Life of an MPE XL Command
  • Scott Cressler & Jeff Vance
  • Mar 90 96 Programming with MPE XL
  • Heikki Tsakinen
  • Feb 91 83 Advanced CI Programming, The 2.1 Story
  • Scott Cressler, Jeff Vance, Steve Elmer
  • Sept 91 86 MPE XL Command Files
  • Fred Ochs, Jr.
  • Nov 92 26 Creating Command Files
  • Rene Martinez
  • Nov 92 78 What the Manuals Don't Say
  • John Dunlop
ad