mIRC Home    About    Download    Register    News    Help

Topic Options
#120548 - 18/05/05 06:12 PM make script paste more lines
gosan Offline
Nutrimatic drinks dispenser

Registered: 12/08/04
Posts: 8
i have a text file which has quotes and it reads them all fine. the only problem is the big quotes, is there a way to make vincula 4.9 or mirc to allow longer pasting??

this is how it looks:
[2:282] O you who believe! When you contract a debt for a fixed period, write it down. Let a scribe write it down in justice between you. Let not the scribe refuse to write as Allah has taught him, so let him write. Let him (the debtor) who incurs the liability dictate, and he must fear Allah, his Lord, and diminish not anything of what he owes. But if the debtor is of poor understanding, or weak, or is unable himself to dictate, then let his guardian dictate in justice. And get two witnesses out of your own men. And if there are not two men (available), then a man and two women, such as you agree for witnesses, so that if one of them (two women) errs, the other can remind her. And the witnesses should not refuse when they are called on (for evidence). You should not become weary to write it (your contract), whether it be small or big, for its fixed term, that is more just with Allah; more solid as evidence, and more convenient to prevent doubts among yourselves, save when it is a present trade which you carry out on the spot among yourselves, then there is no sin on you if you do not write it down. But take witnesses whenever you make a commercial contract. Let neither scribe nor witness suffer any harm, but if you do (such harm), it would be wickedness in you. So be afraid of Allah; and Allah teaches you. And Allah is the All-Knower of each and everything.

i have also tried splitting in to halves with [2:282] on each half, but it only reads one of them and not both.


Edited by gosan (18/05/05 06:21 PM)

Top
#120549 - 18/05/05 10:38 PM Re: make script paste more lines
MikeChat Offline
Hoopy frood

Registered: 12/12/02
Posts: 1245
Loc: California, doooood
when you say "paste" are you reading one very long line into the clipboard and pasting that to the channel all at once? Or are you use the /play -T filename command?

you mentioned it reading the topic " [2:282]" and splitting the data in two secions Both named the same, that won't work as mIRC will do the first [2:282] it sees and stop (as it should).
Rather rename the second half [2:282.1] or something suitable and that should work. You might want to use a timer to delay the second half so you don't lag or flood out.

Top
#120550 - 19/05/05 12:32 AM Re: make script paste more lines
DaveC Offline
Planetary brain

Registered: 26/09/03
Posts: 4230
If you mean a script does this, then its unlikely that its reading it correctly either, that quote above is beyond the 930+-10 characters string length, Even assuming it was under that alot of IRC servers limit message lengths to around 330+-30? (i max mine at 300).


If I assume you can read the whole quotes into a string lets call it %quote you can do this
Code:
var %quote.temp = %quote
while (%quote.temp) {
  msg #channel $left(%quote.temp,300)
  var %quote.temp = $mid(%quote.temp,301)
}

That well send the quote out 300 characters at a time, allowing you to pass under the IRC length limit.

Top
#120551 - 19/05/05 06:32 PM Re: make script paste more lines
gosan Offline
Nutrimatic drinks dispenser

Registered: 12/08/04
Posts: 8
this is the current code i use, where wud i implement your code mate?

on *:text:!quran [*]:#:{
var %parm = $remove($2,[,])
var %chapt = $gettok(%parm,1,58)
var %line_from = $gettok($gettok(%parm,2,58),1,45)
if ((%line_from !isnum) || (%chapt !isnum)) {
msg # Error please use !quran [:]
return
}
var %line_to = $gettok($gettok(%parm,2,58),2,45)
if (!%line_to) { %line_to = %line_from }
if (%line_to !isnum) { msg # Error please use !quran [:] }
msg # S eTahoma;7 Bismillahi Arahmani Araheem 
while (%line_from <= %line_to) {
var %find = $+($chr(91),%chapt,$chr(58),%line_from,$chr(93))
var %line = $read(quran.txt,s,%find)
if ($readn == 0) { msg # No Ayah exists for %find }
else {
var %lines = $wrap(%line, tahoma, 4, 500,1,0), %i = 1
while (%i <= %lines) {
msg # %find $wrap(%line, tahoma, 4, 500,1,%i)
inc %i
}
}
inc %line_from
}
}

Top
#120552 - 20/05/05 10:28 AM Re: make script paste more lines
DaveC Offline
Planetary brain

Registered: 26/09/03
Posts: 4230
Code:
      var %lines = $wrap(%line, tahoma, 4, 500,1,0), %i = 1 
      while (%i &lt;= %lines) { 
        msg # %find $wrap(%line, tahoma, 4, 500,1,%i) 
        inc %i 
      } 


^ that section of your code already breaks it up into chunks, altho breaking it up into chuinks based on a font then sending them to a channel is a bit radical, not everyone well have the same font displaying on there pc, and at the same font size even.

Since that is a proportional font the amount of text can vary greatly, i tested it with "i" and it was 496 characters and with "W" and it was 124. I would suggest dumping this all together, it migth look fine on your screen but its going to look like hell on other peoples.

try

Code:
on *:text:!quran [*]:#:{ 
  var %parm = $remove($2,[,]) 
  var %chapt = $gettok(%parm,1,58)
  var %line_from = $gettok($gettok(%parm,2,58),1,45) 
  if ((%line_from !isnum) || (%chapt !isnum)) { 
    msg # Error please use !quran [:] 
    return 
  } 
  var %line_to = $gettok($gettok(%parm,2,58),2,45) 
  if (!%line_to) { %line_to = %line_from } 
  if (%line_to !isnum) { msg # Error please use !quran [:] } 
  msg # S eTahoma;7 Bismillahi Arahmani Araheem 
  while (%line_from &lt;= %line_to) { 
    var %find = $+($chr(91),%chapt,$chr(58),%line_from,$chr(93)) 
    var %line = $read(quran.txt,s,%find) 
    if ($readn == 0) { msg # No Ayah exists for %find  } 
    else {
       var %quote.temp = %line
       while (%quote.temp) {
         msg # $left(%quote.temp,300)
         var %quote.temp = $mid(%quote.temp,301)
       }
    } 
    inc %line_from 
  } 
}

Top
#120553 - 20/05/05 11:55 AM Re: make script paste more lines
gosan Offline
Nutrimatic drinks dispenser

Registered: 12/08/04
Posts: 8
the code works but again doesnt display with that long verse above frown

note: i use it in msn groups


Edited by gosan (20/05/05 11:56 AM)

Top
#120554 - 20/05/05 11:58 AM Re: make script paste more lines
gosan Offline
Nutrimatic drinks dispenser

Registered: 12/08/04
Posts: 8
Quote:

Rather rename the second half [2:282.1] or something suitable and that should work. You might want to use a timer to delay the second half so you don't lag or flood out.


im just thinking is there a possible way to modify my current code and add an "if" .1 is on the next [ : ] to msg # with it also?

Top
#120555 - 20/05/05 08:20 PM Re: make script paste more lines
MikeChat Offline
Hoopy frood

Registered: 12/12/02
Posts: 1245
Loc: California, doooood
While I have not used the $wrap befor, it looks like maybe you have one parameter too big.

Quote:

else {
var %lines = $wrap(%line, tahoma, 4, 500,1,0), %i = 1
while (%i <= %lines) {
msg # %find $wrap(%line, tahoma, 4, 500,1,%i)
inc %i
}

try changing that 500 to 300 and see if that helps, again I do not know as I have not used $wrap

Also, as Dave pointed out, you will see the font specified but everyone else will see the font they have set in mIRC. I don't know if that matters to you as much as getting around the text/line length issue.

Top
#120556 - 21/05/05 01:17 AM Re: make script paste more lines
DaveC Offline
Planetary brain

Registered: 26/09/03
Posts: 4230
I told you it wouldnt work on long verses, becuase the string length limit. you have to do alot of rewriting to manage longer lines

Try this ...
note the blue bit, you can set these values to change the length of each messaged line (remember that while you see it lines above around 300 dont get sent in full), and you can also set how largeer range someone can request ire: 2:200-300 but not 2:200-800

Code:
;on *:text:!quran [*]:#:{
   [color:blue]var %line.length = 300
  var %line.range.size = 100[/color]
  ;
  var %parm = $remove($2,[,]) 
  var %chapt = $gettok(%parm,1,58)
  var %line_from = $gettok($gettok(%parm,2,58),1,45) 
  var %line_to   = $iif($gettok($gettok(%parm,2,58),2,45),$v1,%line_from)
  if ((%chapt !isnum 1-) || (%line_from !isnum 1-) || (%line_to !isnum $+(%line_from,-))) { 
    msg # Error please use !quran [&lt;Num1&gt;:&lt;Num2&gt;-&lt;Num3&gt;] Num1 is chapter, Num2 is start line, Num3 is optional end line.
  } 
  else {
    if ($calc(%line_to - %line_from) &gt; %line.range.size) {
      echo -st msg # Try keeping the range with in real limits!
    }
    else {
      ;
      ;*** Lets get it done! ***
      ;
      var %filesize = $file(quran.txt).size
      .fclose quran.txt*
      .fopen quran.txt quran.txt
      echo -st msg # S eTahoma;7 Bismillahi Arahmani Araheem 
      var %line_at = %line_from
      while (%line_at &lt;= %line_to) {
        var %find = $+($chr(91),%chapt,$chr(58),%line_at,$chr(93)) 
        .fseek quran.txt 0
        .fseek -w quran.txt $+(%find,*)
        if ($fopen(quran.txt).pos == %filesize) {
          if (%line_from == %line_to) {
            ;say it dont exist only if its was only one line requested
            msg # %find No Ayah exists.
          }
        } 
        else {
          !.echo -q $fread(quran.txt,10240,&amp;binvar)
          breplace &amp;binvar 13 0
          breplace &amp;binvar 10 0
          var %line.end = $calc($iif($bfind(&amp;binvar,1,0),$v1,10241) - 1)
          var %line.start = $calc($len(%find) + 1)
          while (%line.start &lt;= %line.end) {
            msg # %find $bvar(&amp;binvar,%line.start,%line.length).text
            inc %line.start %line.length
          }
        } 
        inc %line_at 
      }
      .fclose quran.txt*
    }
  }
}



To anyone good with regex, someone else might like to improve the matchtext with a regex, but im not that hot on them.
The match text needs to match !quran [nnn:nnn] & !quran [nnn:nnn-nnn] nnn being a number number of digits unknown.

Top
#120557 - 21/05/05 01:52 AM Re: make script paste more lines
Kelder Offline
Hoopy frood

Registered: 12/04/03
Posts: 701
Loc: Leuven, Belgium
Code:
on $*:text:/!quran \[(\d+)\x3A(\d+)(-(\d+))?\]/:#:{
  var %line.length = 300
  var %line.range.size = 100
  var %chapt = $regml(1)
  var %line_from = $regml(2)
  var %line_to   = $iif($regml(4),$v1,%line_from)
  if ($calc(%line_to - %line_from) &gt; %line.range.size) || ($v1 &lt; 1)) {
    echo -st msg # Try keeping the range within real limits!
  }
  else {
  ;
  ;*** Lets get it done! ***
  ;
  var %filesize = $file(quran.txt).size
  .fclose quran.txt*
  .fopen quran.txt quran.txt
  echo -st msg # S eTahoma;7 Bismillahi Arahmani Araheem 
  var %line_at = %line_from
  while (%line_at &lt;= %line_to) {
    var %find = $+([,%chapt,:,%line_at,])
    .fseek quran.txt 0
    .fseek -w quran.txt $+(%find,*)
    if ($fopen(quran.txt).pos == %filesize) {
      if (%line_from == %line_to) {
        ;say it dont exist only if its was only one line requested
        msg # %find No Ayah exists.
      }
    }
    else {
      !.echo -q $fread(quran.txt,10240,&amp;binvar)
      breplace &amp;binvar 13 0
      breplace &amp;binvar 10 0
      var %line.end = $calc($iif($bfind(&amp;binvar,1,0),$v1,10241) - 1)
      var %line.start = $calc($len(%find) + 1)
      while (%line.start &lt;= %line.end) {
        msg # %find $bvar(&amp;binvar,%line.start,%line.length).text
        inc %line.start %line.length
      }
    }
    inc %line_at
  }
  .fclose quran.txt*
}


Here's your regex stuff :tongue:

I'm not quite happy with the whole binary var stuff, my suggestion would be to open the file wsith some text editor and making it wrap at about 200 characters. Then search for the correct [1:2] stuff and continue reading lines until you reach a line that starts with [1:3] or just starts with a [ even.

Another way, put the [1:2] tags on their own lines, with all relevant text on following lines (how many doesn't matter, just make sure they're not long that 200 characters or so. Then do //play -t $+ 1:2 quran.txt $chan to send the text to channel, with 1second intervals so you won't flood off.

Top
#120558 - 21/05/05 11:22 AM Re: make script paste more lines
DaveC Offline
Planetary brain

Registered: 26/09/03
Posts: 4230
Good value on the regex and the updates, (just forgot a last } bracket), but I see no reason to not use binarys, Its not like its really very complexe what i did, i searched for the line, read it in, changed the cr and lf to zerobytes, then cut the line up into parts and displayed it.

I felt the idea of going into the text file and chopping the lines up, while acceptable, would be quite time consuming, and the play idea is perfectly fine you still have to loop through multiple topics (not that i dont), and Im assuming he has flood protection on to stop a channel flood.



Edited by DaveC (21/05/05 11:25 AM)

Top