mIRC Home    About    Download    Register    News    Help

Print Thread
#24583 16/05/03 06:50 PM
Joined: Dec 2002
Posts: 8
B
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
B
Joined: Dec 2002
Posts: 8
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!


-Erik.
#24584 16/05/03 07:23 PM
Joined: Jan 2003
Posts: 96
J
Babel fish
Offline
Babel fish
J
Joined: Jan 2003
Posts: 96
Like:

All My Words Should Start With $Upper
or
Only my first word should be $upper ?

#24585 16/05/03 07:26 PM
A
Anonymous
Unregistered
Anonymous
Unregistered
A
I made this a long time ago
Code:
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 Test

Edit1: InstCaps = Instant Caps just in case you wondered

Edit2: hmm .. upon re-reading your post, you could just use
Code:
alias instcap return $+($upper($left($1-,1)),$lower($right($1-,-1)))


//echo -a $instcap(this is a test) will return This is a test

Last edited by r0ck; 16/05/03 07:37 PM.
#24586 16/05/03 07:39 PM
Joined: Dec 2002
Posts: 2,809
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
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,
Code:
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.

#24587 16/05/03 07:42 PM
A
Anonymous
Unregistered
Anonymous
Unregistered
A
that too smile
I should have hit refresh before I edited my post

#24588 16/05/03 08:22 PM
Joined: Dec 2002
Posts: 8
B
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
B
Joined: Dec 2002
Posts: 8
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...


-Erik.
#24589 16/05/03 08:28 PM
Joined: Dec 2002
Posts: 8
B
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
B
Joined: Dec 2002
Posts: 8
doesn't seem to work.. i just use it by "/caps something here." right? or is there another way?


-Erik.
#24590 16/05/03 08:28 PM
Joined: Dec 2002
Posts: 2,809
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
No problem, if it doesn't work right let me know, I didn't do too much testing on it.

#24591 16/05/03 08:34 PM
Joined: Dec 2002
Posts: 8
B
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
B
Joined: Dec 2002
Posts: 8
wait, I got it grin thanks for the help!


-Erik.
#24592 17/05/03 10:51 AM
Joined: Mar 2003
Posts: 32
P
Pap Offline
Ameglian cow
Offline
Ameglian cow
P
Joined: Mar 2003
Posts: 32
try this:
Code:
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. grin

My friend says he has an alias that does this:
Code:
/heh /say heh

Last edited by Pap; 17/05/03 11:09 AM.
#24593 17/05/03 01:03 PM
Joined: May 2003
Posts: 3
C
Self-satisified door
Offline
Self-satisified door
C
Joined: May 2003
Posts: 3
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 }


It's not that I'm afraid to die, I just don't want to be there when it happens.
#24594 17/05/03 05:19 PM
Joined: Dec 2002
Posts: 2,809
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
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.

#24595 17/05/03 07:02 PM
Joined: Dec 2002
Posts: 699
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 699
//echo -a $caps(there is a problem, it loses commas!)

#24596 17/05/03 07:09 PM
Joined: Dec 2002
Posts: 2,809
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
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!

#24597 17/05/03 07:26 PM
Joined: Dec 2002
Posts: 699
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 699
I didn't change much. smile
Code:
alias caps {
  var %ii = 1, %r
  while $ [ $+ [ %ii ] ] {
    var %a = $ifmatch
    var %i = $calc($len(%a) -1)
    var %out
    while (%i &gt; 0) {
      if ($mid(%a,%i,1) == $chr(32) &amp;&amp; $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)
}

#24598 17/05/03 10:56 PM
Joined: Dec 2002
Posts: 699
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 699
Code:
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 &gt; 0) {
    if ($mid($1-,%i,1) == $chr(32) &amp;&amp; $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. laugh

#24599 17/05/03 11:59 PM
Joined: Dec 2002
Posts: 2,809
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
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...

#24600 18/05/03 11:53 AM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
$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:
Code:
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) smile


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#24601 03/08/04 10:45 PM
Joined: Aug 2004
Posts: 3
B
Self-satisified door
Offline
Self-satisified door
B
Joined: Aug 2004
Posts: 3
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


#24602 04/08/04 01:48 AM
Joined: Aug 2004
Posts: 3
B
Self-satisified door
Offline
Self-satisified door
B
Joined: Aug 2004
Posts: 3
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}


Link Copied to Clipboard