mIRC Homepage
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.
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?
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.
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:
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
Ah, tricky little bugger. Thanks a ton.
On top of the option Starbucks gave, I use the following:

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.
I guess this is a redundant version for $remove($didtok($dname,$did,10),$chr(10)) (unless $remove() is slower or the like)...
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.
© mIRC Discussion Forums