my version of $text

By tai on Oct 10, 2007

; $text by tai
; Does a specified effect to a string of text
; Usage: $text(string).reverse/caps/lower/spaced/lc/rc/ud
; more effects to come

; $text by tai
; Does a specified effect to a string of text
; Usage: $text(string).reverse/caps/lower/spaced/lc/rc/ud
; more effects to come

alias text { 
  if ($1- && $isid) { 
    if ($prop) { 
      if ($v1 = reverse) { 
        var %x = $1-, %t = $len(%x), %i
        while (%t) { 
          %i = $+(%i,$mid(%x,%t,1),$chr(32))
          dec %t
        }
        return %i
      }
      if ($v1 = caps) { return $upper($1-) }
      if ($v1 = lower) { return $lower($1-) }
      if ($v1 = spaced) {
        var %x = $1-, %t = $len(%x), %i, %c = 1
        while (%c <= %t) { 
          %i = $+(%i,$chr(32),$mid(%x,%c,1))
          inc %c
        }
        return %i
      }
      if ($v1 = lc) {
        var %x = 1, %t
        while ($gettok($1-,%x,32)) {
          %t = $+(%t,$chr(32),$upper($left($v1,1)),$right($v1,-1))
          inc %x
        }
        return %t
      }
      if ($v1 = rc) { 
        var %x = $1-, %t = $len(%x), %i, %c = 1
        while (%c <= %t) { 
          %i = $+(%i,,$r(1,15),$mid(%x,%c,1),$chr(32))
          inc %c
        }
        return %i
      } 
      if ($v1 = ud) { 
        var %x = $1-, %t = $len(%x),%i,%c = 1
        while (%c <= %t) { 
          var %n $r(1,2)
          %i = $+(%i,$iif(%n = 1,$upper($mid(%x,%c,1)),$lower($mid(%x,%c,1))),$chr(32))
          inc %c
        }
        return %i
      }
    }
  }
} 

Comments

Sign in to comment.
tai   -  Oct 11, 2007

well i think for lc properties, you can shorten it more with using $regsubex... theres no need for a loop

Interesting idea, I\'ll see what I can do. thanks for the feedback.

 Respond  
zonirc   -  Oct 11, 2007

well i think for lc properties, you can shorten it more with using $regsubex... theres no need for a loop

 Respond  
Lindrian   -  Oct 11, 2007

use proper format of var, eg:
var %x = 1

 Respond  
tai   -  Oct 10, 2007

yeah its really useless, i just decided to mess around with a little custom identifier. thanks though ;P

 Respond  
Kyousoukyoku   -  Oct 10, 2007

Useless imo, but it\'s not bad coding.

 Respond  
tai   -  Oct 10, 2007

As to whoever submitted a low score, can you explain why the low score and how I can improve this snippet?

 Respond  
tai   -  Oct 10, 2007

Yeah, just got into the habit I guess. ;/ Editing right now. :P

 Respond  
guest598594   -  Oct 10, 2007

ok...whats the point of looping when u can use an identifier that duz it for u?

 Respond  
tai   -  Oct 10, 2007

Yes I could, and that\'d probably be a bit faster. But eh, I just got into the whole while loop idea when scripting this so I ended up scripting a while loop for that part too. ;]

 Respond  
Gummo   -  Oct 10, 2007

For the plain upper and lower you can just use $upper($1-) and $lower($1-) respectively, as you\'re changing the whole line.

 Respond  
tai   -  Oct 10, 2007

Ah, should have clarified. rc returns the string in random colors, lc returns the first letter of each word capitalized, and ud returns the string in random upper/lower cases (for example: hAwKeE) :]

 Respond  
guest598594   -  Oct 10, 2007

what duz ud,rc, and lc do?

 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.