Caps On 1st Letter

By smspeople on Sep 20, 2010

This is just for that user who want to 1st letter on

on 1:INPUT:*: {
  set %Var3 $1-
  unset %Var1 %Var2
  set %Var1 1 | set %Var2 $upper($mid(%Var3,1,1))
  if ($mid(%Var3,1,1) == $chr(47)) { goto ServerCommand }
  if ($len(%Var3) == 1) { set %Var2 $upper(%Var2) | say %Var2 | halt }
  :Start1
  inc %Var1 1
  if ($mid(%Var3,%Var1,1) != $chr(32)) { set %Var2 %Var2 $+ $mid(%Var3,%Var1,1) | if ($len(%Var3) < %Var1) { goto Start1 } }
  if ($mid(%Var3,%Var1,1) == $chr(32)) { set %Var2 %Var2 $+ $upper($mid(%Var3,%Var1,2)) | inc %Var1 1 | if ($len(%Var3) < %Var1) { goto Start1 } }
  if ($len(%Var3) != %Var1) { goto Start1 }
  say %Var2
  halt
  :ServerCommand
}
menu channel {
  All 1st Letter Caps
  .on { set %script true }
  .off { unset %script }

Comments

Sign in to comment.
Gummo   -  Jan 31, 2011

That explains the old programming style.

 Respond  
Jethro   -  Jan 23, 2011

itsmefahad, nice find. This snippet is apparently ripped from another one about 5 years ago.

 Respond  
itsmefahad   -  Jan 23, 2011

This Code Already Added In
http://www.hawkee.com/snippet/1570/

And This Guy ReAdd This Code :|

 Respond  
Jethro   -  Nov 23, 2010

Gummo, I'm aware of that could happen, and if you want to get technical, there will always be a "what-if possibility" to take into consideration. I wasn't being meticulous when it came to matching in the regex. I was basically copying if off from the example shown above my initial post for a quick solution. Nevertheless, though, I agree with you about using the "negative lookaround" method to enhance the foolproof level of regex.

 Respond  
Gummo   -  Nov 23, 2010

Using \w as your regex pattern by itself will match any word character after any word boundary. That means that "Jethro's" would become "Jethro'S"
For matching words alone you can use

on *:input:*: {
  if ($left($1,1) !isin / $readini($mircini,text,commandchar)) && (!$ctrlenter) && (!$inpaste) {
    say $regsubex($1-,/(?<!\S)(\w)/g,$+($chr(2),$upper(\1),$chr(2)))
    haltdef
  }
}

If you still want to match words in other places like "[Hello]" then you need a more complex check if you want to do this accurately.

 Respond  
Styleofglobal   -  Nov 23, 2010

@Jethro_, Thanks thank thank thanks :D [first letter of each and every word in a sentence in CAPS and BOLD:] this is am looking for :D

Thanks Again

Sorry for Bad English ....

 Respond  
Jethro   -  Nov 22, 2010

Styleofglobal, I'm not sure which one you want, so these two snippets below are for you to pick:

This one below will make the first letter of each and every word in a sentence in CAPS and BOLD:

on *:input:*:{
  if ($left($1,1) != /) { 
  haltdef
    say $regsubex($1-,/(\w+)/g,$+($chr(2),$upper($left(\t,1)),$chr(2),$mid(\t,2))) 
  }
}

e.g. Hello Styleofglobal, I's A Beautiful Day

This one below will only make the first letter of a sentence in CAPS and BOLD:

on *:input:*:{
  if ($left($1,1) !isin / $readini($mircini,text,commandchar)) && (!$ctrlenter) && (!$inpaste) {
    say $regsubex($1-,/^(.)/,$+($chr(2),$upper(\1),$chr(2)))
    halt
  }
}

e.g. Hello Styleofglobal, it's a beautiful day.

 Respond  
Styleofglobal   -  Nov 22, 2010

@cofve.. frnd :( i want only caps later in bold, i did "set %Var2 [ctrl+b here] %Var2" now its showing all laters bold ....

Help Please Thanks :)

Sorry for Bad English ....

 Respond  
cofvempire   -  Nov 21, 2010

where say %var2 stands press ctrl+b in the middle of say and %var2
ctrl+b is bold letters

 Respond  
Styleofglobal   -  Nov 21, 2010

@smspeople Help me, I Want Caps On 1st Letter In Bold ...

Sorry for Bad English :P

 Respond  
BoosteeR   -  Oct 02, 2010

Okay, thanks m8 :)

 Respond  
Jethro   -  Sep 26, 2010

BoosteR, if you only want to set the first letter of a sentence capitalized, you could use:

on *:input:*:{
  if ($left($1,1) !isin / $readini($mircini,text,commandchar)) && (!$ctrlenter) && (!$inpaste) {
    say $regsubex($1-,/^(.)/,$upper(\t))
    halt
  }
}
 Respond  
BoosteeR   -  Sep 26, 2010

So u would use

 alias caps say $+($upper($left($1-,1)),$mid($1-,2)) 

to set the 1st letter in the sentence caps, or ?

 Respond  
napa182   -  Sep 25, 2010

BoosteeR Said:

Cant u make it so i only set the 1st letter in the whole sentence caps ?

um you can just use

$+($upper($left($1-,1)),$mid($1-,2))

for that try it using this alias

alias caps say $+($upper($left($1-,1)),$mid($1-,2))

but the whole point of his snippet was to make every 1st letter said a cap.
for that i would use

$regsubex($1-,/(\w+)/g,$+($upper($left(\t,1)),$mid(\t,2)))
 Respond  
BoosteeR   -  Sep 25, 2010

Cant u make it so i only set the 1st letter in the whole sentence caps ?

 Respond  
Jethro   -  Sep 21, 2010

opps, my bad. :P

 Respond  
WorldDMT   -  Sep 21, 2010

@napa182: yeah the regsubex replace the while loop but too complicate for him :p
@aucun50: merci c'est gentil ;)

 Respond  
Aucun50   -  Sep 21, 2010

Nice shirt WorldDMT

 Respond  
smspeople   -  Sep 21, 2010

Dear napa182, Ty sir

 Respond  
napa182   -  Sep 20, 2010

could also do

#Caps off
on *:input:*:{ 
  if ($left($1,1) != /) {
    haltdef
    say $regsubex($1-,/(\w+)/g,$+($upper($left(\t,1)),$mid(\t,2)))  
  }
} 
#Caps end
menu channel {
  .Turn All 1st. Letter Caps $iif($group(#Caps) = on,Off,On):{
    $+(.,$iif($group(#Caps) = on,dis,en),able) #Caps
    echo -a 1st. Letter Caps is now $group(#Caps)
  }
}
 Respond  
WorldDMT   -  Sep 20, 2010

may be set %Var2 $upper(%Var2) | say %Var2 | halt have to be set %Var2 $upper(%Var3) | say %Var2 | halt

but why u unset the variable you can just set it but you can use /var too

where is the condition if (%script) ????

your code can be like this

on *:input:*:{
  if (%script) && ($left($1,1) != /) {
    var %x 1
    while $gettok($1-,%x,32) {
      var %r %r $upper($left($v1,1)) $+ $mid($v1,2)
      inc %x
    }
    say %r
    halt
  }
}
 Respond  
[Plornt]   -  Sep 20, 2010

You're missing an end bracket by the way

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.