mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
if ($1 ischar) { echo Yes it is! } #216819 03/12/09 03:21 PM
Joined: Dec 2008
Posts: 1,511
westor Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,511
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

Last edited by westor; 03/12/09 03:21 PM.
Re: if ($1 ischar) { echo Yes it is! } [Re: westor] #216820 03/12/09 03:29 PM
Joined: Jun 2007
Posts: 933
5
5618 Offline
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
Could you please elaborate?

Re: if ($1 ischar) { echo Yes it is! } [Re: westor] #216821 03/12/09 03:31 PM
Joined: Jul 2006
Posts: 3,568
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,568
Do you mean if ($len($1-) == 1) { ?
If so, probably won't be added, you're too lazy seriously ~


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: if ($1 ischar) { echo Yes it is! } [Re: westor] #216822 03/12/09 03:40 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
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.

Last edited by Riamus2; 03/12/09 03:54 PM.

Invision Support
#Invision on irc.irchighway.net
Re: if ($1 ischar) { echo Yes it is! } [Re: Riamus2] #216823 03/12/09 03:44 PM
Joined: Jul 2006
Posts: 3,568
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,568
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.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: if ($1 ischar) { echo Yes it is! } [Re: Wims] #216824 03/12/09 03:49 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
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.


Invision Support
#Invision on irc.irchighway.net
Re: if ($1 ischar) { echo Yes it is! } [Re: westor] #216833 04/12/09 03:19 AM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
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.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Re: if ($1 ischar) { echo Yes it is! } [Re: argv0] #216852 04/12/09 04:02 PM
Joined: Dec 2008
Posts: 1,511
westor Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,511
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! }

Re: if ($1 ischar) { echo Yes it is! } [Re: westor] #216854 04/12/09 04:04 PM
Joined: Mar 2004
Posts: 54
Z
Zed Offline
Babel fish
Offline
Babel fish
Z
Joined: Mar 2004
Posts: 54
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-

Last edited by Zed; 04/12/09 04:07 PM.
Re: if ($1 ischar) { echo Yes it is! } [Re: Zed] #216855 04/12/09 04:05 PM
Joined: Dec 2008
Posts: 1,511
westor Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,511
lol? that has not sence with that i want to tell you.

Re: if ($1 ischar) { echo Yes it is! } [Re: westor] #216856 04/12/09 04:52 PM
Joined: Jun 2007
Posts: 933
5
5618 Offline
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
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!

Re: if ($1 ischar) { echo Yes it is! } [Re: westor] #216858 04/12/09 06:09 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
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.


Invision Support
#Invision on irc.irchighway.net
Re: if ($1 ischar) { echo Yes it is! } [Re: westor] #216864 04/12/09 10:32 PM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
You want to test if "$1" has "characters" in it? As in, if $1 exists?

if ($1 != $null) { echo YES IT IS. }


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Re: if ($1 ischar) { echo Yes it is! } [Re: argv0] #216879 05/12/09 04:02 PM
Joined: Dec 2008
Posts: 1,511
westor Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,511
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!

Last edited by westor; 05/12/09 04:03 PM.
Re: if ($1 ischar) { echo Yes it is! } [Re: westor] #216880 05/12/09 04:53 PM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
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

Re: if ($1 ischar) { echo Yes it is! } [Re: westor] #216881 05/12/09 04:54 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
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

Re: if ($1 ischar) { echo Yes it is! } [Re: genius_at_work] #216882 05/12/09 04:55 PM
Joined: Dec 2008
Posts: 1,511
westor Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,511
All the $chr(*) return character's

Re: if ($1 ischar) { echo Yes it is! } [Re: RusselB] #216883 05/12/09 05:05 PM
Joined: Dec 2008
Posts: 1,511
westor Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,511
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!

Re: if ($1 ischar) { echo Yes it is! } [Re: westor] #216885 05/12/09 07:03 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
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.


Invision Support
#Invision on irc.irchighway.net
Re: if ($1 ischar) { echo Yes it is! } [Re: westor] #216886 05/12/09 08:37 PM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
westor:

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

if ($1 != $null) is what you want.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Re: if ($1 ischar) { echo Yes it is! } [Re: westor] #216889 06/12/09 11:39 AM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
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.

Re: if ($1 ischar) { echo Yes it is! } [Re: argv0] #216890 06/12/09 12:32 PM
Joined: Dec 2008
Posts: 1,511
westor Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,511
The Riammus has understand what i mean, I gave you examples but i have not more examples, anyway!

Re: if ($1 ischar) { echo Yes it is! } [Re: Tomao] #216893 06/12/09 02:13 PM
Joined: Jun 2007
Posts: 933
5
5618 Offline
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
\W? So basically...
Code:
if ($1- !isalnum)

...except that \W also includes the _ character.

Re: if ($1 ischar) { echo Yes it is! } [Re: 5618] #216902 06/12/09 03:45 PM
Joined: Mar 2004
Posts: 54
Z
Zed Offline
Babel fish
Offline
Babel fish
Z
Joined: Mar 2004
Posts: 54
Code:
if ($len($1-) == 1) && ($1- isalnum) { }

or

if (? iswm $1-) && ($1- isalnum) { }

Re: if ($1 ischar) { echo Yes it is! } [Re: westor] #216904 06/12/09 03:55 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
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.


Invision Support
#Invision on irc.irchighway.net
Page 1 of 2 1 2