我有一个滚动字段,它的空格分隔数字和单词。
我想找到数字之和(例如:5 USA& CR 5 Uk)
答案 0 :(得分:2)
on mouseUp
if the field "CC" is not empty then//here "CC" is an Scrolling field and it's containing the content
put 0 into aa
put fld "CC" into myData
split myData by CR
put the number of lines of (the keys of myData) into myArraylength
repeat with i = 1 to myArraylength
put 0 into zo
put myData[i] into y
split y by space
put y[1] into searchStr
if y[1]is not a number then
put 0 into var1
else
put searchStr into vari
put vari &comma after ss1
end if
end repeat
answer ss1
put sum(ss1) into aa1
answer aa1
put ss1 into second1
split second1 by comma
else
answer "List is Empty"
end if
end mouseUp
答案 1 :(得分:0)
假设滚动字段中的文本格式一致,如示例所示:
5 USA
5 UK
4 EUR
etc.
您可以这样做:
put fld "myScrollingFld" into tList
put 0 into tTotal
repeat for each line tLineContents in tList
put word 1 of tList into tNum
if tNum is a number then add tNum to tTotal
end if
答案 2 :(得分:0)
on mouseUp
repeat for each word thisWord in fld "Myfield"
if thisWord is a number then add thisWord to tSum
end repeat
answer tSum
end mouseUp