TS/MP 2.5 Management Programming Manual

Example 4 Adding or Altering a Server
?TACL MACRO
#FRAME
[#PUSH X^ Y^ == variables for zspi and zpwy ddls
read^err io^err reply request == #requester variables
pmon^name == pathmon name parameter
result^1 j^1 == contains result of ssget operation
result^2 j^2 == contains # of tokens ssget returned
result^3 == contains ssget pathway error
res^cmd == contains command from response buffer
res^obj == contains object type from response
res^err == contains error from response
res^name == contains object name in error
cont^true == specifies continuation selected
svr^name == paramed server name.
command^ == paramed command type.
] == end #push
== Make sure the PATHMON name is supplied and check for the $ character.
[#DEF r_valid_pmonname ROUTINE |BODY|
[#IF [#EMPTY %1%] |THEN|
#OUTPUT You must enter the Pathmon name $...
#RESULT 0
|ELSE|
#SET pmon^name %1%
[#IF [#MATCH [#CHARFIND pmon^name 1 $] 1] |THEN|
#RESULT -1
|ELSE|
#RESULT 0
#OUTPUT The Pathmon name must start with a "$"......
] == end if match charfind pmon^name 1 $
] == end if empty %1%
] == end def r_valid_pmonname
== Make sure the command is valid.
[#DEF r_command_ok ROUTINE |BODY|
#FRAME
#PUSH command^type == accepts the parameter passed command
[#CASE [#ARGUMENT /TEXT command^type/ KEYWORD/ WORDLIST ADD
ALTER/
END OTHERWISE]
|1| #SET command^ [command^type]
#RESULT -1
|2| #RESULT 0
#OUTPUT Command type is missing in [#ROUTINENAME]: [#REST]
#OUTPUT You must specify the type of command to execute;
#OUTPUT either ADD or ALTER
|OTHERWISE|
#RESULT 0
#OUTPUT Command type is incorrect in [#ROUTINENAME]: [#REST]
#OUTPUT You must specify the type of command to execute;
#OUTPUT ADD ALTER
] == end case [argument /text command^/ ...
] == end def r_command_ok ...
== Make sure a server name is supplied and that it is in a valid format.
== The server name must start with an alphanumeric character and be less
== than 16 characters in length. (Note: Continuation (for example, ADD
== SERVER *) is not allowed with the ADD/ALTER commands.)
[#DEF r_format_server_name ROUTINE |BODY|
#FRAME
#PUSH check^var == used to ensure server name starts with alpha char.
#PUSH scname^length == stores length of server name
#PUSH T^svr^name == server name passed to #argument
#PUSH ast^ == stores "*"
#SET ast^ *
#SET check^var abcdefghijklmnopqrstuvwxyz
[#CASE [#ARGUMENT /TEXT T^svr^name/ WORD
336 Management Programming Examples