$switchtok

By Sight on Oct 31, 2007

; $switchtok - Sight
; ;; What this is ;;
; $switchtok switches the positions of two different tokens in a string of text
; ;; Syntax ;;
; $switchtok(string,,,C)
; ;; Examples ;;
; $switchtok(Testing this bodacious alias is sweet,3,6,32) switches boadcious and sweet returning: Testing this sweet alias is bodacious :)

; $switchtok - Sight 
; ;; What this is ;;
; $switchtok switches the positions of two different tokens in a string of text
; ;; Syntax ;; 
; $switchtok(string,<N>,<N2>,C) 
; ;; Examples ;;
; $switchtok(Testing this bodacious alias is sweet,3,6,32) switches boadcious and sweet returning: Testing this sweet alias is bodacious :) 

alias switchtok { 
  if ($$1 && $2-4) { 
    var %n = $gettok($$1,$2,$4)
    return $iif(!%n || !$gettok($$1,$3,$4) || $3 = 0 || $2 = 0,$false,$instok($deltok($instok($deltok($$1,$2,$4),$gettok($$1,$3,$4),$2,$4),$3,$4),%n,$3,$4))
  }
}

Comments

Sign in to comment.
zonirc   -  Nov 02, 2007

i dont mean that since the idea is really basic and anyone out there can/would think of it... since Im lost my enthusiam to coded it again so when i see you make this one, hopefully you will do much more or upgraded :) sorry my english not so good :)

 Respond  
Sight   -  Nov 01, 2007

Sorry if you thought I stole your idea, never really saw your snippet before. But yeah, thanks for the idea of error checking. Will add to the snippet.

 Respond  
zonirc   -  Oct 31, 2007

this is nice... however theres a problem especially when the param are not specified(null) like this example:
--> $switchtok(Testing this bodacious alias is sweet,3,,32)
or when the N or N2 specified as 0
--> $switchtok(Testing this bodacious alias is sweet,3,0,32)

just wanna shared with you :)
http://www.hawkee.com/snippet/1313/

 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.