mIRC Homepage

Simple solution to Spaces. $echo() $msg() $quote()

Posted By: Raccoon

Simple solution to Spaces. $echo() $msg() $quote() - 24/12/14 11:57 PM

Dear Khaled,

One of the still pervasive weaknesses of mIRC script is the inability to preserve and output a sequential string of neighboring spaces. Over the years many strides have been made to allow working with sequential spaces (eg: /returnex) but the one major hurtle is doing anything to output or display strings that contain space pairs.

Without making any major changes to mIRC's scripting engine or parsing routines, I would like to recommend what I believe is the simplest stop-gap solution that should make most of us happy:

Allow several commands such as /echo and /msg and /quote and /write to work as an identifier. Since identifiers already preserve sequential spaces, this becomes a simple fix.

noop $echo(-tic,notice,#mIRC,$1-)
noop $msg(#mIRC,$1-)
noop $quote($1-)
noop $write(-c,output.txt,$1-)

Doing this would make my Christmas very Merry.
~ Raccoon

Happy New Year! smile
Posted By: Raccoon

Re: Simple solution to Spaces. $echo() $msg() $quote() - 02/01/15 05:50 AM

Alternately, if you allow us to use &binvars in these commands, or specifically create /bmsg /becho commands, that would be very suitable as well.
Posted By: Plornt

Re: Simple solution to Spaces. $echo() $msg() $quote() - 14/08/15 08:52 AM

Understand that this is old and has been suggested a million times before but I really want something like this. Its an absolute pain dealing with spaces. The only solution people come up with are dirty hacks and the only decent suggestion which is to use a dll no longer exists.

I don't see why this would be difficult to implement. I would be fine with echo and raw supporting binvars.
Posted By: Sat

Re: Simple solution to Spaces. $echo() $msg() $quote() - 14/08/15 09:10 AM

Originally Posted By: Plornt
the only decent suggestion which is to use a dll no longer exists.

While I don't disagree with your post in general, I actually do keep spaces.dll updated. You can always find the latest version at http://www.xise.nl/mirc/ .
Posted By: Wims

Re: Simple solution to Spaces. $echo() $msg() $quote() - 14/08/15 09:10 AM

The spaces problem can usually be worked around easily, the dll solution still exist, unsure why you say otherwise

As far as the suggestion is concerned, it's not about the difficulty of the implemtation, it's about being consistent, in the past, all commands could be called as identifiers, this functionnality was removed because it would allow users to easily get owned, by $quit for example. So bringing back the feature which was removed for 'security' reason would be a bit illogical.
It can be argued that only the commands mentioned in the suggestion could be made as identifier, but I imagine you would quickly start seeing people suggesting others commands, and it wouldn't really make sense to accept one and not the others.
Also keep in mind that if mIRC wasn't handling spaces the way it does, it would be a much bigger pain, you would have to use $trim everywhere and handle the removal of consecutives spaces yourself, you DO want mIRC to handle spaces the way it does 99% of the time, it's better that way.
Posted By: Sat

Re: Simple solution to Spaces. $echo() $msg() $quote() - 14/08/15 09:17 AM

Just as a constructive reply: my previous suggestion for doing this was to add a new command prefix, say ^, which does preserve spaces (as part of actual $n tokens) when tokenizing the command line. This would be backwards compatible, work with all commands, and, as far as I could tell, it would be fairly easy to implement.
Posted By: Wims

Re: Simple solution to Spaces. $echo() $msg() $quote() - 14/08/15 09:26 AM

You're only potentially breaking all custom aliases starting with ^ whistle
Seriously though, this would be a way, people in the past have suggested others ways, like a $space construct (which I personnally prefer):
Code:
//echo -a a    b $space c    d $space e   f
which would display "a b c d e f"
Another suggestion was a new directive, but I don't like it much because you can't use it with one liner:
Code:
alias name {
#space
echo -a this   support   consecutives   spaces etc
#space
echo -a this doesn't
}


$space is really the best because you can alter the way mIRC parse the line directly within the line, allowing alternating between current tokenization and a new tokenization
Posted By: Sat

Re: Simple solution to Spaces. $echo() $msg() $quote() - 14/08/15 09:34 AM

Keep in mind this isn't about putting literal spaces into a script - it's about preserving spaces returned by identifiers or in variables. Edit: oh I see what you mean. Such a $space would be much harder to implement though, if possible at all. Right now, the command line parser first evaluates the line, and then tokenizes it. Support for $space would basically require the evaluation routine to provide feedback to its caller on the byte ranges that are to have their spaces preserved, which would then have to be taken into account by the tokenizer. This is somewhat messy and I'm not exactly sure what would be gained by such flexibility either. Then again I'd be happy with it anyhow of course.

Screw people who make custom aliases that start with a ^, though.
Posted By: Plornt

Re: Simple solution to Spaces. $echo() $msg() $quote() - 14/08/15 03:34 PM

Originally Posted By: Sat
Originally Posted By: Plornt
the only decent suggestion which is to use a dll no longer exists.

While I don't disagree with your post in general, I actually do keep spaces.dll updated. You can always find the latest version at http://www.xise.nl/mirc/ .


Ah yea, sorry forgot to update my reply there, did eventually find it and it works great (thanks!) just originally everywhere was linking to the now defunct mirc.net

But yeah I understand that it may not be about difficulty now. Not sure how they would go about doing it but having a generic binvar accepting raw command to send serverside messages would be great. For built in commands ie, echo etc not sure how you would go about doing it. I dont mind the ^ prefix idea. Just feel like it really should have been addressed by now with a proper solution.

Perhaps some form of string literal using backticks for maximum backwards compatability. Or go the javascript route and force some sentence (eg js's "use strict") at the top of the script which then enables the use of string literals? That I can forsee being a lot of work though.

As an example:

Code:
use strict

alias echoMe {
  echo -a "Hello           This is a message"
}


Would then do what you expect.
Posted By: MeStinkBAD

Re: Simple solution to Spaces. $echo() $msg() $quote() - 18/08/15 01:52 AM

Originally Posted By: Raccoon
One of the still pervasive weaknesses of mIRC script is the inability to preserve and output a sequential string of neighboring spaces. Over the years many strides have been made to allow working with sequential spaces (eg: /returnex) but the one major hurtle is doing anything to output or display strings that contain space pairs.


The most serious problem I've encountered is when encountering a file with a name that starts, or contains sequential spaces.

At one time it was possible to use $shortfn to obtain the 8.3 "old-skool" name since Windows always tried to preserve them. Formatting a drive as NTFS via Windows will no longer enable short filename support by default. And the ExFAT filesystem doesn't support short file names at all.

I've always considered this a bug. It should have been corrected a long long time ago. I know that the consequences for existing scripts could potentially be enormous, but that's a short term problem. Despite living in the short term for most of my life, we all would have been happy in the end.

I think the solution to this would be to fix the parsing engine to properly preserve spaces for /commands and /aliases and wherever else. But role it out slowly... so script developers could choose to enable it. For example: via a hidden menu option that would only appear in the "Tools" menu when the shift key is pressed.
Posted By: Wims

Re: Simple solution to Spaces. $echo() $msg() $quote() - 18/08/15 07:55 AM

$space would be best as far as the scripter is concerned, the implemention details doesn't matter much, we're asking for the possibility to get our string intact in a scripting language, not the moon! Check out mestinkbad's post, you cannot workaround that problem, it's a serious thing although I guess you also screw people using consecutive/leading/trainling space in their filename wink
The flexibility is that we could get mIRC to use a mix of the old and the new tokenization method in one line, like I said we more than often want the old/current tokenization.

Quotes would also achieve that flexibility, but it would break backward comp
© 2020 mIRC Discussion Forums