! ******************************
! $Revision: 145002 $
! $Date: 2009-11-13 11:20:27 -0500 (Fri, 13 Nov 2009) $
! ******************************
! macro MTenvact (_envloc)

! *** primary function: activate the picked environment

! *** Notice - This file contains ANSYS Confidential information ***

!  input arguments:
!   _envloc    (arg1)    (int,sc)      the picked location in the env list

!  output arguments:
!   _success            (int,sc)      =0 no success, =1 success  

!  modified parameters:
!   xxxx            (array)

/nopr
_SUCCESS=1

*if,_DEBUG,gt,0,then
!{
   /gopr
   *vwrite,arg1
   (' === MTenvact:'/'    envloc =',f3.0)
   *if,_DEBUG,lt,3,then
   !{
      /nopr
   !}
   *endif
!}
*endif

_envloc = ARG1
*if,_envloc,lt,0,then
!{
   *msg,error,_envloc
   MTenvact error: The picked location in the list is %i
   _SUCCESS=0
!}
*elseif,_envloc,gt,_NUMENV,then
!{
   *msg,error,_envloc,_NUMENV
   MTenvact error: The picked location in the list is %i which is greater &
   than NUMENV
   _SUCCESS=0
!}
*endif

! activate the picked environment
*if,_SUCCESS,gt,0,then
!{

! set the global picked location
_CURENV = _envloc
_ACTENV = '_ENV%_CURENV%'

! display the BCs of the active environment
immed,0     ! turn off immediate display (too slow and we replot anyway!)
lsclear,solid
lsclear,fe
lsclear,iner
immed,1
mttranbc,1

*if,_DEBUG,gt,0,then
!{
   /gopr
   /com, === leave MTenvact:
   _n = _CURENV
   _name1 = _ENVNAM(_n,1)
   _name2 = _ENVNAM(_n,2)
   _name3 = _ENVNAM(_n,3)
   _name4 = _ENVNAM(_n,4)
   *vwrite,_n,_ACTENV,_name1,_name2,_name3,_name4
   ('   location=',f3.0,'   active environment=',a/'   name=',4a)
   *del,_n
   *del,_name1
   *del,_name2
   *del,_name3
   *del,_name4
!}
*endif

!}
*endif

! delete local variables
*del,_envloc
