我希望只保留一个字符串的前13个字符。我想我不明白如何使用“字符”功能。 有人能帮助我吗?
choose from list {"0041325677667-pharmacie 1", "0041325677557-pharmacie 2",
"0041325677447-pharmacie 3", "0041325677337-pharmacie 4"} with prompt
"Thanks to select" without multiple selections allowed and empty selection allowed
return the result as string
return characters 1 thru 13 of result
提前感谢您的帮助
答案 0 :(得分:0)
characters x thru y
返回一个字符列表,在您的示例项1中返回
{"0", "0", "4" ,"1" ,"3" ,"2" ,"5" ,"6" ,"7" ,"7" ,"6" ,"6", "7"}
text x thru y
按要求返回一个字符串。
without multiple selections allowed and empty selection allowed
是默认值,因此可以省略。但是你应该考虑用户按下“取消”的情况,然后表达式返回布尔值false
。
set chosen to choose from list {"0041325677667-pharmacie 1", "0041325677557-pharmacie 2", "0041325677447-pharmacie 3", "0041325677337-pharmacie 4"} with prompt "Thanks to select"
if chosen is false then return "" -- in case of 'Cancel' return empty string
return text 1 thru 13 of (item 1 of chosen) -- as chosen returns a list by default it must be flattened