mIRC Homepage

Dialogs, $did, and text on multi-line editboxes

Posted By: zac

Dialogs, $did, and text on multi-line editboxes - 14/06/04 09:54 PM

This is partially a feature request and partially a complaint/bug report. I'm filing it under bug report, but if it's misfiled feel free to move it.

In mIRC dialogs, edit boxes can be multi-lined, allowing you to access them with $did(<name>, <id>, <line>). However, this is highly limiting at times.

When the multi-line text contain a word or words which must be wrapped, mIRC adds a space in to compensate. However, this makes the data impossible to be put back together properly.

$did(<name>, <did>, 1) $+ $did(<name>, <did>, 2) could yield either "wordword" or "word word" depending on how mIRC wraps it. Without the $+, you may end up with "word word" when it was originally "wordword". Both not good situations.

Windows can copy and paste the editbox fine without the random-space issue. This is one of the only good parts, as I can still deal with the data on some levels.

What I'm requesting is a method to get the raw text from the editbox's multiple lines, without mIRC's space-wrapping. It seems possible, and it'd be wholly helpful.

If it's possible as it is now, please do share and highlight my ignorance.
Posted By: starbucks_mafia

Re: Dialogs, $did, and text on multi-line editboxes - 14/06/04 11:25 PM

I'm trying to get mIRC to do what you're saying but it's not adding any extra spaces. Could you give an example (simple dialog table + input text) which reproduces the problem?

Even if this isn't a bug, it might be nice if there was a $did(dialog, id, &binvar) form of the identifier.

Edit: I'm using Win98SE with mIRC 6.15. What OS/mIRC version are you getting this bug on?
Posted By: zac

Re: Dialogs, $did, and text on multi-line editboxes - 14/06/04 11:34 PM

Code:
dialog -l example {
  title "Example"
  size -1 -1 102 68
  option dbu
  edit "", 1, 1 1 100 50, multi autovs vsbar
  button "Echo", 2, 34 53 37 12
}

on *:dialog:example:sclick:2:{
  var %i = 1
  while ($did($dname, 1, %i)) { 
    echo -a $ifmatch
    var %full = %full $ifmatch
    inc %i
  }
  echo -a Reconstructed: %full
}

alias example dialog -m example example


Type /example and type text.

Make one long string (longer than the editbox allows per one line), and hit echo. It'll show it broken up. Sure, you say, use $+.. but...

Type a long string, and maybe 5-6 chars before the end of that line, hit space, and start typing again. Do a very long string after. You have a legitimate break here, and a $+ would join the two spaced strings.

Now copy either of the examples above fom the editbox and paste into notepad. You'll see it's reconstructed correctly.
Posted By: starbucks_mafia

Re: Dialogs, $did, and text on multi-line editboxes - 14/06/04 11:55 PM

The problem isn't in $did(), it's in the way you're storing what it's returning. mIRC variables will have spaces trimmed from the end of them so when you add a line to the %full variable which has a space on the end it's being stripped and it's as if the space never existed. The solution comes from the fact that spaces are not stripped fromt the beginning of a variable, so you must construct it in reverse. Use this code instead and you'll get the correct text:
Code:
on *:dialog:example:sclick:2:{
  var %i = $did($dname, 1).lines
  while %i { 
    echo -a $did($dname, 1, %i)
    var %full = $did($dname, 1, %i) $+ %full
    dec %i
  }
  echo -a Reconstructed: %full
}
Posted By: zac

Re: Dialogs, $did, and text on multi-line editboxes - 15/06/04 12:00 AM

Ah, tricky little bugger. Thanks a ton.
Posted By: LifeIsPain

Re: Dialogs, $did, and text on multi-line editboxe - 15/06/04 06:06 AM

On top of the option Starbucks gave, I use the following:
Code:
$replace($didtok($dname,$did,10),$chr(10),$null)

well, you would need to replace the $did with your actual did if applicable, as well as $dname, found it from somewhere on the forums, but forget who said it.
Posted By: cold

Re: Dialogs, $did, and text on multi-line editboxe - 24/06/04 02:20 AM

I guess this is a redundant version for $remove($didtok($dname,$did,10),$chr(10)) (unless $remove() is slower or the like)...
Posted By: LifeIsPain

Re: Dialogs, $did, and text on multi-line editboxe - 24/06/04 04:43 PM

You know, I really am not sure, $remove would make more sence, but I saw it used as $replace on here somewhere I am mostly sure by some big poster and decided to stay with it. So I don't know if it was benchmarked, or if I remember wrong. But hey, this way uses less characters.
© 2022 mIRC Discussion Forums