mIRC Homepage

if ($1 ischar) { echo Yes it is! }

Posted By: westor

if ($1 ischar) { echo Yes it is! } - 03/12/09 03:21 PM

Hello,

I wonder if this could be possible to be added into the mIRC

e.g:

ON *:TEXT:*:?: { if ($1- ischar) { echo -s WARNING: The $nick just used the $v1 character's private } }

Thanks, ^WeSt
Posted By: 5618

Re: if ($1 ischar) { echo Yes it is! } - 03/12/09 03:29 PM

Could you please elaborate?
Posted By: Wims

Re: if ($1 ischar) { echo Yes it is! } - 03/12/09 03:31 PM

Do you mean if ($len($1-) == 1) { ?
If so, probably won't be added, you're too lazy seriously ~
Posted By: Riamus2

Re: if ($1 ischar) { echo Yes it is! } - 03/12/09 03:40 PM

Yeah, please elaborate on what you mean. ischar to mean seems like you're wanting to know that it's a character (i.e. not a number of symbol -- isalplha handles that). But what you put as the warning doesn't seem to make sense -- "character's private"?

Also, keep in mind that $v1 is the result of the check. An is___ check will return $true or $false, which I doubt is what you're expecting in your example.

If you meant it's a single character,then $len() == 1 is just as easy as mentioned. If you mean something else entirely, please explain. A sample input and output for the example script would help us to understand what you mean.
Posted By: Wims

Re: if ($1 ischar) { echo Yes it is! } - 03/12/09 03:44 PM

Quote:
Also, keep in mind that $v1 is the result of the check. An is___ check will return $true or $false, which I doubt is what you're expecting in your example.
So wrong, $v1 return the first part of the condition.
Posted By: Riamus2

Re: if ($1 ischar) { echo Yes it is! } - 03/12/09 03:49 PM

You're right. I always use it with X == Y format and when I actually think of that, I see my error. I wasn't thinking of is___ correctly (that "is" is basically the == and ___ is the second part of the condition). I was incorrectly thinking of it as all the first part of the condition. Oops. smile

Shows how much I use those is___ checks while also displaying the result using $v1... i.e. never.
Posted By: argv0

Re: if ($1 ischar) { echo Yes it is! } - 04/12/09 03:19 AM

if you actually mean to test $len($1) == 1 like the others are assuming, that should not be considered the behaviour of "ischar" imo.

The behaviour of the is* text matchers (isalpha, isalnum) don't test single characters, so if "ischar" would be misleading. "ischar" looks like you're asking the question: is $1 a set of characters? ..similar to "isalpha" (is $1 a set of alpha chars).

If this is really about testing a single char, you'd want if ($1 issinglechar), but that's just getting superfluous. Just use the len check if that's what you want.

If you mean something else, you need to *explain*. You can't expect people to understand you from a single line of an ambiguous example.
Posted By: westor

Re: if ($1 ischar) { echo Yes it is! } - 04/12/09 04:02 PM

I mean man when the $1- has any character's in then echo that the $1- has characters the $v1 was an silly example to saw you what i mean

e.g:

if ($1- ischar) { echo Yes the $1- is a char! }
Posted By: Zed

Re: if ($1 ischar) { echo Yes it is! } - 04/12/09 04:04 PM

A simple solution can be this:

if ($0) echo $1-

or, if $1- can be $null: (if alias is called like this: $test(,,) )

if ($1- != $null) echo $1-
Posted By: westor

Re: if ($1 ischar) { echo Yes it is! } - 04/12/09 04:05 PM

lol? that has not sence with that i want to tell you.
Posted By: 5618

Re: if ($1 ischar) { echo Yes it is! } - 04/12/09 04:52 PM

Originally Posted By: westor
I mean man when the $1- has any character's in then echo that the $1- has characters the $v1 was an silly example to saw you what i mean

e.g:

if ($1- ischar) { echo Yes the $1- is a char! }

You're still not making any sense. Give us examples!
Posted By: Riamus2

Re: if ($1 ischar) { echo Yes it is! } - 04/12/09 06:09 PM

As mentioned, give an example INPUT and OUTPUT rather than just the script as we obviously aren't understanding what you want. If all you're looking for is whether or not it's letters, that's what isalpha is for. If you want to know if there is data, use if ($1-) { } or just if ($1) { } . But without an actual example of input and what you expect the output to be, no one seems to know what you want.
Posted By: argv0

Re: if ($1 ischar) { echo Yes it is! } - 04/12/09 10:32 PM

You want to test if "$1" has "characters" in it? As in, if $1 exists?

if ($1 != $null) { echo YES IT IS. }
Posted By: westor

Re: if ($1 ischar) { echo Yes it is! } - 05/12/09 04:02 PM

OK, lets be more specific


ON *:TEXT:*:?: {
; THE FIRST IF IS THE USUAL EXAMPLE
if ($1 == $chr(35)) { echo Yes the $1 is a character }
; THE SECOND IF IS THAT THAT I WANT TO GIVE YOU EXAMPLE
if ($1 ischar) { echo Yes the $1 is a character }
}

NOTE: I want to tell you that the ischar to return if there are any $chr(*) inside an IF, as there exist the if ($1 isnum) { echo Yes it is an number }, It's easy and you can understand what i mean, ok my english is little poor but it is an good idea who those who has understand!
Posted By: genius_at_work

Re: if ($1 ischar) { echo Yes it is! } - 05/12/09 04:53 PM

You need to tell us what you mean when you say "character".

Do you mean:
letters?
numbers?
punctuation?
control codes? (0-31)
all basic ascii (32-127)?
all extended ascii (128-255)?
all ascii (32-255)?
all unicode characters?

-genius_at_work
Posted By: RusselB

Re: if ($1 ischar) { echo Yes it is! } - 05/12/09 04:54 PM

And how, realistically, is this different from
Code:
if ($1 != $null) { echo Yes the $1 is a character}
as suggested (with a slight alteration to the wording in the echo) by argv0 in the post located here
ok, you'll have to scroll down, as referencing the reply directly only brings you to the top of the original topic
Posted By: westor

Re: if ($1 ischar) { echo Yes it is! } - 05/12/09 04:55 PM

All the $chr(*) return character's
Posted By: westor

Re: if ($1 ischar) { echo Yes it is! } - 05/12/09 05:05 PM

Originally Posted By: RusselB
And how, realistically, is this different from
Code:
if ($1 != $null) { echo Yes the $1 is a character}
as suggested (with a slight alteration to the wording in the echo) by argv0 in the post located here
ok, you'll have to scroll down, as referencing the reply directly only brings you to the top of the original topic


I had never give this example just look the other new that i gave!
Posted By: Riamus2

Re: if ($1 ischar) { echo Yes it is! } - 05/12/09 07:03 PM

He was giving YOU an example with that. You still have not given a sample INPUT and OUTPUT (something I've requested multiple times). If you want to know if it is a single value, use:

if ($len($1) == 1) {}

That will tell you it's a single character. If you want only letters, use isalpha. If you want anything except numbers, use !isnum. If you want anything and any length, use:

if ($1 != $null) {}

A $chr() is any ascii character (including numbers). The only thing you'd filter out that way would be unicode. Is that what you're trying to do? Check if it's unicode? Really, you have to explain what you're looking for. If no one here knows what you are requesting, then it's a pretty good bet that you aren't explaining it well.

Give input and output examples (not more script examples).

Such as:
Quote:

<nick> H
<bot> This is a character.
<nick> Ha
<bot> This is not a character.
<nick> 1
<bot> This is a character.
<nick> "
<bot> This is not a character.
<nick> &#12486;
<bot> This is a character.


This is the kind of example we need to know what you're asking for. Change it to show the right outputs and, if necessary, add or remove some of the examples in there.
Posted By: argv0

Re: if ($1 ischar) { echo Yes it is! } - 05/12/09 08:37 PM

westor:

ANY text is a $chr(*), therefore ANYTHING ischar, therefore:

if ($1 != $null) is what you want.
Posted By: Tomao

Re: if ($1 ischar) { echo Yes it is! } - 06/12/09 11:39 AM

I think he is asking for an ascii character operator for evaluation purposes. I'm sure you can use regex along with a custom $ischar identifier for that matter:
Code:
alias -l ischar if ($regex($1-,/(\W+)/S)) return $regml(1) 
on *:TEXT:*:?:if ($ischar($1-)) echo -s WARNING: $nick just used $+(",$v1,") in private.
P.S. I know using an alias is unnecessary, but since westor's brought the $v1 up...I thought it'd be for the best.
Posted By: westor

Re: if ($1 ischar) { echo Yes it is! } - 06/12/09 12:32 PM

The Riammus has understand what i mean, I gave you examples but i have not more examples, anyway!
Posted By: 5618

Re: if ($1 ischar) { echo Yes it is! } - 06/12/09 02:13 PM

\W? So basically...
Code:
if ($1- !isalnum)

...except that \W also includes the _ character.
Posted By: Zed

Re: if ($1 ischar) { echo Yes it is! } - 06/12/09 03:45 PM

Code:
if ($len($1-) == 1) && ($1- isalnum) { }

or

if (? iswm $1-) && ($1- isalnum) { }
Posted By: Riamus2

Re: if ($1 ischar) { echo Yes it is! } - 06/12/09 03:55 PM

Originally Posted By: westor
The Riammus has understand what i mean, I gave you examples but i have not more examples, anyway!


Everything I put in that example was correct? It was just basically random. Anyhow, if that was correct, then the examples using $len and isalnum will work fine except for unicode characters. Might not be a bad idea for isalpha and isalnum to match with unicode such as Japanese.

Anyhow, westor, if anything, your requirements would seem to make more sense for adding issymbol instead of ischar. Not only would it make more sense to people as far as what it's checking, but it would work well with the other is___ checks (you'd then have alpha,number,symbol to check and I think that would be all you'd need). Of course, what a symbol is would have to be determined for that and opinions on that may differ from person to person... probably why it's not there.
© 2019 mIRC Discussion Forums