找了半天没找到相关算子,有没有大佬做过字母大小写转换?
用了比较奇怪的方式实现了,有点复杂:
ToLower:='true'
StringIn:='-1adffadD FG DSFS'
*若ToLower='true'则转换输入的字符串为小写,否则转换为大写
StringOut:=''
tuple_length (StringIn, TupleLength)
if(TupleLength!=1)
Msg:='请输入1个字符串!'
return ()
endif
tuple_is_string (StringIn, IsString)
* tuple_is_string_elem (StringIn, IsString)
if(IsString!=1)
Msg:='输入的不是字符串!'
return ()
endif
tuple_strlen (StringIn, StringLength)
if(StringLength=0)
Msg:='转换成功,输入为空字符串!'
return ()
endif
UPPER:=['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']
LOWER:=['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']
for i:=0 to StringLength-1 by 1
tuple_str_bit_select (StringIn,i, Selected)
if(ToLower='true')
if(Selected>='A' and Selected<='Z')
tuple_find (UPPER, Selected, Indices)
StringOut:=StringOut+LOWER[Indices]
else
StringOut:=StringOut+Selected
endif
else
if(Selected>='a' and Selected<='z')
tuple_find (LOWER, Selected, Indices)
StringOut:=StringOut+UPPER[Indices]
else
StringOut:=StringOut+Selected
endif
endif
Msg:='转换成功!'
endfor |