mIRC Home    About    Download    Register    News    Help

Page 1 of 2 1 2 >
Topic Options
#148961 - 12/05/06 03:56 PM Problem with simple script
bwr30060 Offline
Fjord artisan

Registered: 23/05/05
Posts: 449
Loc: Georgia USA
I came up with this idea to make it easier to send scripts over mIRC. If you paste a script into a channel or query, the person has to remove <Blake> from the beginning of every line, so I'd like to be able to have this dialog for sending scripts. Both people would have to have this script, but what it would do would be to put the sent script into a @window to make it easier to copy. I'm having problems with this though, and I can't figure where all the problems are. In my status window, it's doing a few things. It looks like it's trying to send a notice to someone named Send with the text Script, and I'm also getting "* /ctcp: insufficient parameters (line 19, scriptsend.mrc)". Line 19 is:

ctcp $snick(#,%x) endscript

Here's what I have so far:
Code:
dialog scriptsend {
  title "Script Sender"
  size -1 -1 428 470
  option pixels notheme
  edit "", 1, 4 9 419 316,multiline, vsbar
  button "Send Script", 2, 4 332 65 25
}
On *:Dialog:scriptsend:sclick:2: {
  var %x = 1
  while (%x &lt;= $snick(#,0)) {
    ctcp $snick(#,%x) script
    inc %x
  }      
  var %y = 1
  while %y &lt;= $did(scriptsend,1).lines {
    msg $snick(#,%x) $did(scriptsend,1,%y).text
    inc %y
  }      
  ctcp $snick(#,%x) endscript
}
ctcp ^*:scriptsend: {
  haltdef  
  set %script 1
  if ($window(script)) {
    aline @script $crlf
  }
  else {
    window @script
  }
}
ctcp ^*:endscript: {
  haltdef
  unset %script
}
on *:text:*:*:{
  if (%script) {
    aline @script $1-
  }
}

Thanks for any help.

OK, I fixed the problem with it sending to the wrong nick. I'm still having a problem though. I need to have it remember every selected nick so it can send the script to them, and right now, it's saying:

dialog No such nick/channel
-
title No such nick/channel

etc. How would I save the nicks since I have to get out of that loop to send the script?
_________________________
Bears on Patrol Chat

Top
#148962 - 12/05/06 04:11 PM Re: Problem with simple script
DaveC Offline
Planetary brain

Registered: 26/09/03
Posts: 4230
Code:
On *:Dialog:scriptsend:sclick:2: {
  var %x = 1
  while (%x &lt;= $snick(#,0)) {
    ctcp $snick(#,%x) script
    var %y = 1
    while %y &lt;= $did(scriptsend,1).lines {
      msg $snick(#,%x) $did(scriptsend,1,%y).text
      inc %y
    }      
    ctcp $snick(#,%x) endscript
    inc %x
  }      
}

Top
#148963 - 12/05/06 04:22 PM Re: Problem with simple script
bwr30060 Offline
Fjord artisan

Registered: 23/05/05
Posts: 449
Loc: Georgia USA
Thanks. That got rid of the errors, but now it just doesn't do anything. It doesn't send any script.
_________________________
Bears on Patrol Chat

Top
#148964 - 12/05/06 06:06 PM Re: Problem with simple script
bwr30060 Offline
Fjord artisan

Registered: 23/05/05
Posts: 449
Loc: Georgia USA
Code:
On *:Dialog:scriptsend:sclick:2: {
  var %x = 1
  while (%x &lt;= $snick(#,0)) {
    ctcp $snick(#,%x) script
    inc %x
  }    
  var %y = 1
  while %y &lt;= $did(scriptsend,1).lines {
    msg Blake $did(scriptsend,1,%y).text
    inc %y
  }      
  ctcp $snick(#,%x) endscript
  inc %x
}
ctcp *:script: {
  set %script 1
}
ctcp ^*:endscript: {
  unset %script
}
on *:text:*:*:{
  if (%script) {
    aline @script $1-
  }
}

This script will send me the text I want, but only because I hard coded my name. It seems to have problems with $snick(#,%x). I left the ctcp the way it is and it always errors out on that line. Any ideas?
_________________________
Bears on Patrol Chat

Top
#148965 - 12/05/06 06:25 PM Re: Problem with simple script
bwr30060 Offline
Fjord artisan

Registered: 23/05/05
Posts: 449
Loc: Georgia USA
This script works. It sends the script to a window, but there's still a problem. To make this work, I had to hard code the name of the channel. It seems like the dialog event won't recognize which nicks are selected in the nick list. I'd really like to fix this so I don't have to hard code channel names.
Code:
dialog scriptsend {
  title "Script Sender"
  size -1 -1 428 470
  option pixels notheme
  edit "", 1, 4 9 419 316,multiline, vsbar
  button "Send Script", 2, 4 332 65 25
}
On *:Dialog:scriptsend:sclick:2: {
  $SendScript($snick(#chat,1))
}
ctcp ^*:script: {
  haltdef  
  set %script 1
}
ctcp ^*:endscript: {
  unset %script
}
on *:text:*:*:{
  if (%script) {
    aline @script $1-
  }
}
alias SendScript {
  if ($window(script)) {
    aline @script $crlf
  }
  else {
    window @script 
    ctcp $1 script
    var %y = 1
    while %y &lt;= $did(scriptsend,1).lines {
      msg $1 $did(scriptsend,1,%y).text
      inc %y
    }  
    ctcp $snick(#,%x) endscript
  }
}
_________________________
Bears on Patrol Chat

Top
#148966 - 12/05/06 06:25 PM Re: Problem with simple script
schaefer31 Offline
Fjord artisan

Registered: 27/08/05
Posts: 525
I believe it should be $active in place of # since # isn't going to have a value in a dialog event.

Top
#148967 - 12/05/06 06:38 PM Re: Problem with simple script
bwr30060 Offline
Fjord artisan

Registered: 23/05/05
Posts: 449
Loc: Georgia USA
Thanks, that works. grin Another small thing, no big deal if I can't do this. This script sends a query with the script text you'd like to send, and also puts it in a window. If I can, I'd like to not have the query window show up at all. I put a haltdef, but the window still opens, there's just no text in it. Can this be done? Thanks.
Code:
on ^*:text:*:?:{
  if (%script) {
    haltdef    
    if ($window(script)) {    
      aline @script $1-
    }
    else {
      window @script
      aline @script $1-
    }
  }    
}

It's also not halting my CTCPs from showing up.


Edited by bwr30060 (12/05/06 06:39 PM)
_________________________
Bears on Patrol Chat

Top
#148968 - 12/05/06 06:47 PM Re: Problem with simple script
schaefer31 Offline
Fjord artisan

Registered: 27/08/05
Posts: 525
I'm not sure if you can prevent the window from opening, but you could hide the window while the script is still sending and close it when finished.

/window -h <window-name>
/window -c <window-name>

Also, on this line:

if ($window(script)) {

I believe you meant:
if ($window(@script)) {

Top
#148969 - 12/05/06 06:50 PM Re: Problem with simple script
bwr30060 Offline
Fjord artisan

Registered: 23/05/05
Posts: 449
Loc: Georgia USA
Sorry, I meant the query window. I'd like to not have it show up at all if the query I'm getting is a script being sent using this script.
_________________________
Bears on Patrol Chat

Top
#148970 - 12/05/06 06:51 PM Re: Problem with simple script
schaefer31 Offline
Fjord artisan

Registered: 27/08/05
Posts: 525
You can hide the query window.

/window -h <some-nick>

Top
#148971 - 12/05/06 06:52 PM Re: Problem with simple script
bwr30060 Offline
Fjord artisan

Registered: 23/05/05
Posts: 449
Loc: Georgia USA
Ah, ok. Thanks smile
_________________________
Bears on Patrol Chat

Top
#148972 - 12/05/06 10:24 PM Re: Problem with simple script
DaveC Offline
Planetary brain

Registered: 26/09/03
Posts: 4230
Code:
on ^*:open:?:*:{ possable.script.text $1- }
on ^*:text:*:?:{ possable.script.text $1- }
alias -l possable.script.text {
  if (%script) {
    haltdef    
    window @script
    aline @script $1-
  }
}

* code untested *

Try out that, It uses the open pm event to get the text if the window doesnt exist, and stops the Pm window opening, if its already open then it cacthes it using text pm event, I think this is better than hiding the window, as if the user already had a pm open to the person, they most likely dont want it hidden.

I also simplified the sending the text to the @script window, i just create it everytime, if it exists already who cares, telling mirc to create it when already in existence is ignored (and is slightly faster than checking for it anyway)

Top
#148973 - 12/05/06 10:28 PM Re: Problem with simple script
bwr30060 Offline
Fjord artisan

Registered: 23/05/05
Posts: 449
Loc: Georgia USA
This works for what I want to do. I might try yours later tonight just to see, but here's what I have.
Code:
dialog scriptsend {
  title "Script Sender"
  size -1 -1 428 470
  option pixels notheme
  edit "", 1, 4 9 419 316, multi vsbar
  button "Send Script", 2, 4 332 65 25
  button "Clear", 3, 76 332 65 25
}
On *:Dialog:scriptsend:sclick:2: {
  var %x = 1
  while (%x &lt;= $snick($active,0)) {
    ctcp $snick($active,%x) script
    var %y = 1
    while %y &lt;= $did(scriptsend,1).lines {
      msg $snick($active,%x) $did(scriptsend,1,%y).text
      inc %y
    }      
    ctcp $snick($active,%x) endscript
    inc %x
  }
}  
ctcp ^*:script: {
  haltdef  
  set %script 1
}
ctcp ^*:endscript: {
  haltdef  
  unset %script
}
on ^*:text:*:?:{
  if (%script) {
    window -h $nick   
    if ($window(@script)) {    
      aline @script $1-
    }
    else {
      window @script
      aline @script $1-
    }
  }    
}
alias SendScript {
  if ($window(script)) {
    aline @script $crlf
  }
  else {
    window @script 
    ctcp $1 script
    var %y = 1
    while %y &lt;= $did(scriptsend,1).lines {
      msg $1 $did(scriptsend,1,%y).text
      inc %y
    }  
    ctcp $snick($active,%x) endscript
  }
}
On *:Dialog:scriptsend:sclick:3: {
  did -r scriptsend 1
}
_________________________
Bears on Patrol Chat

Top
#148974 - 12/05/06 11:28 PM Re: Problem with simple script
DaveC Offline
Planetary brain

Registered: 26/09/03
Posts: 4230
Code:
dialog scriptsend {
  title "Script Sender"
  size -1 -1 428 470
  option pixels notheme
  edit "", 1, 4 9 419 316, multi vsbar
  button "Send Script", 2, 4 332 65 25
  button "Clear", 3, 76 332 65 25
}
On *:Dialog:scriptsend:sclick:2: {
  var %x = 1
  while (%x &lt;= $snick($active,0)) {
    .ctcp $snick($active,%x) script
    var %y = 1
    while %y &lt;= $did(scriptsend,1).lines {
      .msg $snick($active,%x) $did(scriptsend,1,%y).text
      inc %y
    }      
    .ctcp $snick($active,%x) endscript
    inc %x
  }
}  
On *:Dialog:scriptsend:sclick:3: {
  did -r scriptsend 1
}
ctcp ^*:script: {
  haltdef  
  set -u600 $+(%,script.,$nick) 1
}
ctcp ^*:endscript: {
  haltdef  
  unset $+(%,script.,$nick)
}
on ^*:open:?:*:{ possable.script.text $1- }
on ^*:text:*:?:{ possable.script.text $1- }
alias -l possable.script.text {
  if ($($+(%,script.,$nick),2)) {
    haltdef
    window @script
    aline @script $1-
  }    
}


try that out, its untested, but i think it well work.
I added . to the ctcp's and the msg's so you dont have to see them all being sent (add or remove at your pleasure)
I added dynamicly named %script vars so its turned of and on per user, while its possable two users might dump u a script at the same moment, causing mucking up of the @script window, this way at least, if one person is sending you a script and another pming you in chat, his chat wont end up in the script window.
Also added a 10min auto unset to the setting of the $script.$nick var incase the user never sends the turn off code
Used my idea for the on texts to not create the pm window, or ignore it if it exists.

One last possable alturnative is also this
Code:
alias -l possable.script.text {
  if ($($+(%,script.,$nick),2)) {
    haltdef
    window $+(@script.,$nick)
    aline $+(@script.,$nick) $1-
  }    
}

This would create sepreate @script.$nick windows so u could track who sent what script, and avoid the chance of two same time sent scripts overlapping in the same window.
This may however be few and far between, i dont know how active the channel u mentioned is.

Top
#148975 - 12/05/06 11:34 PM Re: Problem with simple script
bwr30060 Offline
Fjord artisan

Registered: 23/05/05
Posts: 449
Loc: Georgia USA
Thanks. I'll give that one a try too. The channel I'm talking about is on my own IRC server, which really has not had many people at all on it. so at least I won't have to worry about messages getting put in the window. Anyone is still welcome to check out my IRC server. I'd like to have it be a place where you can discuss scripts, if it ever gets going.
_________________________
Bears on Patrol Chat

Top
#148976 - 13/05/06 02:04 AM Re: Problem with simple script
bwr30060 Offline
Fjord artisan

Registered: 23/05/05
Posts: 449
Loc: Georgia USA
This seems to be having a problem. This is the final script I ended up with (I haven't tried the other one yet), and the one loop seems to be failing. It's the loop to check how many lines are in the edit box so that it sends them all. For some reason, the loop seems to keep going even after the number of lines is exceeded, and then %script doesn't get unset. This causes a problem, because then other queries get put into the @window. Can anyone figure out why this is failing? I'll just repost the section of code where that loop is.
Code:
On *:Dialog:scriptsend:sclick:2: {
  var %x = 1
  while (%x &lt;= $snick($active,0)) {
    ctcp $snick($active,%x) script
    var %y = 1
    while %y &lt;= $did(scriptsend,1).lines {
      msg $snick($active,%x) $did(scriptsend,1,%y).text
      inc %y
    }      
    ctcp $snick($active,%x) endscript
    inc %x
  }
}
_________________________
Bears on Patrol Chat

Top
#148977 - 13/05/06 02:42 AM Re: Problem with simple script
bwr30060 Offline
Fjord artisan

Registered: 23/05/05
Posts: 449
Loc: Georgia USA
I know what the issue is, but I'm not sure how to solve it. It only errors out sometimes, and this is because sometimes when I'm sending a script to test, I paste the whole thing and then decide I only need to send a few lines. I then delete all but about three lines, leaving the cursor on a blank line. The line count considers where the cursor is to be a line, but there's no text there, so it can't be set to a variable. How can I handle this so that it would check to make sure that there is something on that line before setting it to a variable? Thanks.

EDIT:

There is another problem. After I send someone a script, they don't get my queries that I send them.


Edited by bwr30060 (13/05/06 02:47 AM)
_________________________
Bears on Patrol Chat

Top
#148978 - 13/05/06 03:45 AM Re: Problem with simple script
genius_at_work Offline
Hoopy frood

Registered: 08/10/05
Posts: 1741
You need to add a line to skip blank lines. Add this line as the first line inside the second while-loop.


if ($did(scriptsend,1,%y).text == $null) continue

-genius_at_work

Top
#148979 - 13/05/06 10:07 AM Re: Problem with simple script
qwerty Offline
Hoopy frood

Registered: 07/01/03
Posts: 2523
I'd use
if ($remove($did(scriptsend,1,%y).text,$chr(32)) == $null) continue
to prevent errors with lines that contain only spaces.
_________________________
/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com

Top
#148980 - 13/05/06 02:56 PM Re: Problem with simple script
bwr30060 Offline
Fjord artisan

Registered: 23/05/05
Posts: 449
Loc: Georgia USA
I just tried both ways you two mentioned and the script locks up either way. What am I doing wrong. And this might be a stupid question, but did you literally want me to have the word "continue" there? I haven't seen that used. Thanks.
Code:
On *:Dialog:scriptsend:sclick:2: {
  var %x = 1
  while (%x &lt;= $snick($active,0)) {
    ctcp $snick($active,%x) script
    var %y = 1
    while %y &lt;= $did(scriptsend,1).lines {
      if ($remove($did(scriptsend,1,%y).text,$chr(32)) == $null) continue      
      msg $snick($active,%x) $did(scriptsend,1,%y).text
      inc %y
    }      
    ctcp $snick($active,%x) endscript
    inc %x
  }
} 


Edited by bwr30060 (13/05/06 02:56 PM)
_________________________
Bears on Patrol Chat

Top
Page 1 of 2 1 2 >