!   TITLE:  max_enty_dim.mac (MANAGEMENT)
!
!
!       Updated macro to use 'ENTITY_ARRAY' for querying maximum values.
!
!   OBJECTIVE:
!
!   This sub-macro is used to retrieve the maximum value of the dimension
!   of a specified entity within a selected set along with the entity number.
!
!
!   COMMAND SYNTAX:
!
!                       (1)
!       MAX_ENTY_DIM, ent_typ
!
!
!   ARGUMENTS:
!
!       (1) ent_typ = entity type with which to retrieve maximum dimension
!                     value within [entity type must be in single quotes]:
!
!               'l' = retrieves the maximum length of all selected lines
!
!               'a' = retrieves the maximum area of all selected areas
!
!               'v' = retrieves the maximum volume of all selected volumes
!
!
!   DESCRIPTION:
!
!   The entity types that may be queried are:
!
!                       ENTITY      DIMENSION
!                      --------    -----------
!               (1)     line        line length
!               (2)     area        surface area
!               (3)     volume      volume
!
!   From within the selected set of any given entity, the maximum value of
!   its pertinent dimension, and the entity number with the maximum dimension,
!   is queried and returned in one of the corresponding sets of parameters,
!   respectively:
!
!                     DIMENSION      ENTITY NUMBER
!                    -----------     -------------
!               (1)   max_leng         max_lnum
!
!               (2)   max_area         max_anum
!
!               (3)   max_vol          max_vnum
!
!
!
*get,prkey_,active,0,prkey
/nopr
!
entity__=arg1
!
*if,entity__,eq,'a',then
    asum
*elseif,entity__,eq,'v',then
    vsum
*endif
!
!                          (1)     (2)   (3)  (4)   (5)    (6)   (7)
!           ENTITY_ARRAY, entity, aname, typ, dir, #rows, #col, #pln
!
!
entity_array,entity__,'max_arry','array',,,2
!
*if,entity__,eq,'l',then
    *do,ii__,1,ecount,1
        *get,max_arry(ii__,2),line,max_arry(ii__,1),leng
    *enddo
*elseif,entity__,eq,'a',then
    *do,ii__,1,ecount,1
        *get,max_arry(ii__,2),area,max_arry(ii__,1),area
    *enddo
*elseif,entity__,eq,'v',then
    *do,ii__,1,ecount,1
        *get,max_arry(ii__,2),volu,max_arry(ii__,1),volu
    *enddo
*endif
!
!                        (1)     (2) (3) (4) (5) (6) (7)
!       ARRY_MAX_VAL, 'arrynam', ri, rf, ci, cf, pi, pf
!
!
arry_max_val,'max_arry',,,2
!
*if,entity__,eq,'l',then
    max_leng=max_val
    max_lnum=max_arry(max_ir,1)
*elseif,entity__,eq,'a',then
    max_area=max_val
    max_anum=max_arry(max_ir,1)
*elseif,entity__,eq,'v',then
    max_vol=max_val
    max_vnum=max_arry(max_ir,1)
*endif
!
*set,max_arry(1),
*set,entity__,
*set,ecount,
*set,ii_,
*set,max_val,
*set,max_ir,
*set,max_ic,
*set,max_ip,
!
*if,prkey_,eq,1,then
    /go
*endif