mIRC Homepage
Posted By: eawedat asc function - 12/11/11 11:22 PM
hey all,

what's wrong with typing :
Code:
//echo $asc(65)


in the editbox?

/echo: insufficient parameters

thanks.
Posted By: Tomao Re: asc function - 13/11/11 12:24 AM
You missed the -a switch:
//echo -a $asc(65)
Posted By: Riamus2 Re: asc function - 13/11/11 01:02 AM
Why are you using $asc() with a number? Perhaps you meant $chr() ?

$asc() is used with a single character inside the parentheses. It will then tell you the $chr() value of that character. $chr() is the opposite. It will tell you the single character for the number value you enter:

//echo -a $chr(65)
A

//echo -a $asc(A)
65
Posted By: eawedat Re: asc function - 13/11/11 08:23 AM
I know that "-a" option means to echo in active window!

but if i'm already in an active window why should I type it?
By the way it is interesting why $chr(65) DOES work without adding the option "-a".

Code:
//echo $chr(65) 


would echo normally the character "A".

-------------------------------------------------
Riamus2 , i'm just reviewing some built-in functions for a project!

thanks a lot guys.
Posted By: Tomao Re: asc function - 13/11/11 08:34 AM
From my experience, some identifiers require that you include the -a switch to be evaluated properly with the echo command via the edit box. For $asc() identifier, it needs -a, otherwise you'll get an error. For $chr(), though, it doesn't. There has to be a good explanation for this matter, but I'm not certain.
Posted By: eawedat Re: asc function - 13/11/11 08:49 AM
Tomao, I see, is there a list for example that indicates which command has to include -a and which not?
Posted By: argv0 Re: asc function - 13/11/11 09:28 AM
You should read the /help for every command you use. That said, you'll probably only run into this problem with /echo.
Posted By: Riamus2 Re: asc function - 13/11/11 02:24 PM
It's usually a good idea to just be in the habit of including the location you want the echo to appear no matter what you're doing, whether that means including -a or -s or a window name. If you're in the habit of always including the location, then you won't run into these types of problems.

As to why there is an issue with $asc()... it's because you're getting a numerical value and a number after /echo is treated as part of the command. You can see that by just using:
/echo 1

Use /help /echo and you'll understand why a number is part of the command.
Posted By: eawedat Re: asc function - 14/11/11 09:34 AM
by the way you could type any "char" to let echo work with $asc or other functions. it is not only "-a".

for example you could type.
Code:
//echo x $asc(65)
//echo - $asc(65)
//echo . $asc(65)
//echo 4 $asc(65)


thanks.
Posted By: Riamus2 Re: asc function - 14/11/11 11:16 AM
Non-numerical text functions like you'd expect. It will display fine. As I stated, only a number will have problems if you don't include a location. Notice in your last example that the 4 is not shown. A number is part of the command if no location is given before it. If you have nothing after the number, it will give an error because there isn't anything to display. If something is after it, the text will display, but the number will not. It's the color. As I said, read the help file for /echo and it makes sense why it works that way.

And you really need to get rid of the 65 in $asc(). If you want the value from "6", then use $asc(6). Anything following the first character in $asc() is ignored. The result for $asc(6) is the same as for $asc(65) or $asc(60279357823682368972357325) or $asc(6kjasfj32t50jsldkjf345) or whatever else. 65 has no meaning in $asc().
© mIRC Discussion Forums