Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
If used with no parameter, ask for a ini file with askfile. The other way is to put two parameters on the command line : the first one is the title for all the messages and dialog boxes, the second is the name of the ini file
Enjoy
gosub deffunc ; define functions if param0 <> 2 param1 = "Ini file modification" param2 = AskFileName(param1, "", "ini files|*.ini", "", 1) endif MyTitle = StrCat(param1, " (", param2, ")") ; -------------------------------------------------------------------- Localtmp = Environment("TEMP") if Localtmp == "" then Localtmp = "c:\temp" If DirExist(localtmp) == @false Then DirMake(localtmp) mydmp = StrCat(Localtmp, "\modifini.dmp") if fileexist(mydmp) then filedelete(mydmp) ; -------------------------------------------------------------------- Intcontrol(73, 2, 0, 0, 0) debugtrace(2, mydmp) AddExtender("wilx34i.dll") mbstop = xHex(10) mbquestion = xHex(20) mbexclaim = xHex(30) mbinfo = xHex(40) idyes = xHex(6) idno = xHex(7) theini = param2 nbp = 0 Allsec = IniItemizePvt("", theini) for ii = 1 to ItemCount(allsec, @tab) sect = ItemExtract(ii, allsec, @tab) psect = IniItemIzePvt(sect, theini) nbp = nbp + ItemCount(psect, @tab) next ind = 0 If nbp == 0 Message(Mytitle, "No parameters to be edited") exit endif ArrTree = ArrDimension(nbp + ii - 1) for ii = 1 to ItemCount(allsec, @tab) sect = ItemExtract(ii, allsec, @tab) psect = IniItemIzePvt(sect, theini) ArrTree[ind] = StrCat("+", sect) ind = ind + 1 for jj = 1 to ItemCount(psect, @tab) par = ItemExtract(jj, psect, @tab) ArrTree[ind] = StrCat(" ", par) ind = ind + 1 next next IntControl (49, 1, 5, 0, 0) IntControl (33, 0, 0, 0, 0) treeFormat=`WWWDLGED,6.1` modvalue = @false treeCaption = MyTitle treeX=131 treeY=147 treeWidth=350 treeHeight=260 treeNumControls=005 treeProcedure=`TimerProc` treeFont=`DEFAULT` treeTextColor=`DEFAULT` treeBackground=`DEFAULT,DEFAULT` outini = LoadIni(Theini) while @true Thelist = BuildTree(ArrTree) tree001 = `149,240,036,012,PUSHBUTTON,DEFAULT,"Close",1,1,DEFAULT,DEFAULT,DEFAULT,DEFAULT` tree002 = `003,021,144,218,ITEMBOX,Thelist,DEFAULT,DEFAULT,3,DEFAULT,DEFAULT,DEFAULT,DEFAULT` tree003 = `153,021,190,020,EDITBOX,MyVariable2,"",DEFAULT,4,8,DEFAULT,DEFAULT,DEFAULT` tree004 = `153,050,036,012,PUSHBUTTON,DEFAULT,"Valide",2,5,2,DEFAULT,DEFAULT,DEFAULT` tree005 = `153,080,190,152,MULTILINEBOX ,outini,"xxxxx",DEFAULT,4,8,DEFAULT,DEFAULT,DEFAULT`;"219|219|219"` ButtonPushed=Dialog("tree") if buttonpushed == 1 then break endwhile exit :WBERRORHANDLER lasterr = Lasterror() intcontrol(1000, lasterr, 0, 0, 0) errmess = StrCat(lasterr, ":", intcontrol(34, lasterr, 0, 0, 0)) xMessage = StrCat("Internal Error : ", errmess, @crlf, wberrorhandlerline, @crlf, wberrorhandleroffset, @crlf, wberrorhandlerassignment) if isdefined(mydmp) if !Fileexist(mydmp) debugtrace(1, mydmp) IntControl (71, 3, 1, 0, 0) debugtrace(0, mydmp) endif if Fileexist(mydmp) xMessage = StrCat(xmessage, @crlf, "Please, send this file : %mydmp%", @crlf, "to : your company name here") endif endif Message (MyTitle, xMessage) dllfree(user32) exit ; functions definition .................................................................................................................... :deffunc #defineFunction BuildTree(arrtree) outlist = "" index = -1 expand = @false nbi = ArrInfo(arrtree, 1) for i = 1 to nbi index = index + 1 val = arrtree[index] if StrSub(val, 1, 1) == " " if expand OutList = ItemInsert(StrCat(" ", val), -1, outlist, @tab) endif continue endif if StrSub(val, 1, 1) == "+" expand = @false else expand = @true endif OutList = ItemInsert(val, -1, outlist, @tab) next return outlist #endfunction #defineFunction UpdTree(arrtree, item, Myini) nbi = ArrInfo(arrtree, 1) disp = "??????" if StrIndex(item, @tab, 1, @fwdscan) <> 0 then item = StrTrim(strsub(item, 1, pos - 1)) for i = 0 to nbi - 1 SrcItem = StrTRim(arrtree[i]) If StrSub(srcitem, 1, 1) == "-" then thesect = StrSub(srcitem, 2, -1) if SrcItem == StrTrim(item) if StrSub(item, 1, 1) == "+" arrtree[i] = StrCat("-", StrSub(item, 2, -1)) disp = arrtree[i] else if StrSub(item, 1, 1) == "-" arrtree[i] = StrCat("+", StrSub(item, 2, -1)) disp = arrtree[i] else if !Isdefined(thesect) then continue Value = StrReplace(IniReadPvt(thesect, StrTrim(item), " ", Myini), @tab, " ") ; display(2, "test", In) disp = StrCat(value, @tab, i) endif endif break endif next return disp #endfunction #defineFunction UpdIni(arrtree, indexI, Myini, value) key = StrTRim(arrtree[indexI]) for i = indexi to 0 by -1 SrcItem = StrTRim(arrtree[i]) If StrSub(srcitem, 1, 1) == "-" thesect = StrSub(srcitem, 2, -1) break endif next IniWritePvt(thesect, key, value, MyIni) return #endfunction #defineFunction LoadIni(Myini) OutIni = "" hd = FileOpen(MyIni, "read") while @true rec = FileRead(hd) if rec == "*EOF*" then break rec = StrReplace(rec, @tab, " ") OutIni = ItemInsert(rec, - 1, outini, @tab) endwhile fileclose(hd) return STrReplace(OutIni, @tab, @crlf) #endfunction #DEFINESUBROUTINE TimerProc(Handle,dMessage,ControlID,param4,param5) InitDialog = 0 TimerTick = 1 switch dMessage case InitDialog user32=dllload(strcat(dirwindows(1),"user32.dll")) LB_SETCURSEL=390 LB_GETCURSEL=392 ;get lb handle hw_lb=dllcall(user32,long:"GetDlgItem",long:Handle,long:99+002) DialogProcOptions(Handle, 7, 1); Pass item listbox selection changes. DialogProcOptions(Handle, 5, 1); Value change in editbox DialogProcOptions(Handle, 2, 1); Push Button DialogProcOptions(Handle, 11, 1); X window return (-1) case TimerTick return(-1) case 7 if modvalue newvalue = DialogControlGet(Handle, 3, 3); Set text rc = xMessageBox(MyTitle, "Save value ?", @MBYESNO | mbquestion) if rc == idyes updIni (arrtree, indexi, Theini, newvalue) outini = LoadIni(Theini) DialogControlSet(Handle, 5, 3, outini); Set text endif modvalue = @false endif sSelection = DialogControlGet(Handle, ControlID, 6); Get selection selIndex=dllcall(user32,long:"SendMessageA",long:hw_lb,long:LB_GETCURSEL,long:0,long:0) dispText = Updtree(arrtree, sSelection, Theini) if strsub(sSelection, 1, 1) == " " indexI = ItemExtract(2, disptext, @tab) disptext = ItemExtract(1, disptext, @tab) endif Thelist = BuildTree(ArrTree) DialogControlSet(Handle, 3, 3, dispText); Set text DialogControlSet(Handle, 2, 5, Thelist); Set text if StrSub(sSelection, 1, 1) <> " " ;DialogControlSet(Handle, 2, 6, dispText); Set selection dllcall(user32,long:"SendMessageA",long:hw_lb,long:LB_SETCURSEL,long:selIndex,long:0) DialogControlState(Handle, 3, 3, 8); remove read only else DialogControlState(Handle, 3, 4, 8); set read only ;DialogControlSet(Handle, 2, 6, sSelection); Set selection dllcall(user32,long:"SendMessageA",long:hw_lb,long:LB_SETCURSEL,long:selIndex,long:0) endif break; case 5 modvalue = @true DialogControlState(Handle, 4, 4, 2); remove disabled break case 11 exit case 2 rc = idno if ControlID == 1 && modvalue rc = xMessageBox(MyTitle, "Save value ?", @MBYESNO | mbquestion) endif if ControlID == 4 || rc == idyes newvalue = DialogControlGet(Handle, 3, 3); Set text updIni (arrtree, indexi, Theini, newvalue) outini = LoadIni(Theini) DialogControlSet(Handle, 5, 3, outini); Set text modvalue = @false DialogControlState(Handle, 4, 3, 2); set disabled endif break DialogControlState(Handle, 4, 3, 2); set disabled endswitch ; ntlMessage Return(-1) ; Do default processing #ENDSUBROUTINE return
Article ID: W16191
File Created: 2004:03:30:15:43:12
Last Updated: 2004:03:30:15:43:12