mIRC Homepage
Posted By: Bullseye multiple lines - 16/03/06 10:27 AM
hi,
I have this script that reads from a text file.
The code I use is:
Code:
if ($did == 2) {
      var %ik = $did(8).text
      var %nick = $did(7).seltext
      var %msg = msg $did(8)
      var %act = describe $did(8)
      $read(slaps.txt,t) 
    }
  

In the text file the line looks like this:
Code:
 %msg 3Here's 2 %ik      ....did you need me %nick
 

But when I want to show a popup with multiple lines it shows it as 1 line.
Normaly you use | (see code below)to separate and start the next line but that doesn't work.

Code:
%msg 3Here's 2 %ik          | %msg     did you need me %nick 

Anybody wanna help

Greetzz
Posted By: vexed Re: multiple lines - 16/03/06 01:01 PM
/help $&

%msg 3Here's 2 %ik $&
....did you need me %nick
Posted By: hixxy Re: multiple lines - 16/03/06 01:05 PM
Code:
menu menubar {
  Cool popup:{
    say 1
    say 2
  }
}
Posted By: Bullseye Re: multiple lines - 16/03/06 01:20 PM
I'll place my code of the script.

Code:
 dialog slap {
  title "flupScript Slap Manager - uitgebreid door Bullseye"
  size -1 -1 290 158
  option dbu
  list 1, 0 16 217 129, size
  button "Random Slap", 2, 1 145 37 12
  button "Selected Slap", 3, 59 145 37 12
  button "Delete Slap", 4, 180 145 37 12
  button "Add Slap", 5, 120 145 37 12
  combo 8, 223 16 60 140, size vsbar drop
  list 7, 223 27 60 117, size
  text "flupScript Slap Manager - uitgebreid door Bullseye", 6, 7 3 140 8
  edit "", 9, 222 3 61 10, read
}

on *:dialog:slap:*:*:{
  if (!$istok(mouse edit,$devent,32) && $did != 3 && $active != @slap.preview && $window(@slap.preview)) { window -c $ifmatch }
  if ($devent == init) {
    did -r slap 1 
    loadbuf -o slap 1 slaps.txt 
    did -r slap 9 
    did -a slap 9 Total Slaps: $lines(slaps.txt) 
    set %schan $chan(0)
    while (%schan > 0) { 
      did -a slap 8 $chan( $+ %schan $+ ) 
      dec %schan 
    }
  }
  if ($devent == sclick) {
    if ($did == 1) {
      if ($did(1).seltext) {
        preview
      }
    }
    if ($did == 8) {
      var %schans $did(8) 
      did -r slap 7 
      var %snicks $nick($did(8),0)
      while (%snicks > 0) {
        did -a slap 7 $nick($did(8), %snicks)
        dec %snicks
      }
    }
    if ($did == 5) {
      write slaps.txt $?="Slap to add" 
      did -r slap 1 
      loadbuf -o slap 1 slaps.txt 
      did -r slap 9
      did -a slap 9 Total Quotes: $lines(slaps.txt) 
    }
    if ($did == 4) {
      write -dl $+ $did(1).sel slaps.txt 
      did -r slap 1 
      loadbuf -o slap 1 slaps.txt
      did -r slap 9 
      did -a slap 9 Total Quotes: $lines(slaps.txt) 
    }
    if ($did == 3) {
      var %ik = $did(8).text
      var %nick = $did(7).seltext
      var %msg = msg $did(8)
      var %act = describe $did(8)
      $read(slaps.txt,t, $did(1).sel) 
    }
    if ($did == 2) {
      var %ik = $did(8).text
      var %nick = $did(7).seltext
      var %msg = msg $did(8)
      var %act = describe $did(8)
      $read(slaps.txt,t) 
    }
  }
}

menu channel {
  .Slap Manager:dialog -m slap slap
}

alias -l preview {
  var %font = $window(Status Window).font,%size = $window(Status Window).fontsize,%x = $calc($dialog(slap).x +1),%y = $calc($dialog(slap).y + 346),%text = $read(slaps.txt, $did(1).seltext),%w = $iif($calc($window(-1).w - %x) < 602,$calc($v1 - 4),$v2),%text.w = $width($burcwrap(%text,%font,%size,$calc(%w -4),1,1),%font,%size,0,1),%w = $calc(%text.w + 6),%lines = $burcwrap(%text,%font,%size,%w,1,0),%line.h = $height(%text,%font,%size),%text.h = $calc(%lines * %line.h),%h = $iif($calc($window(-1).h - %y) < $calc(%text.h + 6),$calc($v1 -2),$v2)
  if ($window(@slap.preview)) {
    var %wnd = $ifmatch
    window -f %wnd %x %y %w %h
  }
  else {
    window -pdk0fhB +dL @slap.preview %x %y %w %h
  }
  window -o @slap.preview
  drawrect -rf @slap.preview 15794175 1 0 0 %w %h
  ;15794175
  drawrect -r @slap.preview 0 1 0 0 %w %h
  var %q = 1
  while (%q <= %lines) {
    var %drawtext = $burcwrap(%text,%font,%size,$calc(%w -4),1,%q)
    drawtext -bpr @slap.preview $color($color(action)) 15794175 %font %size 4 $calc((%q -1) * %line.h +2) %drawtext
    inc %q
  }
}
menu @slap.preview {
  fix position:preview
}
on *:appactive:{
  if (!$appactive && $window(@slap.preview)) { window -c @slap.preview }
}
alias -l burcwrap {
  var %text = $1, %c $chr(44)
  tokenize 44 $+($2,%c,$3,%c,$4,%c,$iif($0 == 5,1 $+ %c),$$5,%c,$6)
  if ($istok(1.0,$5,46) == $true) {
    return $wrap(%text,$1,$2,$3,$4,$5)
  }
  var %regex = /(\d{0,2})/g, %regex2 /\d{0,2},(\d{1,2})/g, %b = 1,
  var %str, %cc1, %cc2
  while (%b < $($ $+ $0,2)) {
    %str = %str $+ $wrap(%text,$1,$2,$3,$4,%b)
    inc %b
  }
  if ($regex(%str,%regex)) %cc1 = $regml($regml(0))
  if ($regex(%str,%regex2) > 0) %cc2 = $regml($regml(0))
  if (%cc1 $+ %cc2) var %cc = $+(,%cc1,$iif(%cc2,$chr(44) $+ %cc2))
  return $iif(2 \\ $count(%str,) ,) $+ $iif(2 \\ $count(%str,),) $+ $&
    $iif(2 \\ $count(%str,),) $+ $iif(%cc,%cc) $+ $wrap(%text,$1,$2,$3,$4,$5)
}
 


this reads the text file with the popups
Posted By: MikeChat Re: multiple lines - 16/03/06 07:24 PM
since ID 8 is a combo box, you need to use .seltext
var %msg = msg $did(8).seltext

that is just on a quick glance through, there may be other things but off the top thats what I see.
Posted By: Bullseye Re: multiple lines - 17/03/06 06:43 AM
$read(slaps.txt,pt, $did(1).sel)

That is the answer.
it lets the | works as it should.
I tryed it but it didn't work.
somehow after a reboot of my client it did work.
Anyway problem solved. smile

***
my popups in the text file look like this:

%act walks over to %nick and kicks his butt.

Is it possible to let it look like this:

kick butt*%act walks over to %nick and kicks his butt.

Returning only:

%act walks over to %nick and kicks his butt.

Now it return "kick butt" aswell.
My guess is that if it can be done it has to be with gettok and I'm not that good yet so some help will be welcome smile
Posted By: xDaeMoN Re: multiple lines - 17/03/06 07:06 AM
Yes, you would use $gettok

Code:
 $gettok($read(slaps.txt,pt, $did(1).sel),2,42) 


42 is the * ( //echo -a $asc(*) )
2 is the second token in the string delimited by the *

For more info, /help $gettok
© mIRC Discussion Forums