Silo Posted September 17, 2008 Report Share Posted September 17, 2008 Pretty simple question, yet it's doing my head in Listing a .txt file in a dialog list - easy. Deleting a line with a button - easy. Deleting a line with right click popup - still no problem. Ok, so now I've thrown MDX in to the mix and it's not working to my liking. So, is this right - when using views.dll to add a header & grid etc, is one the command line? i.e - do other controls need to start at 2? alias -l rem.chan { ;;;tokenize ($did($dname,2).text,32) var %ohi $input(Are you sure you want to delete the channel $+ %select.chan from your favourites list?,qcyd,Confirm) if (%ohi == $true) splay clear.wav | write -dl $+ $readn $did($dname,2).sel $read(Engine/Text/favourites.txt) elseif (%ohi == $false) halt chan.list } So, as I said, before adding MDX this would work fine. Now it deletes random lines. The input display still points to the right line, but as you can see, that's only because it's displaying a variable. I've tried using $calc( +2) wrapped around various parts of the write code, to no avail. Can someone show me the error of my ways? Thanks in advance Link to comment Share on other sites More sharing options...
The Gate Keeper Posted September 17, 2008 Report Share Posted September 17, 2008 (edited) Firstly, you are true that MDX uses the first line as a header, so what you need to do is add 1 to the select count, not 2, as you were thinking of doing. Furthermore, when doing a command like $input, you don't need to set variables or have an "else" statement... it can be simply done as... alias -l rem.chan { ;;;tokenize ($did($dname,2).text,32) if ($input(Are you sure you want to delete the channel $+ %select.chan from your favourites list?,qcyd,Confirm)) { splay clear.wav write -dl $+ $readn $calc($did($dname,2).sel + 1) $read(Engine/Text/favourites.txt) } chan.list } Edited September 17, 2008 by The Gate Keeper Link to comment Share on other sites More sharing options...
Silo Posted September 17, 2008 Author Report Share Posted September 17, 2008 Hi TGK, firstly, thank you for a such a swift response I had experimented with that version of $calc, & here's the weird thing... It doesn't delete the line plus it actually writes a file to $scriptdir with either the name of the channel or a + or - I thought maybe my mIRC was screwy so I added a fresh .exe yet it still does the same thing :| Thank you for cleaning up the $input for me too Any other ideas? Link to comment Share on other sites More sharing options...
The Gate Keeper Posted September 17, 2008 Report Share Posted September 17, 2008 (edited) i see what happened... your "write -dl" was incorrect. This should now do the trick. My gues is "chan.list" loads up the channel list? if this is so, then hopefully it will work now. alias -l rem.chan { ;;;tokenize ($did($dname,2).text,32) if ($input(Are you sure you want to delete the channel $+ %select.chan from your favourites list?,qcyd,Confirm)) { splay clear.wav write -dl $+ $calc($did($dname,2).sel + 1) Engine/Text/favourites.txt did -r $dname 2 } chan.list } Edited September 17, 2008 by The Gate Keeper Link to comment Share on other sites More sharing options...
Silo Posted September 17, 2008 Author Report Share Posted September 17, 2008 (edited) Hey there, you're right, the chan.list is the loop to display the .txt in the list box. Arghhhh, your code looks perfect but it's still removing the randomly, or maybe even the next selection after the one I've actually chosen. Perhaps I should mention, that when I write to the file I add two entries - var %a = $chan var %b = $server so in reality, I'm still only deleting the selected line, so I gues that isn't important to the task... Hmmm, like I mentioned, remove MDX and it's no problem lol I appreciate your time & help PS - I removed the did -r $dname line since I got a */did: invalid parameters (line 96, dialogs.mrc)* error. Since I did -r in the chan.list loop I didn't think it was needed? - Edited September 17, 2008 by Silo Link to comment Share on other sites More sharing options...
The Gate Keeper Posted September 17, 2008 Report Share Posted September 17, 2008 well, just some confirmation, the list is actually id 2? If not, then this could be the issue... Link to comment Share on other sites More sharing options...
Silo Posted September 17, 2008 Author Report Share Posted September 17, 2008 lol i wish it were something as simple as that dialog favourites { title "Favourites" size -1 -1 125 108 option dbu icon $mircdir $+ Engine\ico\Default\home.ico, 0 button "&Close", 1, 86 93 37 12, ok cancel list 2, 2 1 122 89, size check "Auto close on join", 3, 4 95 50 10 } On *:Dialog:favourites:*click:2:{ if (!$read(Engine/Text/favourites.txt)) faves.pop if (!$did(2).sel) halt tokenize 32 $did($did,1) if ($1 == rclick) { .set %select.chan $remove($gettok($did(favourites,2).seltext,2-7,32),+fs 0 0 1 , +fs) faves.pop } elseif ($1 == dclick) && (!$server) { prepare.server } elseif ($1 == dclick) { set -u10 %select.chan $remove($gettok($did(favourites,2).seltext,2-7,32),+fs 0 0 1 , +fs) perform.event } elseif ($1 == sclick) { } } Link to comment Share on other sites More sharing options...
The Gate Keeper Posted September 18, 2008 Report Share Posted September 18, 2008 can you put the code properly together? Where does "rem.chan" fit into it? Also, can you tell me what teach of the tokenize shows? as in, after each token method, do an echo with a no to identify. Sometimes you may not be getting the right token information. Link to comment Share on other sites More sharing options...
Silo Posted September 18, 2008 Author Report Share Posted September 18, 2008 Ok, will do when I get home. Thanks for your assistance I remembered in the vews.dll line I had a checkbox added which I never used, so I thought that could give a false reading with the $calc + 1 . I removed it, but it's still cutting random lines I'll post the complete code tonight (quite embarrassing since my code is basic and messy lol) Thanks again TGK Link to comment Share on other sites More sharing options...
Silo Posted September 18, 2008 Author Report Share Posted September 18, 2008 Please excuse the double post Ok, TGK, as requested... alias ajoin { dialog $iif($dialog(favourites),-x,-mh favourites) favourites } dialog favourites { title "Favourites" size -1 -1 125 108 option dbu icon $mircdir $+ Engine\ico\Default\home.ico, 0 button "&Close", 1, 86 93 37 12, ok cancel list 2, 2 1 122 89, size check "Auto join on &connect", 3, 4 95 60 10 } On *:Dialog:favourites:*click:2:{ if (!$read(Engine/Text/favourites.txt)) faves.pop if (!$did(2).sel) halt tokenize 32 $did($did,1) if ($1 == rclick) { .set %select.chan $remove($gettok($did($dname,2).seltext,2-7,32),+fs 0 0 0 , +fs) faves.pop } elseif ($1 == dclick) && (!$server) { prepare.server } elseif ($1 == dclick) { set -u10 %select.chan $remove($gettok($did(favourites,2).seltext,2-7,32),+fs 0 0 0 , +fs) perform.event } elseif ($1 == sclick) { } } On *:Dialog:favourites:sclick:3:{ $iif($did(3).state == 1,set %a.join,unset) %a.join } On *:Dialog:favourites:init:*:{ createMDX dll $mdx SetDialog $dname dll $mdx SetBorderStyle 2 staticedge dll $mdx SetBorderStyle $dname 4 clientedge dll $mdx SetControlMDX $dname 2 listview flatsb report single showsel rowselect grid icon > $vdll dll $mdx SetColor favourites background $rgb(0,0,0) dll $mdx SetColor $dname 2 textbg $rgb(214,67,0) did -i $dname 2 1 settxt color $rgb(64,0,128) did -i $dname 2 1 headerdims 118:1 102:2 did -i $dname 2 1 headertext Channel $chr(9) Server if ($var(%a.join)) did -c $dname 3 chan.list } alias -l perform.event { .join %select.chan align Joining %select.chan $+ ... if ($var(%a.join)) ajoin } alias -l chan.list { did -r favourites 2 var %i = 1 while (%i <= $lines(Engine/Text/favourites.txt)) { did -a favourites 2 $gettok($read(Engine/Text/favourites.txt,%i),1,32) $chr(9) $gettok($read(Engine/Text/favourites.txt,%i),2-,32) inc %i } } alias -l prepare.server { tokenize ($did($dname,2).text,32) server $gettok($read(Engine/Text/favourites.txt),2-,32) } alias -l set.chan { var %channel = $input(Enter channel name,129,Add Channel) var %server = $input(Enter server name,129,Add Server,$server) write -a Engine/Text/favourites.txt %channel %server chan.list } alias -l rem.chan { if ($input(Are you sure you want to delete the channel %select.chan from your favourites list?,qcyd,Confirm)) { splay clear.wav write -dl $+ $calc($did($dname,2).sel + 1) Engine/Text/favourites.txt ; did -r $dname 2 } chan.list } alias -l cull.list { if $input(Are you sure you want to delete your favourites list? $crlf $crlf $+ This process cannot be undone,wnd,Confirm) splay clear.wav | write -c Engine/Text/favourites.txt chan.list } alias join.chan { var %xx = 1 while (%xx <= $lines(Engine/Text/favourites.txt)) { .join $read(Engine/Text/favourites.txt,%xx) inc %xx } } On *:SIGNAL:*MPOPUP.*: { if ($1 == 465) .list if ($1 == 490) set.chan if ($1 == 491) rem.chan if ($1 == 492) chan.list if ($1 == 493) cull.list } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now