This little dialog can be used to view your .txt files , delete a .txt file or create a new .txt file.
Update 1: It will now allow you to view all .txt files. I had to fix the deleting part to work with the new way that had to be listed.
Update 2: hsbar added to the list box.
Update 3: If the .txt file name is in use it will not create it.
Update 4: The file name including .txt must be at least 5 characters in length.
Update 5 21Sep08: Removed the 'List' button , changed the way it list the .txt in the list box, changed to where it loads all the .txt files in your $mircdir upon opening, made the 'View , New and Delete' buttons show when opening and cleaned the code up a bit here and there.
menu status,channel {
[Text Files]: dialog $iif(!$dialog(textfiles), -m, -va) textfiles textfiles
}
dialog textfiles {
title ".txt Files"
size -1 -1 200 230
list 2, 10 5 183 170, hsbar vsbar sort
text "File", 3, 5 178 30 25, center
edit "", 4, 35 175 158 20, read autohs center
button "View", 5, 5 200 55 25
button "New" 7, 72 200 55 25
button "Delete", 6, 140 200 55 25
text "New File", 8, 10 235 50 25
edit "", 9, 60 232 133 20, autohs
button "Create", 10, 5 260 90 25
button "Cancel", 11, 105 260 90 25
}
on *:dialog:textfiles:*:*: {
if ($devent = init) {
did -b $dname 5,6
var %x = 1
while ($findfile($mircdir,*.txt,%x)) {
did -a $dname 2 $remove($findfile($mircdir,*.txt,%x,2),$mircdir)
inc %x
}
did -z $dname 2 190 350
dialog -t $dname $+($chr(91),$did(2).lines,$chr(93)) .txt files
}
if ($devent = sclick) {
if ($did == 2) {
if ($did(2).seltext) {
did -e $dname 5,6
dialog -s $dname -1 -1 200 230
did -ra $dname 4 $+($mircdir,$did(2).seltext)
}
}
if ($did == 5) { run $did(2).seltext | did -b $dname 5,6 | did -u $dname 2 }
if ($did == 6) {
if ($input(Continue with deletion of $str($crlf,2) $qt($+($mircdir,$did(2).seltext)) $+ ?,cy,Deletion of $qt($remove($did(2).seltext,$mircdir)))) {
.remove $qt($+($mircdir,$did(2).seltext))
did -d $dname 2 $did(2).sel
dialog -t $dname $+($chr(91),$did(2).lines,$chr(93)) .txt files
did -f $dname 9
did -b $dname 5,6
did -u $dname 2
did -r $dname 4
}
else { did -f $dname 9 | did -b $dname 5,6 | did -u $dname 2 | did -r $dname 4 }
}
if ($did == 7) {
dialog -s $dname -1 -1 200 290
did -f $dname 9
did -b $dname 5,6
did -u $dname 2
did -r $dname 4
}
if ($did == 10) {
if (!$did(9).text) {
echo -ag No information given for a .txt file to be created.
dialog -s $dname -1 -1 200 230
did -r $dname 9
}
if ($did(9).text) {
if (($right($did(9),4) == .txt) && ($len($did(9)) < 5)) {
echo -ag The length including .txt must be at least 5 characters in length.
dialog -s $dname -1 -1 200 230
did -r $dname 9
}
elseif ($right($did(9),4) != .txt) {
echo -ag Please use " .txt " at the end of the name for the new file.
dialog -s $dname -1 -1 200 230
did -r $dname 9
}
elseif ($exists($did(9))) {
echo -ag That .txt file name is already in use.
dialog -s $dname -1 -1 200 230
did -r $dname 9
}
else {
write $did(9)
did -a $dname 2 $did(9)
did -f $dname 9
did -b $dname 5,6
did -u $dname 2
did -r $dname 4
dialog -s $dname -1 -1 200 230
dialog -t $dname $+($chr(91),$did(2).lines,$chr(93)) .txt files
}
}
}
if ($did == 11) { dialog -s $dname -1 -1 200 230 | did -r $dname 9 }
}
}
This is very handy.Theres no reason to load then look at scripts then delete from the editor and its better then opening your directory and having 785094732150 files open on your desk top.Only thin i had a problem with is freezing my comp for about 30 seconds thought it mite have been infinite but i waited so i didn\'t break, was just busy doing its thing.i did notice that when you delete a file the dialog goes back to the list button state to list the files again an you can close or list again from there.Is there any way after you delete a file that the dialog can auto list the .txt files again? not that it takes much effort to list again,just push the button.Think that just comes from me loading an unloading files,that whole fun tedious loop.Any way nice job on this very useful 8/10.`-.-
if i give it a 10 i might get yelled at from hawkee for such little coding :)
I\'m not really saying you should give this a ten lol. But, it wouldn\'t hurt to review this snippet a bit and rate it based on what you find. =D On the contrary, your opinions are not my decision. So whatever you rate it is based on what you look for in a snippet. So eh, w/e. ;)
I must say this is a pretty useful snippet for filtering out those txt files that aren\'t needed. One thing that disappoints me is the appreciation this snippet receives. I would, well right now, rate this a 6. It makes me wonder how people rate snippets.
Anyway, it would be interesting if you could display the file\'s data in a new dialog or an expansion to the current dialog. I don\'t really see a use of resizing the dialog with a button when you can directly list them. ;) It would be great to have this support other file types, and just include it in one pack. But I\'d have to say this is pretty nice, good work Scakk.
If you mean using $nopath when getting the list of .txt files then I tried that. Using $nopath and $nofile cause it to not allow you to open some of the .txt files it list in the dialog. Doing it as it is above you get the full list , you can open them all and you can delete any of them no matter how deep they are in the mIRC directory.
then u shold at least add a hsbar and did -z, cuz all i currently see if the beginning of the $mircdir, and i cant even see the file
If you mean using $nopath when getting the list of .txt files then I tried that. Using $nopath and $nofile cause it to not allow you to open some of the .txt files it list in the dialog. Doing it as it is above you get the full list , you can open them all and you can delete any of them no matter how deep they are in the mIRC directory.