/* rexx */ /*-------------------------------------------------------------------*/ /* */ /* REXX Exec : VALIDMEM */ /* */ /* Description : Validate a passed member name */ /* */ /* Created on : 14 Apr 2020 */ /* Created by : KEVIN FERGUSON */ /* : Userid(MIT001) */ /* : using ABBYDALE.DEVL.REXX(VALIDMEM) */ /* */ /* Called by : */ /* */ /* Calls : */ /* */ /* Change Activity : */ /* */ /* ©Copyright of Abbydale Systems LLC. */ /* */ /*-------------------------------------------------------------------*/ pee = '' signal on halt /* attention key */ valid = 8 /* Set default return code */ badchar = "" forbid = '*%!&¬}{[_]:,;()' /* characters forbidden in member name */ forbid2 = '1234567890' /* Invalid first characters */ parse upper arg testit msg testit = strip(testit,b,"'") if testit = "?" then do call disp_help exit(4) end if testit = "" then do do while testit = "" Say 'Enter member to validate. (use to terminate)' parse upper pull testit if testit = '' then exit if LENGTH(testit) > 8 then do testit = "" say 'Invalid member name length. Re-enter' end end end if LENGTH(testit) > 8 then do mess = 'Invalid member name length' signal leaveit end x = 1 if POS(SUBSTR(testit,1,1),forbid2) > 0 then do badchar = SUBSTR(testit,1,1) badness: mess = ' - Invalid character in name ' signal leaveit end do until x = LENGTH(forbid) if POS(SUBSTR(forbid,x,1),testit) > 0 then do badchar = SUBSTR(forbid,x,1) signal badness end x = x + 1 end mess = ' - Valid' valid = 0 leaveit: if msg <> "" then do say testit||mess|| badchar end exit(valid) /*-------------------------------------------------------------------*/ /* disp_help procedure */ /*-------------------------------------------------------------------*/ disp_help: procedure pgm_name=sysvar("sysicmd") if pgm_name="" then pgm_name="VALIDMEM" say left(pgm_name,8) "- a REXX exec that will validate a member name." say "" say "Usage: VALIDMEM member msgs | ? " say "" say " member - Member name to be validated." say " msgs - (optional) if coded all messages will be displayed." say " ? - generates this information." say "" say " Return Codes : 0 - valid member name." say " 4 - Help displyed" say " 12 - Invalid member name." Say " 16 - Critical error" return /*-------------------------------------------------------------------*/ /* trap NOVALUE condition */ /*-------------------------------------------------------------------*/ novalue: say 'NOVALUE entered from line' sigl say condition("D") say 'The instruction is suppressed' address "TSO" "delstack" exit(16) /*-------------------------------------------------------------------*/ /* trap HALT condition */ /*-------------------------------------------------------------------*/ halt: say 'HALT acknowledged in line' sigl say 'Cleanup processing in progress' address "TSO" "delstack" exit(16) /*-------------------------------------------------------------------*/ /* End of VALIDMEM */ /*-------------------------------------------------------------------*/