我正在使用进度条,我认为它无法正常工作。我的要求是当我的替换结束时,进度条显示一条消息并且必须到达终点。如果我运行我的代码多次,则进度条属性的当前值自动设置为100我正在使用以下代码
global searchStr
global replaceStr
global assa
global tCurrentProgress
on mouseUp
----------progressbar coding------------------------
global tCurrentProgress
put 0 into tCurrentProgress
if tCurrentProgress >= the endValue of scrollbar "Progress Scrollbar" then
else
add 1 to tCurrentProgress
---------------------------------------------
put the htmlText of field "MytextField" into myHtml
set the caseSensitive to true
put the field SRText into myArrayToBe
split myArrayToBe by CR
put the number of lines of (the keys of myArrayToBe) into myArraylength
repeat with i = 1 to myArraylength
--return i
put myArrayToBe[i] into y
split y by colon
put y[1] into searchStr
put y[2] into replaceStr
if searchStr is empty then
put the 0 into m
else
replace searchStr with "<strike><font bgcolor=" & quote & "yellow" & quote & ">" & searchStr & "</font></strike><font bgcolor=" & quote & "green" & quote & ">" & replaceStr & "</font>" in myHtml
end if
end repeat
set the htmlText of fld "MytextField" to myHtml
end if
send "push_thumb" to me in .1 second ----------progressbar coding-------
end mouseUP
----------progressbar coding------------------------
command push_thumb
put the thumbPosition of scrollbar "Progress Scrollbar" into tCurrentProgress
if tCurrentProgress >= the endValue of scrollbar "Progress Scrollbar" then
answer "Process complete"
else
add 1 to tCurrentProgress
send "push_thumb" to me in .1 second -- keep the timer going
end if
set the thumbPosition of scrollbar "Progress Scrollbar" to tCurrentProgress
end push_thumb
-------------------------------------------------------------------------
答案 0 :(得分:1)
由于您已将tCurrentProgress设为全局变量,因此在更改之前,其内容将保留在内存中。每当你启动mouseUp进程时,你需要将0放入tCurrentProgress,你需要将进度条的thumbPosition设置为startValue(可能为0)。
请记住,使用进度条意味着您将完成特定数量的任务,并且已完成任务的百分比与进度条的填充百分比相对应。从您的示例中不清楚,进度条的值与您的代码所执行的替换次数相对应。
如果无法知道进程需要多长时间,您应该使用能够传达不确定进度的内容,例如将光标更改为观看或忙碌,或使用加载/旋转GIF等内容。这表明您的应用程序正在处理,但没有跟踪任何具体进展。