Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- lowAlphaList = "a b c d e f g h i j k l m n o p q r s t u v w x y z"
- hiAlphaList = "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"
- tolower = [
- tmpArg1 = $arg1; tmpFindList = (findlist $hiAlphaList $tmpArg1)
- if (>= $tmpFindList 0) [
- tmpCOut = (at $lowAlphaList (findlist $hiAlphaList $tmpArg1))
- result $tmpCOut
- ] [ result $arg1 ]
- ]
- // echo (tolower a) // Output: a
- // echo (tolower A) // Output: a
- // echo (tolower AB) // Output: AB // Only works with single char arguments
- // echo (tolower 1337) // Output: 1337 // Ignores anything that is not an alpha char or is already in the desired case
- toupper = [
- tmpArg1 = $arg1; tmpFindList = (findlist $lowAlphaList $tmpArg1)
- if (>= $tmpFindList 0) [
- tmpCOut = (at $hiAlphaList (findlist $lowAlphaList $tmpArg1))
- result $tmpCOut
- ] [ result $arg1 ]
- ]
- // echo (toupper b) // Output: B
- convertcase = [
- tmpSCOut = ""
- loop ccl (strlen $arg1) [
- if (!= $arg2 0) [
- tmpSCOut = (concatword $tmpSCOut (toupper (substr $arg1 $ccl 1)))
- ] [
- tmpSCOut = (concatword $tmpSCOut (tolower (substr $arg1 $ccl 1)))
- ]
- ]
- result $tmpSCOut
- ]
- // echo (convertcase "HELLO WORLD") // Output: hello world // Default output is lowercase
- // echo (convertcase "HELLO WORLD" 1) // Output: HELLO WORLD // Use '1' as the 2nd argument to force into uppercase
- // echo (convertcase "hElLo WoRlD!!!") // Output: hello world!!! // Since it uses tolower/toupper, it ignores anything that is not an alpha char or is aleady in the desired case
Advertisement
Add Comment
Please, Sign In to add comment