! TITLE: parm_val.mac (MANAGEMENT) ! ! ! Modified code to check if a model is built. If it exists ! it retrieves the parameter value; if not it aborts. Also ! added default assignment parameter. ! ! Modified code to use the default value if a parameter ! array is found but the parameter is not defined. ! ! Modified code to not print to output file except if default ! value used or if error traps sprung. ! Added error trap for names not being in single quotes. ! ! OBJECTIVE: ! ! This sub-macro initializes/retrieves a parameter value from a previously ! stored array of parameter values. ! ! ! COMMAND SYNTAX: ! ! (1) (2) (3) (4) ! PARM_VAL, mod_name, param, new_parm, def_val ! ! ! ARGUMENTS: ! ! (1) mod_name = model name using the parameter file which has ! the desired user value. This may be retrieved ! from the array 'MODEL'. ! ! (2) param = desired parameter within the parameter file to be ! queried. ! ! (3) new_parm = new parameter character name to assign the value to ! ! (4) def_val = parameter assignment default value. If ALL of the ! following conditions are met: ! ! a.) the parameter array for a model does not exist ! ! b.) the parameter NEW_PARM is not previously defined ! ! c.) DEF_VAL is not equal to 0 ! ! then DEF_VAL is assigned to the new specified parameter. ! ! In the event that a given model, and therefore the parameter ! array, does not exist for retrieval, these conditions will insure ! that a previously defined value for a parameter holding the name ! of NEW_PARM is not overwritten when this macro is executed. Also, ! if the parameter NEW_PARM is not previously defined, it will not ! be initialized with a value of 0 when DEF_VAL is left blank. ! A message note will be included in the output if the default value ! is used. ! ! ! DESCRIPTION: ! ! These parameter values may be used to link separate models together whose ! surfaces may interface. This will keep the surfaces contingent by using the ! same dimensional values to interface the parts (e.g., outer diameter of one ! part mating with the inner diameter of a second part, therefore same diame- ! ter value must be used for the two mating surfaces from a given axis of rot- ! ation). This prevents the user from searching for a specific parameter value ! manually, and keeps the parts linked if a specific paramter value is changed. ! ! ! *get,prkey_,active,0,prkey /nopr ! *set,abort1_ ! initialize error traps/flags to default settings *set,trap1_ *set,trap2_ ! mod_name=arg1 param_=arg2 newparm_=arg3 defval_=arg4 ! *get,ptyp_,parm,mod_name,type ! check that 'mod_name' is a character string ! *if,ptyp_,ne,3,then abort1_=1 *endif ! *get,ptyp_,parm,param_,type ! check that 'param_' is a character string ! *if,ptyp_,ne,3,then abort1_=1 *endif ! *get,ptyp_,parm,newparm_,type ! check that 'newparm_' is a character string ! *if,ptyp_,ne,3,then abort1_=1 *endif ! *if,abort1_,ne,1,then param_=upcase(param_) *get,parftyp_,parm,par_file,type ! *if,parftyp_,eq,4,then *get,modlim_,parm,par_file,dim,x ! *do,iiii_,1,modlim_,1 *if,mod_name,eq,model(iiii_,1),then mod_indx=iiii_ abrtget_=0 *exit *else *if,iiii_,eq,modlim_,then abrtget_=1 *endif *endif *enddo ! *if,abrtget_,eq,0,then parm_arr=par_file(mod_indx,1) ! max_indx=parfmxi(mod_indx,1) ! *do,iiii_,1,max_indx,1 *if,param_,eq,%parm_arr%(iiii_,1),then %newparm_%=%parm_arr%v(iiii_,1) *exit *else *if,iiii_,eq,max_indx,then *get,ptyp_,parm,%newparm_%,type ! *if,ptyp_,eq,-1,then *if,defval_,ne,0,then %newparm_%=defval_ trap1_=1 *endif *else trap2_=1 *endif *endif *endif *enddo *else *get,ptyp_,parm,%newparm_%,type ! *if,ptyp_,eq,-1,then *if,defval_,ne,0,then %newparm_%=defval_ trap1_=1 *endif *else trap2_=1 *endif *endif *else *get,ptyp_,parm,%newparm_%,type ! *if,ptyp_,eq,-1,then *if,defval_,ne,0,then %newparm_%=defval_ trap1_=1 *endif *else trap2_=1 *endif *endif *else *msg,warn PARM_VAL aborted. Need single quotes around model or variable names. & Output file/window lists the input parameters for 'PARM_VAL' execution. *endif ! *if,trap1_,eq,1,then *msg,warn Default value used in 'PARM_VAL' execution. & Output file/window lists the input parameters for 'PARM_VAL' execution. *endif ! *if,trap2_,eq,1,then *msg,warn PARM_VAL aborted. Default value not used (parameter currently defined). & Output file/window lists the input parameters for 'PARM_VAL' execution. *endif ! *set,mod_name, *set,param_, *set,newparm_, *set,defval_, *set,iiii_, *set,max_indx, *set,mod_indx, *set,parm_arr, *set,abrtget_, *set,ptyp_, *set,parftyp_, *set,modlim_, *set,abort1_, *set,trap1_, *set,trap2_, ! *if,prkey_,eq,1,then /go *endif