mIRC Homepage
Posted By: rennir Requesting change to text input. - 18/01/04 03:44 PM
I wrote up this script that I use to cut up my input so that it comes out in mulitple spats when I'm typeing it up in IRC. A lot of what I'm doing on irc, requires this. My script looks like this, it's found in the Events section.

Code:
on 1:input:*: { 
  %usertext  = $1-
  %textlen   = $len(%usertext)
  %firsttime = 1
  if (%textlen > 400) {
    while (%textlen > 400) { 
      %pos = 400 
      :loop 
      if %pos < 370 goto end | 
      %chara = $mid(%usertext, %pos, 1) 
      if $asc(%chara) == 32 goto end | 
      %pos = %pos - 1 
      goto loop 
      :end 
      %outtext = $left(%usertext, %pos - 1) 
      if (%firsttime == 0) { 
        /say <-cont-> %outtext <-next-> 
      }
      if (%firsttime == 1) { 
        %prefix = $left(%outtext, 4) 
        %mtch = { /me  } 
        if (%prefix == %mtch) {
          %outtext <-next->
        } 
        if (%prefix != %mtch) {
          /say %outtext <-next->
        }
        %firsttime = 0 
      } 
      %cuttext  = $remove(%usertext, %outtext) 
      %usertext = %cuttext
      %textlen  = $len(%usertext)
    } 
    /say <-cont-> %usertext <-end->
    /halt
  }
}
 


The code is sloppy because I found I was haveing difficulty with some details. maybe someone can help me out but that's beyond the point. Here's the REAL point.

If I type something too long in the main text window, mIRC Automaticly hits Return when I reach the end which is what I DON'T want, but the text is far too long to even store as a variable and my script fails, hence people see only one line of cropped text thrown back at them and I'm forced to go back and repost what I'm saying, and start a new post all together to finish it up which isn't what I'm aiming for.

Yes, I want to enter in a near novels worth of text into the input bar, and have it neatly cut up and pasted to the server automaticly via this or another script. If the input control can't have it's buffer increased to support more characters, can then it NOT automaticly hit Return when I reach the end?

Rennir
Posted By: KingTomato Re: Requesting change to text input. - 18/01/04 05:16 PM
Cross posting is not neccisery. Posting on multiple sections of the forus is not needed, as most whom help frequent all the sectison. Additonally, you just come accross as demanding or impatient. Please keep your posts to one topic, and one topic only.
Posted By: rennir Re: Requesting change to text input. - 18/01/04 09:23 PM
Sorry, i really just wanted to post about an issue I've been faceing lately and hope to see it addressed. The key thing is, The fact that mIRC hits enter prematurely AND, that if the input is too long to be stored in a variable, it fails out is very annoying to me. This post was ment to address one aspect, the 2nd post was ment to address the script itself. I'm sorry though if everything seems messed up.

Rennir
Posted By: DaveC Re: Requesting change to text input. - 19/01/04 10:10 AM
i had some time to kill, so wrote this for you.

It seems to work ok, as far as i tested it.

Code:
 
;
;
; Input is not sent to channel until you press - (minus) on its own on a line
;
; I played with using $ctrlenter as the despooler trigger, but it was effected by ctrl-v inserts to the line, setting it off if the line exceeded the input buffer length.
;
;
on *:input:*:{
  ;
  ;
  ; only acts on input from a channel and not if it starts with a / unless its a /me
  ;
  ;
  if ( $chan != $null ) && ( ( $left($1,1) != / ) || ( $1 == /me ) ) {
    ;
    var %cid.chan = $+($cid,.,$chan)
    ;
    if ( $hget( [ $+(Input.Buffer.,%cid.chan) ] ,0 ).item == 0 ) {
      hfree -w [ $+(Input.Buffer.,%cid.chan) ]
      hmake [ $+(Input.Buffer.,%cid.chan) ]
    }
    ;
    ;
    ; Input Spooler
    ;
    ;
    if ( $1- != - ) {
      var %count = $hget( [ $+(Input.Buffer.,%cid.chan) ] ,0).item
      var %pos = 1
      var %text = $mid($1-,%pos,400)
      while ( %text != $null ) {
        if ( $len($deltok(%text,-1,32)) < 370 ) {
          %text = $left(%text,370)
          inc %pos 370
        }
        else {
          %text = $deltok(%text,-1,32)
          inc %pos $len(%text)
          inc %pos
        }
        inc %count
        hadd [ $+(Input.Buffer.,%cid.chan) ] %count %text
        ;
        var %text = $mid($1-,%pos,400)
      }
    }
    ;
    ;
    ; Input Despooler
    ;
    ;
    else {
      ;
      if ($gettok($hget( [ $+(Input.Buffer.,%cid.chan) ] , 1),1,32) == /me ) {
        var %describe = $true
        hadd [ $+(Input.Buffer.,%cid.chan) ] 1 $gettok($hget( [ $+(Input.Buffer.,%cid.chan) ] , 1),2-,32)
      }
      else {
        var %describe = $false
      }
      ;
      var %count = 1
      var %total = $hget( [ $+(Input.Buffer.,%cid.chan) ] ,0).item
      ;
      while (%count <= %total ) {
        ;
        ;
        ;$iif((%describe = $true),describe,msg) $chan $iif((%count > 1),<-cont->) $hget( [ $+(Input.Buffer.,%cid.chan) ] , %count) $iif((%count < %total),<-next->,<-end->)
        ;^ above remarked as it would flood me off the irc server
        ;
        .timer 1 %count $iif((%describe = $true),describe,msg) $chan $iif((%count > 1),<-cont->) $hget( [ $+(Input.Buffer.,%cid.chan) ] , %count) $iif((%count < %total),<-next->,<-end->)
        ;^ above timer used instead to timer the messages out.
        ;
        ;
        %describe = $false
        inc %count
      }
      hfree -w [ $+(Input.Buffer.,%cid.chan) ]
    }
    ;
    ;
    ; Spooled or Despooled halt the original text
    ; 
    ;
    halt
  }
}


I dont think the [ ] were needed in here at all actually but i left them in just in case, some times i have found you need em for some things, and others you dont
Posted By: rennir Re: Requesting change to text input. - 19/01/04 04:16 PM
Very interesting script, I may take this and modify it some to suit my needs. Also It's nice to actually read a script and now begin to understand more how the syntax of the language works actually. I had a lot of problems with if-else statements and now I see maybe what that's the case.

Okay, I'm goign to study your script some and try to see what it does and why it works. Thanks for the big help!

Rennir
Posted By: cold Re: Requesting change to text input. - 19/01/04 06:39 PM
About the evaluation brackets, you don't need them there.
Posted By: DaveC Re: Requesting change to text input. - 20/01/04 03:38 AM
in the first draft of the script i had used [ $+(%,Input.Buffer.,$cid.chan,.count) ] to keep count on the number of lines there were before i woke up and though doh the hash table keeps track of that itself with $hget( [ $+(Input.Buffer.,%cid.chan) ] ,0).item or should I say ($hget($+(Input.Buffer.,%cid.chan),0).item, by then the brackets had migrated out and it was working so i decided not to bother with checking if i could withdraw them, dont fix whats not broken as they say.
It was the reason i ended up posting about a looking for doc on good [ ] explanations.

I still wonder why he needs to type in 1000's of characters of text in one shot, byt the time id get that much typed the conversation would have changed subject.
© mIRC Discussion Forums