How might I go about making a remote for an "on INPUT" that uses $replace to make the first letter (and only the first letter) of every sentence capitalized? example:
First word in this sentence is capitalized. Now the first word in this sentence is capitalized.
Any ideas?
Thanks in advance!
Like:
All My Words Should Start With $Upper
or
Only my first word should be $upper ?
I made this a
long time ago
alias instcaps {
tokenize 32 $lower($1-) | var %i = 1
while ($eval($+($chr(36),%i),2) != $null) {
var %tok = $eval($+($chr(36),%i),2)
var %r = %r $+($upper($left(%tok,1)),$right(%tok,-1))
inc %i
}
return %r
}
//echo -a $instcaps(this is a test) will return
This Is A TestEdit1: InstCaps = Instant Caps just in case you wonderedEdit2: hmm .. upon re-reading your post, you could just use
alias instcap return $+($upper($left($1-,1)),$lower($right($1-,-1)))
//echo -a $instcap(this is a test) will return
This is a test
Well thats not what he asked for though. First letter of first word of each sentence, not first letter of every word. It may seem like an easy task, but it can actually get rather complex, for example, what is a "sentence"? What characters can it end with? ?!. most likely. But if you just go through and capitalize the first letter after a period,
http://www.test.com becomes
http://www.Test.Com, so that's not going to work correctly,
alias caps {
var %i = $calc($len($1-) -1)
var %out
while (%i > 0) {
if ($mid($1-,%i,1) == $chr(32) && $mid($1-,$calc(%i -1),1) isin .?!) {
set %out $upper($mid($1-,$calc(%i +1),1)) $+ %out
}
else {
set %out $mid($1-,$calc(%i +1),1) $+ %out
}
dec %i
}
set %out $upper($mid($1-,%i,1)) $+ %out
return %out
}
$caps(this is a sentence. this is another sentence! this is a third sentence?) = This is a sentence. This is another sentence! This is a third sentence?
So that appears to work. But just a note, to prevent the stated problem on urls, it recognizes the end of a sentence as ". " "? " and "! " meaning if there is not a space after the punctuation, then it won't capitalize, it's not a bug, it is how I designed it.
that too
I should have hit refresh before I edited my post
ah yeah, I should've been more specific about the puncuation. you've got it the way I was looking for though, whereas a sentence is anything ending with "!", ".", or "?"
so, thanks for the code, i'll test it now...
doesn't seem to work.. i just use it by "/caps something here." right? or is there another way?
No problem, if it doesn't work right let me know, I didn't do too much testing on it.
wait, I got it
thanks for the help!
try this:
on *:INPUT:*:{
if ( $left($1,1) == / || $ctrlenter == $true ) { return }
haltdef
say $upper($left($1,1)) $+ $right($1-,-1)
}
You can hit Ctrl+Enter instead of Enter to escape it.
Next thing you know you'll want to add " $+ . " to the end of it, right? hehe
Edit: I forgot you wanted the first letter of each sentence... that only does the very first letter. Well that's a start for the rest of you guys. Good luck. I suggest you just unlazy yourself and learn to type proper.
My friend says he has an alias that does this:
on *:INPUT:*:if ($left($1,1) != $readini($mircdirmirc.ini,text,commandchar)) && ($active != Status Window) || ($ctrlenter = $true) { var %x = 1,%y | while (%x <= $numtok($1-,32)) { %y = %y $+($upper($left($gettok($1-,%x,32),1)),$lower($mid($gettok($1-,%x,32),2))) | inc %x } | msg $active %y | unset %x %y | halt }
Seriously, does anyone read the original post? This is the third snippet that does NOT do what he asked. There have been ones that capitalize the first letter of every word (like this one), which is not what he asked. There was one that capitalized the first letter of just the first word, which is also not what he asked, he asked for it to capitalize the first letter of EVERY sentence, not every word, and not just the first word. The first word of EVERY sentence.
//echo -a $caps(there is a problem, it loses commas!)
Yea well... yell at mIRC for that, as far as I know there is no real work around for that, which falls back to my suggestion of mIRC should be like other languages and support quotes!
I didn't change much.
alias caps {
var %ii = 1, %r
while $ [ $+ [ %ii ] ] {
var %a = $ifmatch
var %i = $calc($len(%a) -1)
var %out
while (%i > 0) {
if ($mid(%a,%i,1) == $chr(32) && $mid(%a,$calc(%i -1),1) isin .?!) {
set %out $upper($mid(%a,$calc(%i +1),1)) $+ %out
}
else {
set %out $mid(%a,$calc(%i +1),1) $+ %out
}
dec %i
}
%r = %r %out $+ ,
inc %ii
}
return $left(%r,-1)
}
alias caps {
var %i = 1, %a, %out
while $ [ $+ [ %i ] ] { %a = %a $ifmatch $+ , | inc %i }
tokenize 32 $left(%a,-1)
%i = $calc($len($1-) -1)
while (%i > 0) {
if ($mid($1-,%i,1) == $chr(32) && $mid($1-,$calc(%i -1),1) isin .?!) {
%out = $upper($mid($1-,$calc(%i +1),1)) $+ %out
}
else { %out = $mid($1-,$calc(%i +1),1) $+ %out }
dec %i
}
set %out $upper($mid($1-,%i,1)) $+ %out
return %out
}
I should have tested it.
That gave me an idea, maybe if you use $1-, if $isid it should return it EXACTLY as entered, meaning $blah(test, test,test)
$1 = test
$2 = test
$3 = test
$1- = test, test,test
I can't really think of a situation where you would ever request all the params passed to an identifier other than if you wanted to use it as text...
$caps(How many, 0, 1 or 2?)
This example input breaks the ident, because the 1st while loop doesn't discriminate between $null, $false or 0. I'd use something like this:
while $ [ $+ [ %i ] ] != $null { %a = %a $ifmatch $+ , | inc %i }
Well, in fact I wouldn't even bother making something like this, the scripter should just do a /var %a = <whatever input> and use $caps(%a)
hello, a newbie here
I used this:
alias instcaps { tokenize 32 $lower($1-) | var %i = 1 while ($eval($+($chr(36),%i),2) != $null) { var %tok = $eval($+($chr(36),%i),2) var %r = %r $+($upper($left(%tok,1)),$right(%tok,-1)) inc %i } return %r}
and it works great if i copy and paste from someones list into the channel... but if I use the person's Trigger, it all comes in lower case... every word.
Is there another snippet to use?
I want to make the 1st letter of each word capitalized.
Thank you
Actually, the snippet does not work to capitalize the first letter of each word.
The file I was getting was already capitalized correctly.
But when I deliberately got a file from someone that had no capitalization....... that's how it came to me.... All Lower-case.
So, I sure do need a snippet to put into my Scripts Editor that will Capitalize the first Letter of each Word in the file name.
this is the snippet I used:
alias caps { var %i = 1, %a, %out while $ [ $+ [ %i ] ] { %a = %a $ifmatch $+ , | inc %i } tokenize
32 $left(%a,-1) %i = $calc($len($1-) -1) while (%i > 0) { if ($mid($1-,%i,1) == $chr(32) &&
$mid($1-,$calc(%i -1),1) isin .?!) { %out = $upper($mid($1-,$calc(%i +1),1)) $+ %out } else {
%out = $mid($1-,$calc(%i +1),1) $+ %out } dec %i } set %out $upper($mid($1-,%i,1)) $+ %out return
%out}