2015-10-05 29 views
1

我希望只保留一個字符串的前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

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