如何在livecode中获取内容
How to fetch content in livecode
我想捕捉两个 $ 符号之间的内容。
例如:- 这只是$一个示例$所以$响应$快速$。
在这里,我想将美元之间的文本(仅如此快速地)存储到一个数组中。
在使用此代码进行捕获时。但它抓住了(只是一个例子,所以,迅速回应)。我需要 "only"、"so" 和 "quickly"。
replace "$" with "\XXdollarXX" in field "MytextField"
put the text of field "MytextField" into ss
repeat with i = 0 to the number of chars in ss
if char i of ss contains "$" then
repeat with x = i+1 to the number of chars in ss
if char x of ss contains "$" then
--answer x
put x into Lpos
put char i to Lpos of ss into jar
answer jar
put Lpos into i
end if
end repeat
end if
end repeat
如果您在单步执行时检查您的代码,您会发现它必须以这种方式工作。但是,"offset" 函数可以在循环中使用,并且包含一个参数 "chars to skip"。通过不断更新该参数,并考虑到只有所有其他实例都是相关的,您可以收集“$”对之间的文本:
- 在实例 1 和 2 之间
- 在实例 3 和实例 4 之间
等等
制作一个按钮和一个字段。将一些文本放入撒有“$”的字段中进行测试。在按钮脚本中:
on mouseUp
put 0 into charsToSkip
repeat until charsToskip > the length of fld 1
if the optionKey is down then exit to top --YOU WILL NEED THIS RIGHT NOW...
get offset("$",fld 1,charsToSkip)
add it to charsToSkip
put charsToSkip & return after accum
end repeat
end mouseUp
我留给你添加正确退出此循环的能力。逐步执行处理程序,您将按照我提到的方式看到累积构建的价值。
克雷格·纽曼
我想捕捉两个 $ 符号之间的内容。 例如:- 这只是$一个示例$所以$响应$快速$。 在这里,我想将美元之间的文本(仅如此快速地)存储到一个数组中。 在使用此代码进行捕获时。但它抓住了(只是一个例子,所以,迅速回应)。我需要 "only"、"so" 和 "quickly"。
replace "$" with "\XXdollarXX" in field "MytextField"
put the text of field "MytextField" into ss
repeat with i = 0 to the number of chars in ss
if char i of ss contains "$" then
repeat with x = i+1 to the number of chars in ss
if char x of ss contains "$" then
--answer x
put x into Lpos
put char i to Lpos of ss into jar
answer jar
put Lpos into i
end if
end repeat
end if
end repeat
如果您在单步执行时检查您的代码,您会发现它必须以这种方式工作。但是,"offset" 函数可以在循环中使用,并且包含一个参数 "chars to skip"。通过不断更新该参数,并考虑到只有所有其他实例都是相关的,您可以收集“$”对之间的文本:
- 在实例 1 和 2 之间
- 在实例 3 和实例 4 之间 等等
制作一个按钮和一个字段。将一些文本放入撒有“$”的字段中进行测试。在按钮脚本中:
on mouseUp
put 0 into charsToSkip
repeat until charsToskip > the length of fld 1
if the optionKey is down then exit to top --YOU WILL NEED THIS RIGHT NOW...
get offset("$",fld 1,charsToSkip)
add it to charsToSkip
put charsToSkip & return after accum
end repeat
end mouseUp
我留给你添加正确退出此循环的能力。逐步执行处理程序,您将按照我提到的方式看到累积构建的价值。
克雷格·纽曼