|
拼音转换成数字,其中(2--abc,3--def,4--ghi,5--jkl,6--mno,7--pqrs,8--tuv,9--wxyz)
例如:输入:chen,输出:2436
我写的脚本:
# Pinyin convert to number.
create_input_dialog ( "Please type the pinyin" );
public function pton(pinyin)
{
pinyin = tolower(pinyin);
result = "";
for(i = 1; i <= length(pinyin); i++)
{
ls = substr(pinyin, i, 1);
if(ls == "a" | ls == "b" | ls == "c")
{result = result & "2";}
if(ls == "d" | ls == "e" | ls == "f")
{result = result & "3";}
if(ls == "g" | ls == "h" | ls == "i")
{result = result & "4";}
if(ls == "j" | ls == "k" | ls == "l")
{result = result & "5";}
if(ls == "m" | ls == "n" | ls == "o")
{result = result & "6";}
if(ls == "p" | ls == "q" | ls == "r" | ls == "s")
{result = result & "7";}
if(ls == "t" | ls == "u" | ls == "v")
{result = result & "8";}
if(ls == "w" | ls == "x" | ls == "y" | ls == "z")
{result = result & "9";}
printf(result);
}
} |
|