#code=936
ifex D:\X.LOG,LOGS *D:\X.LOG 
ENVI^ EnviMode=1
ENVI^ ForceLocal=1

SET  ::WM_LBUTTONDOWN=0x0201
SET  ::WM_LBUTTONDBLCLK=0x0203
SET  ::WM_DROPFILES=0x0233

SET$ &TAB=09
SET$ &NLC=0a
SET$ &NL=0d 0a

SET &TDAT1=
SET &TDAT2=

SET &I=0
SET &J=0
SET &LOC=zh-CN
SET &idx=
SET &idxdef=
SET &defI=-1
_SUB FreshLable
    TEAM SET TDAT1=| SET &pre=| SET &cr=| SET &I=0| SET &J=-1| SET idx=| SET idxdef=| SET LOC=zh-CN| SET defI=-1| SET ret=
    %BCDCMD% /enum  
    FORX *NL &ret,&&L, CALL * GETLINE 
    FIND $X=X%idx%,! TEAM SET  TDAT1=%TDAT1%%NLC%%idx%%idxdef%| SET idx=
    SET &NUM=%I% 
    GETLeftList
    MSTR TDAT1=2,-1,%TDAT1%
_END

_SUB  GETLeftList
    SET TDAT1=
    SET  &K=0
    LOOP #%&K%<%NUM%,
    {
        SET &tag= 
        IFEX $%K%>0, SET  tag=%K%. 
        CALC #&K=%&K% + 1
        SET~  idx=T[%K%] 
        SET idxdef=
        IFEX $%K%=%defI%, SET idxdef= 【默认】
        SET TDAT1=%TDAT1%%NLC%%tag%%idx%%idxdef%
    }
_END


_SUB  GETLINE
    LSTR  &&Lx=6,%L%
    FIND  $------=%Lx%, TEAM CALC #I=%I%+1| SET &T[%I%]=| SET &L[%I%]=%pre%| SET J=1| SET pre=| SET &T[%I%]=| SET &ID[%I%]=| SET  TDAT1=%TDAT1%%NLC%%idx%%idxdef%| SET idx=Sys%I%| SET idxdef=| EXIT _SUB 
    SET pre=%L%
    FIND $X=X%L%, TEAM SET J=-1| EXIT   //结尾 
    IFEX $%J%<1, EXIT   //没开头 
    MSTR &&n=<1>:%L%
    MSTR n=2,-1,%n%
    MSTR &&v=<2->:%L%
    MSTR -trim &&n=%n%
    SET &nm[%I%][%J%]=%n%
    FIND $identifier=%n%, SET n=标识符  //中文  
    SET &vl[%I%][%J%]=%v%
    SET &N[%I%]=%J%
    FIND $1:locale=%I%:%n%, SET LOC=%v%
    FIND $description=%n%, TEAM SET T[%I%]=%v%| SET idx=%v%|
    FIND $标识符=%n%,
    {
        TEAM SET ID[%I%]=%v%| SET T[%I%]=%v%| SET idx=%v%
        IFEX $%defI%<1,!!  FIND ${current}=%v%,!!  TEAM  SET defI=%I%
        FIND ${default}=%v%,!!  TEAM SET defI=%I%
    }
    CALC #J=%J% + 1
_END





_SUB  GETNodeI
    SET &&I=%1
    SET TDAT2=
    SET~  &ni=N[%I%]
    SET  &K=0
    LOOP #%&K%<%ni%,
    {
        CALC #&K=%&K% + 1
        SET~  &nmj=nm[%I%][%K%] 
        SET~  &vlj=vl[%I%][%K%]
        SET TDAT2=%TDAT2%%NLC%%nmj%%TAB%%vlj%
    }
    MSTR TDAT2=2,-1,%TDAT2%
_END

_SUB WIN1,W738H574,BCDTOOL开源版,
    SET &Title=BCDTOOL开源版
    ENVI @this=%Title%[当前系统]
    SET &ret=
    SET &TITLE1=238:Row
    SET &TITLE2=150:名称%TAB%310:值
    SET &CurI=1
    Set &CurJ=0
    SET &err=
    SET &idx=
    SET &busy=0
    SET &BCDCMD=EXEC* --64 ret=!BCDEDIT 
    SET &BCDFile=
    SET &BCDParam=
    CALL * FreshLable
    CALL * GETNodeI  %CurI% 
    TABL &TB1,L16T16W239H452,%TITLE1%,%TDAT1%,  0x12840
    TABL &TB2,L254T16W461H452,%TITLE2%,%TDAT2%, 0x10840
    ENVI @&TB1.MSG=_%&::WM_LBUTTONDBLCLK%: CALL  OnFresh 
    ENVI @&TB1.MSG=_%&::WM_LBUTTONDOWN%: CALL  OnLButtonTabl1  
    ENVI @&TB2.MSG=_%&::WM_LBUTTONDBLCLK%: CALL  OnLButtonTabl2   
    ITEM &Fresh,L-1T447W60H30,刷新,CALL OnFresh,,0x10
    ITEM &SaveGlob,L52T438W60H30,保存全局,CALL OnGlob,,0x10  //自动保存 
    ITEM &SaveCur,L143T447W81H30,保存当前系统,CALL OnSaveSys,,0x10  //自动保存 
    ITEM &Copy,L260T474W60H30,复制,CALL * OnCopy,
    ITEM &BCD,L75T475W60H30,选择文件,CALL * OnBCD,
    ITEM &Up,L327T473W60H30,上移,CALL OnUp,
    ITEM &Down,L396T473W60H30,下移,CALL OnDown,
    ITEM &Add,L466T474W60H30,添加,CALL @--popmenu  OnAdd,
    ITEM &Del,L537T475W60H30,删除,CALL OnDel,
    ITEM &Def,L612T476W60H30,默认,CALL OnDef,
    ENVI @&SaveCur.Enable=0
    ENVI @this.MSG=#1: CALL * OnMsg1
    ENVI @this.MSG=%&::WM_DROPFILES%::&&wp,&&lp, CALL OnDropFile
    LABE &tip,L10T519W707H22,左边空白处双击刷新；右边双击修改或添加或删除,,
    ENVI @&TB1.Color=*1;0x8080;;;**B
    ENVI @&TB1.Sel=%CurI%:1
    FIND $1=%CurI%,!! TEAM ENVI @&Copy.Enable=0| ENVI @&Up.Enable=0| ENVI @&Del.Enable=0| ENVI @&Down.Enable=0|
    CheckDef
    ITEM ITEMHELP,L686T480W15H21,?,MyHELP,
_END

_SUB OnDropFile
    ENVI  ?&&f,&&FS=DROPFILE,%wp%
    FIND $X=X%f%, EXIT
    SET BCDFile=%f%
    SET BCDParam=/store %f%
    SET BCDCMD=EXEC* --64 &ret=!BCDEDIT /store %f% 
    ENVI @this.SENDMSG=#1
    SET &v=
    IFEX $%NUM%<1, SET v=无效
    ENVI @&tip=%v%BCD:%f%
    ENVI @this=%Title%[%f%]
_END

_SUB OnBCD
    SET &f=
    BROW  &&f,%BCDFile%,请选择BCD，取消为当前系统,
    //FIND $X=X%f%, EXIT
    SET BCDFile=%f%
    SET BCDParam=/store %f%
    FIND $X=X%f%, SET BCDParam= 
    SET BCDCMD=EXEC* --64 &ret=!BCDEDIT %BCDParam% 
    ENVI @this.SENDMSG=#1
    SET &v=
    SET &bcd=BCD
    IFEX $%NUM%<1, SET v=无效
    FIND $X=X%f%, TEAM SET bcd=| SET f=当前系统
    ENVI @&tip=%v%%bcd%:%f%
    ENVI @this=%Title%[%f%]
_END



_SUB OnFresh
    ENVI @this.SENDMSG=#1
    ENVI @&tip=已刷新
_END


//CALL @--popmenu       MyMenu1
_SUB OnAdd
    IFEX $%busy%>0, EXIT 
    MENU ,Windows Vista/7/2008/8 启动项(启动盘), OnAddLoader7boot /d "Windows 7" /application osloader
    MENU ,Windows Vista/7/2008/8 启动项(盘符), OnAddLoader7Drv  /d "Windows 7" /application osloader
    MENU ,Windows Vista/7/2008/8 启动项(分区), OnAddLoader7Pt   /d "Windows 7" /application osloader
    MENU ,Windows 2000/XP/2003 启动项, OnAddLoaderXP {ntldr} /d "Windows XP"  
    MENU ,实模式 启动项,  OnAddLoaderGrub /d "GRUB" /application bootsector
    MENU -
    MENU ,VHD 启动项(NT6.x), OnAddLoaderVHD /d "Boot from VHD" /application osloader
    MENU ,WIM 启动项(Ramdisk), OnAddLoaderWIM /d "Boot from Wim" /application osloader  
    MENU ,调试项, OnAddLoaderDebug {dbgsettings} 
_END


_SUB OnAddLoaderDebug  
    ENVI @&tip=
    %BCDCMD% /create %*  
    SET err=%ERROR%
    SED idx=,.*\{,{,%ret%  //项 {87ded223-8e5e-11e2-9a43-206a8a4be802} 成功创建。
    SED idx=,\}.*,},%idx%
    LSTR &&idx1=1,%idx%
    FIND ${=%idx1%,!  TEAM MESS  [%idx%] 失败  [%ret%] | EXIT 
    %BCDCMD% /set %idx%    locale %LOC%
    %BCDCMD% /set %idx%    debugtype Serial 
    %BCDCMD% /set %idx%    debugport  1 
    //%BCDCMD% /set %idx%    inherit  {bootloadersettings}
    %BCDCMD% /set %idx%    baudrate  115200  
    %BCDCMD% /displayorder  %idx%    /addlast    //增加这个Ubuntu的菜单项到末尾。
    CALC #CurI=%NUM% + 1
    ENVI @this.SENDMSG=#1
    ENVI @&tip=添加=%err%:%ret%
_END

_SUB OnAddLoaderVHD  
    ENVI @&tip=
    %BCDCMD% /create %*  
    SET err=%ERROR%
    SED idx=,.*\{,{,%ret%  //项 {87ded223-8e5e-11e2-9a43-206a8a4be802} 成功创建。
    SED idx=,\}.*,},%idx%
    LSTR &&idx1=1,%idx%
    FIND ${=%idx1%,!  TEAM MESS  [%idx%] 失败  [%ret%] | EXIT 
    %BCDCMD% /set %idx%    locale %LOC%
    %BCDCMD% /set %idx%    device vhd=[C:]\sources\boot.vhd 
    %BCDCMD% /set %idx%    path \Windows\system32\winload.exe    //指定引导文件的路径和文件名 
    %BCDCMD% /set %idx%    inherit  {bootloadersettings}
    ///%BCDCMD% /set %idx%    ""  {globalsettings}   
    %BCDCMD% /set %idx%    osdevice vhd=[C:]\sources\boot.vhd
    %BCDCMD% /set %idx%    systemroot \Windows
    %BCDCMD% /displayorder  %idx%    /addlast    //增加这个Ubuntu的菜单项到末尾。
    CALC #CurI=%NUM% + 1
    ENVI @this.SENDMSG=#1
    ENVI @&tip=添加=%err%:%ret%
_END


_SUB OnAddLoaderWIM  
    ENVI @&tip=
    %BCDCMD% /create {ramdiskoptions} /d "Ramdisk options"
    %BCDCMD% /set {ramdiskoptions} ramdisksdidevice partition=c:
    IFEX C:\\boot\boot.sdi, %BCDCMD% /set {ramdiskoptions} ramdisksdipath \boot\boot.sdi
    %BCDCMD% /create %* 

    SET err=%ERROR%
    SED idx=,.*\{,{,%ret%  //项 {87ded223-8e5e-11e2-9a43-206a8a4be802} 成功创建。
    SED idx=,\}.*,},%idx%
    LSTR &&idx1=1,%idx%
    FIND ${=%idx1%,!  TEAM MESS  [%idx%] 失败  [%ret%] | EXIT 
    %BCDCMD% /set %idx%    locale %LOC%
    %BCDCMD% /set %idx%    device ramdisk=[boot]\Disk.wim,{ramdiskoptions}           
    %BCDCMD% /set %idx%    path \Windows\system32\boot\winload.exe   //指定引导文件的路径和文件名 
    %BCDCMD% /set %idx%    osdevice ramdisk=[boot]\sources\boot.wim,{ramdiskoptions}
    %BCDCMD% /set %idx%    systemroot  \Windows
    %BCDCMD% /set %idx%    detecthal Yes
    %BCDCMD% /set %idx%    winpe     Yes
    %BCDCMD% /displayorder  %idx%    /addlast    //增加这个Ubuntu的菜单项到末尾。
    CALC #CurI=%NUM% + 1
    ENVI @this.SENDMSG=#1
    ENVI @&tip=添加=%err%:%ret%
_END

_SUB OnAddLoaderXP 
    ENVI @&tip=
    %BCDCMD% /create %*  
    SET err=%ERROR%
    SED idx=,.*\{,{,%ret%  //项 {87ded223-8e5e-11e2-9a43-206a8a4be802} 成功创建。
    SED idx=,\}.*,},%idx%
    LSTR &&idx1=1,%idx%
    FIND ${=%idx1%,!  TEAM MESS  [%idx%] 失败  [%ret%] | EXIT 
    %BCDCMD% /set %idx%    locale %LOC%
    %BCDCMD% /set %idx%    device boot           
    %BCDCMD% /set %idx%    path \NTLDR   //指定引导文件的路径和文件名 
    %BCDCMD% /displayorder  %idx%    /addlast    //增加这个Ubuntu的菜单项到末尾。
    CALC #CurI=%NUM% + 1
    ENVI @this.SENDMSG=#1
    ENVI @&tip=添加=%err%:%ret%
_END

_SUB OnAddLoader7Boot 
    ENVI @&tip=
    %BCDCMD% /create %*  
    SET err=%ERROR%
    SED idx=,.*\{,{,%ret%  //项 {87ded223-8e5e-11e2-9a43-206a8a4be802} 成功创建。
    SED idx=,\}.*,},%idx%
    LSTR &&idx1=1,%idx%
    FIND ${=%idx1%,!  TEAM MESS  [%idx%] 失败  [%ret%] | EXIT 
    %BCDCMD% /set %idx%    locale %LOC%
    %BCDCMD% /set %idx%    device boot           
    %BCDCMD% /set %idx%    path \Windows\system32\winload.exe    //指定引导文件的路径和文件名 
    %BCDCMD% /set %idx%    inherit  {bootloadersettings}
    //%BCDCMD% /set %idx%    ""  {globalsettings}  //怎么加？？？？  
    %BCDCMD% /set %idx%    osdevice boot
    %BCDCMD% /set %idx%    systemroot \Windows
    %BCDCMD% /displayorder  %idx%    /addlast    //增加这个Ubuntu的菜单项到末尾。
    CALC #CurI=%NUM% + 1
    ENVI @this.SENDMSG=#1
    ENVI @&tip=添加=%err%:%ret%
_END

_SUB OnAddLoader7Drv 
    ENVI @&tip=
    %BCDCMD% /create %*  
    SET err=%ERROR%
    SED idx=,.*\{,{,%ret%  //项 {87ded223-8e5e-11e2-9a43-206a8a4be802} 成功创建。
    SED idx=,\}.*,},%idx%
    LSTR &&idx1=1,%idx%
    FIND ${=%idx1%,!  TEAM MESS  [%idx%] 失败  [%ret%] | EXIT 
    %BCDCMD% /set %idx%    locale %LOC%
    %BCDCMD% /set %idx%    device partition=C:           
    %BCDCMD% /set %idx%    path \Windows\system32\winload.exe    //指定引导文件的路径和文件名 
    %BCDCMD% /set %idx%    inherit  {bootloadersettings}
    //%BCDCMD% /set %idx%    ""  {globalsettings}  //怎么加？？？？  
    %BCDCMD% /set %idx%    osdevice partition=C:
    %BCDCMD% /set %idx%    systemroot \Windows
    %BCDCMD% /displayorder  %idx%    /addlast    //增加这个Ubuntu的菜单项到末尾。
    CALC #CurI=%NUM% + 1
    ENVI @this.SENDMSG=#1
    ENVI @&tip=添加=%err%:%ret%
_END


_SUB OnAddLoader7Pt 
    ENVI @&tip=
    %BCDCMD% /create %*  
    SET err=%ERROR%
    SED idx=,.*\{,{,%ret%  //项 {87ded223-8e5e-11e2-9a43-206a8a4be802} 成功创建。
    SED idx=,\}.*,},%idx%
    LSTR &&idx1=1,%idx%
    FIND ${=%idx1%,!  TEAM MESS  [%idx%] 失败  [%ret%] | EXIT 
    %BCDCMD% /set %idx%    locale %LOC%
    %BCDCMD% /set %idx%    device partition=\Device\HarddiskVolume1           
    %BCDCMD% /set %idx%    path \Windows\system32\winload.exe    //指定引导文件的路径和文件名 
    %BCDCMD% /set %idx%    inherit  {bootloadersettings}
    //%BCDCMD% /set %idx%    ""  {globalsettings}  //怎么加？？？？  
    %BCDCMD% /set %idx%    osdevice partition=\Device\HarddiskVolume1
    %BCDCMD% /set %idx%    systemroot \Windows
    %BCDCMD% /displayorder  %idx%    /addlast    //增加这个Ubuntu的菜单项到末尾。
    CALC #CurI=%NUM% + 1
    ENVI @this.SENDMSG=#1
    ENVI @&tip=添加=%err%:%ret%
_END

_SUB OnAddLoaderGrub
    ENVI @&tip=
    //MESS. %BCDCMD% /displayorder %IDs%  @
    %BCDCMD% /create %*  
    SET err=%ERROR%
    SED idx=,.*\{,{,%ret%
    SED idx=,\}.*,},%idx%
    //TEAM MESS  [%idx%]
    LSTR &&idx1=1,%idx%
    FIND ${=%idx1%,!  TEAM MESS  [%idx%] 失败  [%ret%] | EXIT 
    %BCDCMD% /set %idx%    locale %LOC%
    %BCDCMD% /set %idx%    device partition=c:   //设置引导扇区文件所在的分区，grldr.mbr所在分区
    %BCDCMD% /set %idx%    path \grldr.mbr       //指定引导扇区文件的路径和文件名 
    %BCDCMD% /displayorder  %idx%    /addlast    //增加这个Ubuntu的菜单项到末尾。
    CALC #CurI=%NUM% + 1
    ENVI @this.SENDMSG=#1
    ENVI @&tip=添加=%err%:%ret%
_END

_SUB OnUp
    IFEX $%busy%>0, EXIT 
    ENVI @&tip=
    IFEX $%CurI%=1, EXIT 
    IFEX $%CurI%=2, EXIT 
    SET J=2
    SET &IDs=
    CALC #&&I1= %CurI% - 1 
    LOOP #%J%<%I1%, TEAM SET~ &idx=ID[%J%]|  SET &IDs=%IDs% %idx%| CALC #J=%J% + 1
    TEAM SET~ &idx=ID[%CurI%]|  SET &IDs=%IDs% %idx%
    TEAM SET~ &idx=ID[%I1%]|  SET &IDs=%IDs% %idx%
    CALC #J=%J% + 2
    LOOP #%J%<=%NUM%, TEAM SET~ &idx=ID[%J%]|  SET &IDs=%IDs% %idx%| CALC #J=%J% + 1
    //MESS. %BCDCMD% /displayorder %IDs%  @
    %BCDCMD% /displayorder %IDs% 
    SET err=%ERROR%
    SET CurI=%I1%
    ENVI @&TB1.Sel=%CurI%;1
    ENVI @this.SENDMSG=#1
    ENVI @&tip=上移=%err%:%ret%
_END

_SUB OnDown
    IFEX $%busy%>0, EXIT 
    ENVI @&tip=
    IFEX $%CurI%=1, EXIT 
    IFEX $%CurI%=%NUM%, EXIT 
    SET J=2
    SET &IDs=
    CALC #&&I1= %CurI% + 1 
    LOOP #%J%<%CurI%, TEAM SET~ &idx=ID[%J%]|  SET &IDs=%IDs% %idx%| CALC #J=%J% + 1
    TEAM SET~ &idx=ID[%I1%]|  SET &IDs=%IDs% %idx%
    TEAM SET~ &idx=ID[%CurI%]|  SET &IDs=%IDs% %idx%
    CALC #J=%J% + 2
    LOOP #%J%<=%NUM%, TEAM SET~ &idx=ID[%J%]|  SET &IDs=%IDs% %idx%| CALC #J=%J% + 1
    //MESS*. %BCDCMD% /displayorder %IDs%  @
    %BCDCMD% /displayorder %IDs% 
    SET err=%ERROR%
    SET CurI=%I1%
    ENVI @&TB1.Sel=%CurI%;1
    ENVI @this.SENDMSG=#1
    ENVI @&tip=下移=%err%:%ret%
_END

_SUB CheckDef
    SET &en=1
    IFEX $%defI%=%CurI%, SET &en=0
    IFEX $%CurI%=1, SET &en=0
    ENVI @&Def.Enable=%en%
    SET &defI1=
    IFEX $%defI%>1, TEAM CALC #&&defI1= %defI% - 1|  //SET defI1=(%defI1%)
    ENVI @&Def=默认(%defI1%)
_END

_SUB OnMsg1
    CALL * FreshLable 
    IFEX $%CurI%>%NUM%, TEAM CALC #CurI=%NUM%|  
    ENVI @&TB1.Sel=%CurI%;1  //重新选择 
    CALL * GETNodeI  %CurI% 
    ENVI @&TB1.Val=-*  //清除 
    ENVI @&TB1.Val=1*;%TDAT1%
    ENVI @&TB2.Val=-*  //清除 
    ENVI @&TB2.Val=1*;%TDAT2%
    CheckDef
_END

_SUB OnDel
    IFEX $%busy%>0, EXIT 
    ENVI @&tip=
    IFEX $%CurI%=1, EXIT 
    SET~  &IDi=ID[%CurI%]
    FIND $X=X%IDi%, EXIT 
    //MESS. %BCDCMD% /delete   %IDi%  /f @
    %BCDCMD% /delete  %IDi% /f 
    SET err=%ERROR%
    IFEX $%CurI%=%NUM%, CALC #CurI=%NUM% - 1 
    ENVI @&TB1.Sel=%CurI%;1
    ENVI @this.SENDMSG=#1
    ENVI @&tip=删除=%err%:%ret%
_END

_SUB OnCopy
    IFEX $%busy%>0, EXIT 
    ENVI @&tip=
    IFEX $%CurI%=1, EXIT 
    SET~  &IDi=ID[%CurI%]
    SET~  &Ti=T[%CurI%]
    FIND $X=X%IDi%, EXIT 
    %BCDCMD% /copy %IDi%  /d "复制 %Ti%"
    SET err=%ERROR%
    ENVI @this.SENDMSG=#1
    ENVI @&tip=复制=%err%:%ret%
_END

_SUB OnDef
    IFEX $%busy%>0, EXIT 
    ENVI @&tip=
    IFEX $%CurI%=1, EXIT 
    SET~  &IDi=ID[%CurI%]
    FIND $X=X%IDi%, EXIT 
    //MESS. %BCDCMD% /default  %IDi%  @
    %BCDCMD% /default  %IDi%
    SET err=%ERROR%
    ENVI @this.SENDMSG=#1
    ENVI @&tip=默认=%err%:%ret%
_END

_SUB OnLButtonTabl1   
    ENVI @&tip=
    IFEX $%busy%>0, EXIT 
    ENVI  @&TB1.Sel=?Sel
    IFEX $%Sel%<1, TEAM  ENVI @&TB1.Sel=%CurI%:1| EXIT     
    SET &en=1
    IFEX  $%Sel%=1, SET &en=0
    CALC #&&en2=!%en%
    TEAM ENVI @&Copy.Enable=%en%| ENVI @&Up.Enable=%en%| ENVI @&Down.Enable=%en%| ENVI @&Del.Enable=%en%| ENVI @&SaveCur.Enable=%en%| ENVI @&SaveGlob.Enable=%en2%
    SET CurI=%Sel%
    IFEX $%CurI%=1, TEAM 
    GETNodeI  %CurI% 
    ENVI @&TB2.Val=-*  //清除 
    ENVI @&TB2.Val=1*;%TDAT2%

    CheckDef
_END

_SUB OnLButtonTabl2
    IFEX $%busy%>0, EXIT 
    ENVI  @&TB2.Sel=?&&Sel2
    TEAM SET &nmj=| SET &vlj=
    CALC #busy=%busy% + 1 
    IFEX  $%Sel2%<1, TEAM CALL  @*ModifyItem  0x10 0 0| CALC #busy=%busy% - 1| EXIT
    SET CurJ=%Sel2%
    ENVI @&TB2.Val=?%Sel2%.1;&&nmj 
    ENVI @&TB2.Val=?%Sel2%.2;&&vlj 
    // MESS.  [%nmj%] [%vlj%]
    CALL  @*ModifyItem  0 0x10 0x08
    CALC #busy=%busy% - 1
_END

_SUB ModifyItem,W639H245,项目和值,
    LABE -vcenter -right,L17T18W60H30,名称:,,
    EDIT -vcenter &nm,L80T18W500H30,%nmj%,,%3
    LABE -vcenter -right,L17T53W60H30,值:,,
    EDIT -vcenter &vl,L80T54W500H30,%vlj%,,
    ITEM &Modify,L186T146W60H30,修改,CALL OnModfy,,%1
    ITEM &Add,L289T146W60H30,添加,CALL OnModfy,,%2
    ITEM &Del,L401T144W60H30,删除,CALL OnModfy del,,%1
_END
_SUB OnModfy
    SET~  &IDi=ID[%CurI%]
//ENVI @&tip=xxxx [%&nm%]  [%&vl%] CurI=%CurI% IDi=%IDi%
    FIND $X=X%IDi%, EXIT 
    SET &nmx=%&nm%
    SET &vlx=%&vl%
    FIND $标识符=%nmx%, EXIT 
    FIND $identifier=%nmx%, EXIT 
    FIND $X=X%nmx%, EXIT 
    FIND $%1=del,!  %BCDCMD% /set %IDi% %nmx% "%vlx%" 
    FIND $%1=del,!! %BCDCMD%  /deletevalue   %nmx%
    KILL \   
    ENVI @WIN1.SENDMSG=#1 
    ENVI @&tip=设定:%ret%    
_END

_SUB MyHELP
    SET-def S=
    SET S=%S%Shadow Defender 维护模式：loadoptions=dissm
    MESS. %S%
_END

WIN1

