|
Joined: Dec 2002
Posts: 295
Fjord artisan
|
OP
Fjord artisan
Joined: Dec 2002
Posts: 295 |
Hi, can somebody help me with this script please ? First up, i have a combo box with lots of entries in it, but now it needs sorting out and i want to delete certain parts from the list, i saw in another script they have a combo box with add/delete buttons so i kindof know this can be done, but i cant for the life of me figure it out, i have read and reread the script, printed it out and read the help files, of both mIRC and the script. So far i have
dialog comby {
title ""
size -1 -1 124 86
option dbu
button "CLOSE", 1, 2 2 37 12, ok cancel
button "ADD", 2, 2 20 37 12
button "DELETE", 3, 2 32 37 12
combo 4, 40 2 80 80, sort edit drop
}
on *:dialog:comby:edit:0: {
did -o $dname 4 %tempmessage
}
on *:dialog:comby:sclick:2: {
did -a $dname 4 %tempmessage $did(4)
}
on *:dialog:comby:sclick:3: {
did -o $dname 4 %tempmessage $did(4)
}
That above code will add and delete entries (this is a test combo box script, before i think about addding it to my real script) It adds the entries and it deletes them, but i think i have the code wrong (again) because asoon as i close the script, all the entires are gone, i think it may something to do with the % variable i have used, maybe i shouldnt of used that, but if i remove it, i cant figure out what text or event should go there in order to add or delete text i want in the combo box. I have read and reread on $did and all that stuff, and i can honestly say after nearly 2 years of scripting mIRC i still cant get that bit right, and yet just the otehr day i made my first away script with no help. Thanks in advance ShadowDemon (Still using mIRC V6.12)
Never argue with an idiot...they'll drag you down to their level and beat you up with experience
|
|
|
|
Joined: Mar 2003
Posts: 1,271
Hoopy frood
|
Hoopy frood
Joined: Mar 2003
Posts: 1,271 |
1. one of your buttons is tagged as "ok cancel" - a button is either ok, cancel, or neither, but not both. 2. if you want the stuff you added to be saved, you need to manually save it. The following will save the lines in a textfile when you hit the CLOSE button. It will save in reverse order, but since your box is sorted anyway, that doesn't matter.
[color:green]; when you click on the CLOSE button[/color]
on *:dialog:comby:sclick:1: {
[color:green]; find out how many entries there are;[/color]
var %i = $did(comby,4).lines
[color:green]; read from line last backwards[/color]
while (%i) {
[color:green]; write the line to file, make sure it's not empty![/color]
if ($did(comby,4,%i).text) write [color:blue]filename.txt[/color] $did(comby,4,%i).text
dec %i
}
}
You will however, if re-opening the dialog you want the stuff to be displayed, need to reload:
[color:green]; when you open the dialog GUI[/color]
on *:dialog:comby:init:*: {
[color:green]; if your saved file exists[/color]
if ($exists([color:blue]filename.txt[/color])) {
[color:green]; find out how many lines there are[/color]
var %i = $lines([color:blue]filename.txt[/color])
[color:green]; and write them all[/color]
while (%i) {
did -a $dname 4 $read([color:blue]filename.txt[/color],%i)
dec %i
}
}
}
DALnet #Helpdesk I hear and I forget. I see and I remember. I do and I understand. -Confucius
|
|
|
|
Joined: Dec 2002
Posts: 295
Fjord artisan
|
OP
Fjord artisan
Joined: Dec 2002
Posts: 295 |
Ok, thanks Locutos for the help. Sorry, i must of missed the ok cancel on the button, i did use dialog studio to create the dialog with. I copied the code and it doesnt work, heres what i have now
dialog comby {
title ""
size -1 -1 124 86
option dbu
button "CLOSE", 1, 2 2 37 12, ok
button "ADD", 2, 2 20 37 12
button "DELETE", 3, 2 32 37 12
combo 4, 40 2 80 80, sort edit drop
}
; when you click on the CLOSE button
on *:dialog:comby:sclick:1: {
; find out how many entries there are
var %i = $did(comby,4).lines
;read from line last backwards
while (%i) {
; write the line to file, make sure it's not empty!
if ($did(comby,4,%i).text) write filename.txt $did(comby,4,%i).text
dec %i
}
}
; when you open the dialog GUI
on *:dialog:comby:init:*: {
; if your saved file exists
if ($exists(filename.txt)) {
; find out how many lines there are
var %i = $lines(filename.txt)
; and write them all
while (%i) {
did -a $dname 4 $read(filename.txt,%i)
dec %i
}
}
}
It`s not adding anything to the text file, it doesnt show anything, i dont know whats up  I tried creating a blank text file, even put it in my scripts folder ShadowDemon
Never argue with an idiot...they'll drag you down to their level and beat you up with experience
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
Maybe cos the button with the ID 2 arent writed down in your code. so for now nothing will happen when you press your "Add" button, Locutos only made the "save" part for you so i cant see how that dialog would work without a fev more lines of code Same goes for the button "Delete"..
Last edited by sparta; 28/10/03 10:40 AM.
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: Dec 2002
Posts: 295
Fjord artisan
|
OP
Fjord artisan
Joined: Dec 2002
Posts: 295 |
Thats the thing, i dont know what code should fit in there, this is really annoying me, i think i`ll give up on this, because my originla script using the combo works fine, but i have to open up the editor everytime i want to add or delete and entry from the combo which is kindof a waste of time for me, when i can have add/delete buttons on the selected line in the combo.
Thanks for you help Sparta
ShadowDemon
Never argue with an idiot...they'll drag you down to their level and beat you up with experience
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
/help dialog .. then read what the diffrent functions doing.. you must trigger the "write" command somwhere, now your dialog list it.. and save the changes when closed.. but it dont actualy write the word you have added in your combo. you should read a bit about $did / did, and if it works on your combo, then use the code from that one and make LocutusofBorg's code a part of yours.. no need to rewrite everything.. i belive LocutusofBorg only made the part of the dialog that you had som problem with.. 
on *:dialog:comby:sclick:2: {
did -a $dname 4 %tempmessage $did(4)
}
on *:dialog:comby:sclick:3: {
did -o $dname 4 %tempmessage $did(4)
}
and what i can see the %var u using arent added in the dialog.. filename.txt $did(comby,4,%i).text this should point you in the right way.. "i hope" 
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: Dec 2002
Posts: 295
Fjord artisan
|
OP
Fjord artisan
Joined: Dec 2002
Posts: 295 |
Thanks, but as i said somewheer in my original post, i have read and reread the mirc help file on using did, $did and anything to do with section of using dialogs, and in my almost 2 yeasrs of scripting i still cant get my head around these not working properly. I put the follwing code back into my script
on *:dialog:comby:sclick:2: {
did -a $dname 4 %tempmessage $did(4)
}
on *:dialog:comby:sclick:3: {
did -o $dname 4 %tempmessage $did(4)
}
and it kindof worked, but now i jsut get a bunch of lines, for example i put teh word test in the combo edit box and clicked teh add button, now when i view the combo box, i have like 5 words of test, and then it doesnt delete the word i select. I totaly give up on this stupid project of mine, wish i`d never bothered with it Thanks
Never argue with an idiot...they'll drag you down to their level and beat you up with experience
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
on *:dialog:comby:sclick:2: {
[color:red];clear the edit line
did -r $dname 4[/color]
did -a $dname 4 %tempmessage $did(4)
}
on *:dialog:comby:sclick:3: {
did -o $dname 4 %tempmessage $did(4)
[color:red]add the write command[/color]
}
Where do your code write to the txt file? you must use "write" to get the info to a txt file..
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: Dec 2002
Posts: 29
Ameglian cow
|
Ameglian cow
Joined: Dec 2002
Posts: 29 |
Since you have editable combo box i assuming that you want to add or delete entrys manually. dialog comby { title "" size -1 -1 124 86 option dbu button "CLOSE", 1, 2 2 37 12, ok button "ADD", 2, 2 20 37 12 button "DELETE", 3, 2 32 37 12 combo 4, 40 2 80 80, sort edit drop } Now we will set variable to entered value in combo box on *:dialog:comby:edit:4: { set %tempmessage $did(4) } ;now we will write that in text file whe you click add button on *:dialog:comby:sclick:2: { ;first we will check does variable have value if (%tempmessage) { write data.txt %tempmessage ;we will put that data in your combo box loadbuf -ro comby 4 data.txt ;and unset variable beaocouse we don`t want to 2 times add same data in case you click add button twice } } now deleting on *:dialog:comby:sclick:4: { ;we will set variable to line number you want to delete from your text file set %line $did(4).sel } on *:dialog:comby:sclick:3: { ;again check for variable to have value if (%line) { write -dl $+ %line data.txt ;and load data in combo box without entry that you deleted loadbuf -ro comby 4 data.txt unset %line } } and last thing,you want that data to be in combobox when you open dialog on *:dialog:comby:init:*: { if ($lines(data.txt) != 0) { loadbuf -ro comby 4 data.txt } } or if you want to check is there text file you can do so like this on *:dialog:comby:init:*: { if ($exists(data.txt)) && ($lines(data.txt) != 0) { loadbuf -ro comby 4 data.txt } } If this is what you want i am glad to help in case that you need something else you can post it again with more info about what you want to do.
|
|
|
|
Joined: Dec 2002
Posts: 295
Fjord artisan
|
OP
Fjord artisan
Joined: Dec 2002
Posts: 295 |
Thanks RAIN, Thats what i wanted it to do  The hard part is just beginning, i have to add that to my original code, which is quite large and has many id's but somehow i'll manage. That simple script was an example and was used for testing until i got it right. ShadowDemon
Never argue with an idiot...they'll drag you down to their level and beat you up with experience
|
|
|
|
Joined: Dec 2002
Posts: 295
Fjord artisan
|
OP
Fjord artisan
Joined: Dec 2002
Posts: 295 |
Sparta,
I read the code, and still dont understand it, so i tried to re-code my code, until i read RAIN's post, he/she seems to have gotton it right for me, and it now works.
Thanks for your help though.
And sorry for "My Rudeness" the other day, i have printed out and keep by me, a list of the /did commands from the help file, but yet i still dont seem to understand them. i have tried to read up on many tutorials too about it.
ShadowDemon
Never argue with an idiot...they'll drag you down to their level and beat you up with experience
|
|
|
|
|