TEAM ENVI^ ENVIMODE=1| ENVI^ FORCELOCAL=1
IFEX %CurFile%.LOG, LOGS  %CurFile%.LOG
EXEC* &&IPS0=*IPCONFIG    //MESS %IPS%
SET-def IPS=%&IPS0%  //默认就整个表了
SET-def ip=
SET-def mask=
SET-def GW=
SET$ NL=0D 0A
//Ethernet adapter 本地连接:
    //  IPv4 Address. . . . . . . . . . . : 192.168.196.37
    //  Subnet Mask . . . . . . . . . . . : 255.255.248.0
    //  Default Gateway . . . . . . . . . : 192.168.199.254
    //  IPv4 地址 . . . . . . . . . . . . : 192.168.196.37
    //  子网掩码  . . . . . . . . . . . . : 255.255.255.0
    //  默认网关. . . . . . . . . . . . . :


//GetCard 序号 返回名称名 [IPS]  [IPS0]   //序号:1~N
_SUB GetCardId   
    SET &retnm=IPS
    FIND $%~3<>, SET &retnm=%~3
    SET &STR0=IPS0
    FIND $%~4<>, SET &STR0=%~4
    SET id=1
    SET &id=%~1
    CALC #&id=%id%
    IFEX $%id%<1, SET id=1
    SET &I=0
    SET &step=0
    SET &ret=
    SET &netnm=
    SET~  &STR0.v=%STR0%
    @FIND $%&STR0.v%=, EXEC* %STR0%=*IPCONFIG
    FORX *NL %STR0%,&&L,
    {*  
        LSTR &&L4=4,%&L%
        -----step[%&step%] [%&L4%]
        IFEX $%&step%=0,
        {
            RSTR &&R1=1,%&L%
            FIND $%&R1%<>:, EXIT -
            FIND $%&L4%=, EXIT -
            CALC &I=%&I%+1
            IFEX $%&I%=%id%,
            {*  SET step=1  //找到网卡
                SET netnm=%&L%
            }
        }!
        {
            FIND $%&L4%<>, EXIT FORX
            FIND $'%&L4%'='    ', FIND $%&L%<>, SET ret=%&ret%%NL%%&L%
        }
    }
    MSTR &ret=3,0,%&ret%
    ENVI-ret %retnm%=%&ret%
    ENVI-ret %~2=%&netnm%
_END

//GetCard "网卡名" ["网卡名2"]  [IPS]  [IPS0]
_SUB GetCard   
    SET &retnm=IPS
    FIND $%~3<>, SET &retnm=%~3
    SET &STR0=IPS0
    FIND $%~4<>, SET &STR0=%~4
    SET &step=0
    SET &ret=
    SET~  &STR0.v=%STR0%
    @FIND $%&STR0.v%=, EXEC* %STR0%=*IPCONFIG
    FORX *NL %STR0%,&&L,
    {*  
        LSTR &&L4=4,%&L%
        -----step[%&step%] [%&L4%]
        IFEX $%&step%=0,
        {
            RSTR &&R1=1,%&L%
            FIND $%&R1%<>:, EXIT -
            FIND $%&L4%=, EXIT -
            SED &&V1=?,%~1,,%L%
            FIND $%~2<>,!! IFEX $%&V1%<1,!! SED &&V1=?,%~2,,%L%
            IFEX $%&V1%>0, SET step=1  //找到网卡
        }!
        {
            FIND $%&L4%<>, EXIT FORX
            FIND $'%&L4%'='    ', FIND $%&L%<>, SET ret=%&ret%%NL%%&L%
        }
    }
    MSTR &ret=3,0,%&ret%
    ENVI-ret %retnm%=%&ret%
_END


//GetIPX 变量名 "TAG1" "TAG2"  [IPS]  [-sub[4]] 
//-sub: IP地址  X.X.X.X  =>  NNN NNN NNN NNN
_SUB GetIPX 
    SET &STR=IPS
    FIND $%~4<>, SET &STR=%~4
    SET &ret=
    FORX *NL %STR%,&&L,
    {*  SED &&V1=?,%~2,,%&L% 
        IFEX $%&V1%<1,!! SED &&V1=?,%~3,,%L%
        IFEX $%&V1%<1, EXIT -    
        MSTR &v2=<-1>%&L%
        FIND $:=%&v2%, SET v2=    //空
        SET  ret=%&v2%
        EXIT  FORX
    }
    ENVI-ret %~1=%&ret%
    FIND $%~5=, EXIT //获得各个字段    
    SET-def n=%1
    MSTR -delims:. &&n1,&&n2,&&n3,&&n4=<1*>%ret%
    FIND $%~5=-sub3, @TEAM RSTR &n1=3,000%n1%| RSTR &n2=3,000%n2%| RSTR &n3=3,000%n3%| RSTR &n4=3,000%n4%
    @TEAM ENVI-ret %n%1=%&n1%| ENVI-ret %n%2=%&n2%| ENVI-ret %n%3=%&n3%| ENVI-ret %n%4=%&n4%
_END


GetCard "本地连接:" ""  IPS  IPS0  //获得 本地连接: 的信息表
MESS. 本地连接: [%NL%%IPS%]

GetCardId 1 &&nm  IPS  IPS0        //获得 连接1  的信息表
MESS. 连接1: <%&nm%> [%NL%%IPS%]



GetIPX  &&ip "IP Address"  "IPv4 " IPS -sub

GetIPX  &&mask "Subnet Mask"  "子网掩码" IPS  -sub


GetIPX  &&gw "Default Gateway"  "默认网关"  IPS  -sub

MESS IP  : %ip1% %ip2% %ip3% %ip4% [%ip%]\nMASK: %mask1% %mask2% %mask3% %mask4% [%mask%] \nGW  : %gw1% %gw2% %gw3% %gw4% [%gw%] \n

