📄 stafcpar.rxl
字号:
/*****************************************************************************//* Software Testing Automation Framework (STAF) *//* (C) Copyright IBM Corp. 2001 *//* *//* This software is licensed under the Common Public License (CPL) V1.0. *//*****************************************************************************//******************************************************************************//* STAFCPar.rxl - STAF Command Parser REXX Library *//* By Charles Rankin and Don Randall (C) IBM 1999 *//* Version: 1.00 *//******************************************************************************//* Supplied Functions *//* ------------------ *//* InitParser - Initializes a command parser *//* SetCurrentParser - Sets the current parser *//* AddOption - Adds an option to the current parser *//* AddOptionGroup - Adds an option group to the current parser *//* AddOptionNeed - Adds an option need to the current parser *//* SetMaxArguments - Sets the maximum allowable arguments for the current *//* parser *//* ParseString - Parses a given string *//* OptionTimes - Determines the number of times an option was specified *//* OptionValue - Determines the value of a named option *//* NumInstances - Determines the number of options specified *//* InstanceName - Determines the name of a given option *//* InstanceValue - Determines the value of a given option *//* NumArguments - Determines the number of arguments specified *//* Argument - Determines the value of a given argument *//******************************************************************************//* Note: All these functions are case insensitive with regards to option *//* names *//******************************************************************************/#Function All#From STAFCPar Import InitParser SetCurrentParser AddOption AddOptionGroup AddOptionNeed SetMaxArguments ParseString OptionTimes OptionValue NumInstances InstanceName InstanceValue NumArguments Argument#End#Function InitParser/******************************************************************************//* InitParser - Initializes a command parser *//* *//* Accepts: Optionally, the name of the parser to initialize *//* (default = DEFAULT) *//* *//* Returns: 0 *//******************************************************************************/InitParser: parse arg IP_ParserName call SetCurrentParser IP_ParserName STAFCommandParser.!Option.SCP_CurrentParser.0 = 0 STAFCommandParser.!OptionGroup.SCP_CurrentParser.0 = 0 STAFCommandParser.!OptionNeed.SCP_CurrentParser.0 = 0 STAFCommandParser.!MaxArguments.SCP_CurrentParser = 0 RETURN 0/* End of InitParser */#From STAFCPar Import SetCurrentParser#End#Function SetCurrentParser/******************************************************************************//* SetCurrentParser - Sets the current parser *//* *//* Accepts: Optionally, the name of the parser to make current *//* (default = DEFAULT) *//* *//* Returns: 0 *//******************************************************************************/SetCurrentParser: parse arg SCP_CurrentParser if SCP_CurrentParser = "" then SCP_CurrentParser = "DEFAULT" SCP_CurrentParser = TRANSLATE(SCP_CurrentParser) RETURN 0/* End of SetCurrentParser */#End#Function SetMaxArguments/******************************************************************************//* SetMaxArguments - Sets the maximum number of allowable arguments *//* *//* Accepts: The maximum number of arguments *//* *//* Returns: 0 *//******************************************************************************/SetMaxArguments: parse arg SMA_NumArgs STAFCommandParser.!MaxArguments.SCP_CurrentParser = SMA_NumArgs RETURN 0/* End of SetMaxArguments */#End#Function AddOption/******************************************************************************//* AddOption - Adds an option to the current parser *//* *//* Accepts: The name of the option *//* The number of times the option is allowed to be specified *//* (0 = unlimited) *//* A value indicating if a value should be specified with the option *//* *//* YES = A value must be specified with the option *//* ALLOWED = A value may be specified with the option *//* NO = A value may not be specified with the option *//* *//* Returns: 0 *//******************************************************************************/AddOption: parse arg AO_Name, AO_Times, AO_Required STAFCommandParser.!Option.SCP_CurrentParser.0 =, STAFCommandParser.!Option.SCP_CurrentParser.0 + 1 AO_Index = STAFCommandParser.!Option.SCP_CurrentParser.0 STAFCommandParser.!Option.SCP_CurrentParser.AO_Index.!Name = AO_Name STAFCommandParser.!Option.SCP_CurrentParser.AO_Index.!Times = AO_Times STAFCommandParser.!Option.SCP_CurrentParser.AO_Index.!ValueRequired =, TRANSLATE(AO_Required) RETURN 0/* End of AddOption */#End#Function AddOptionGroup/******************************************************************************//* AddOptionGroup - Adds an option group to the parser. An option group *//* allows you to specify mutually exclusive options. *//* *//* Accepts: A space separated list of the options in the group *//* The minimum number of options in the group that must be specified *//* The maximum number of options in the group that may be specified *//* *//* Returns: 0 *//******************************************************************************//* Note *//* ---- *//* *//* The most common values for minimum and maximum are 1 and 1, which states *//* that one and only one of the options in the group must be specified. *//* Another common set of values are 0 and 1, which states that none of the *//* options must be specified, but at most, only 1 may be specified. *//******************************************************************************/AddOptionGroup: parse arg AOG_Group, AOG_Min, AOG_Max STAFCommandParser.!OptionGroup.SCP_CurrentParser.0 =, STAFCommandParser.!OptionGroup.SCP_CurrentParser.0 + 1 AOG_Index = STAFCommandParser.!OptionGroup.SCP_CurrentParser.0 STAFCommandParser.!OptionGroup.SCP_CurrentParser.AOG_Index.!Group = AOG_Group STAFCommandParser.!OptionGroup.SCP_CurrentParser.AOG_Index.!Minimum = AOG_Min STAFCommandParser.!OptionGroup.SCP_CurrentParser.AOG_Index.!Maximum = AOG_Max RETURN 0/* End of AddOptionGroup */#End#Function AddOptionNeed/******************************************************************************//* AddOptionNeed - Adds an option need to the parser. An option need allows *//* you to specify that one of a set of options must be *//* specified when one of another set of options is specified. *//* *//* Accepts: A space separated list of the options which need another option *//* A space separated list of options which must be specifed if an *//* option in the first group is specified *//* *//* Returns: 0 *//******************************************************************************//* Note *//* ---- *//* *//* An example of an option need is if a user was not required to specify a *//* userid and password, but if they specified the userid, then they must *//* also specify the password. In this case, the userid option would need the *//* password option. *//* *//* Be aware that an option need is only one way. Thus, in the previous *//* example, the user could specify just the password without error. If you *//* wanted the userid and password to be mutually "needee" of each other, then *//* you would need to specify an OptionNeed in each direction, one where the *//* userid needs the password, and the other where the password needs the *//* userid. *//******************************************************************************/AddOptionNeed: parse arg AON_Needer, AON_Needee STAFCommandParser.!OptionNeed.SCP_CurrentParser.0 =, STAFCommandParser.!OptionNeed.SCP_CurrentParser.0 + 1 AON_Index = STAFCommandParser.!OptionNeed.SCP_CurrentParser.0 STAFCommandParser.!OptionNeed.SCP_CurrentParser.AON_Index.!Needer = AON_Needer STAFCommandParser.!OptionNeed.SCP_CurrentParser.AON_Index.!Needee = AON_Needee RETURN 0/* End of AddOptionNeed */#End#Function NumInstances/******************************************************************************//* NumInstances - Determines the number of options specified in the parsed *//* string *//* *//* Accepts: Nothing *//* *//* Returns: The number of options specified in the parsed string *//******************************************************************************/NumInstances: RETURN STAFCommandParser.!Instance.SCP_CurrentParser.0/* End of NumInstances */#End#Function InstanceName/******************************************************************************//* InstanceName - Determines the name of the specified option instance *//* *//* Accepts: The option instance number *//* *//* Returns: The value of the specified option instance *//******************************************************************************/InstanceName: parse arg IN_Num RETURN STAFCommandParser.!Instance.SCP_CurrentParser.IN_Num.!Name/* End of InstanceName */#End
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -