我制作的堆栈应该显示文本行类别。我可以在“选择类别”卡上设置“类别”,并将设置保存在外部文本文件中。再次打开堆栈时,类别会在表单中正确显示,但在选择卡的卡上,所选复选框与显示的类别不对应。
堆栈级别的代码不适用于上述代码:
global gAllLines,gSelectedCategories
on openStack
put empty into gAllLines
set the itemDelimiter to tab
put fld "alllines" of cd "settingsandfiles" into gAllLines
put empty into gSelectedCategories
set the itemDelimiter to tab -- do I have to set the itemDelimiter here again even though it was set above?
set the defaultFolder to specialFolderPath("Documents")
put URL ("file:./myAppsData.txt") into gSelectedCategories
if "s" is among the items of gSelectedCategories then set the hilite of btn "Short" of cd "select_categories" to true
if "m" is among the items of gSelectedCategories then set the hilite of btn "Medium" of cd "select_categories" to true
if "l" is among the items of gSelectedCategories then set the hilite of btn "Long" of cd "select_categories" to true
end openStack
选择类别卡上的保存按钮上的代码是:
global gAllLines,gSelectedCategories,gMyCategories
on mouseUp
put empty into gSelectedCategories
set the itemDelimiter to tab
if the hilite of btn "Short" is true then put "s" & tab after gSelectedCategories
if the hilite of btn "Medium" is true then put "m" & tab after gSelectedCategories
if the hilite of btn "Long" is true then put "l" & tab after gSelectedCategories
put gSelectedCategories into URL ("file:./myAppsData.txt")
go back
end mouseUp
这是堆栈的链接:
https://dl.dropboxusercontent.com/u/99863601/Data%20grid%20Form_save%20and%20retrieve%20settings.zip
或在这里:
http://filecloud.io/lk06h3py
或在这里:
http://www.divshare.com/download/24928436-897
如何解决这个问题?
提前致谢。
keram
=======================
我现在通过更改堆栈级别的代码来修复它:
on openStack
put empty into gAllLines
set the itemDelimiter to tab
put fld "alllines" of cd "settingsandfiles" into gAllLines
put empty into gSelectedCategories
put URL ("file:" & specialFolderPath("Documents") & "/myAppsData.txt") into gSelectedCategories
if "s" is among the items of gSelectedCategories then set the hilite of btn "Short" of cd "select_categories" to true
else set the hilite of btn "Short" of cd "select_categories" to false
if "m" is among the items of gSelectedCategories then set the hilite of btn "Medium" of cd "select_categories" to true
else set the hilite of btn "Medium" of cd "select_categories" to false
if "l" is among the items of gSelectedCategories then set the hilite of btn "Long" of cd "select_categories" to true
else set the hilite of btn "Long" of cd "select_categories" to false
end openStack
keram
答案 0 :(得分:1)
保存数据时,它以制表符分隔。回读数据时,脚本采用默认分隔符,即逗号。如果在读取值之前将itemDelimiter设置为tab,它应该可以工作。
目前尚不清楚是否允许用户选择多个项目或仅选择一个项目。如果它只有一个,那么你根本不需要测试项目,数据中只有一个字符(“s”,“m”或“l”。)
答案 1 :(得分:1)
我刚刚测试了你的堆栈,它适用于我(OSX9),你在Mac或PC上做这个吗?我想知道问题是否可能是文本文件的路径以及是否值得添加
set the defaultFolder to specialFolderPath("Documents")
到您的“保存”脚本中按钮。
但实际上听起来你只需要对问题做一些调试和研究,例如:文本文件是否在你期望的位置创建?它包含您认为应该包含的内容吗?默认情况下,您的复选框似乎会突出显示,如果您不突出显示它们并尝试常规会发生什么情况,您是否仍然将它们全部显示为突出显示?等等等
Dave Kilroy
答案 2 :(得分:0)
无法访问您的堆栈。所以我不知道变量“s”,“m”和“j”是什么,或者它们是否恰当地适合从该文件中提取的数据的“项目”。
你知道项目是用逗号分隔的文本块,对吗?听起来格式化不对,因为设置这些按钮的hilites的命令似乎很简单。那么“s”包含什么,更重要的是,返回的文本是如何形成的?
克雷格纽曼