进度条无法正常工作
Progress bar not Working properly
我正在使用进度条,但我认为它无法正常工作。我的要求是当我的替换结束时进度条显示一条消息并且必须达到结束 point.If 我 运行 我的代码不止一次然后进度条的当前值 属性 自动设置为 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
-------------------------------------------------------------------------
由于您已将 tCurrentProgress 设为全局变量,因此其内容将保留在内存中,直到您对其进行更改。每当你开始你的 mouseUp 进程时,你需要将 0 放入 tCurrentProgress 并且你需要将你的进度条的 thumbPosition 设置为其 startValue(可能是 0)。
请记住,使用进度条意味着您将完成特定数量的任务,完成任务的百分比与进度条的填充百分比相对应。从您的示例中不清楚进度条的值是否与您的代码完成的替换次数相对应。
如果无法知道一个过程需要多长时间,您应该使用一些可以传达不确定进度的东西,例如将光标更改为正在观看或忙碌,或者使用 loading/spinning GIF 之类的东西。这表明您的申请正在处理中,但没有跟踪任何具体进度。
我正在使用进度条,但我认为它无法正常工作。我的要求是当我的替换结束时进度条显示一条消息并且必须达到结束 point.If 我 运行 我的代码不止一次然后进度条的当前值 属性 自动设置为 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
-------------------------------------------------------------------------
由于您已将 tCurrentProgress 设为全局变量,因此其内容将保留在内存中,直到您对其进行更改。每当你开始你的 mouseUp 进程时,你需要将 0 放入 tCurrentProgress 并且你需要将你的进度条的 thumbPosition 设置为其 startValue(可能是 0)。
请记住,使用进度条意味着您将完成特定数量的任务,完成任务的百分比与进度条的填充百分比相对应。从您的示例中不清楚进度条的值是否与您的代码完成的替换次数相对应。
如果无法知道一个过程需要多长时间,您应该使用一些可以传达不确定进度的东西,例如将光标更改为正在观看或忙碌,或者使用 loading/spinning GIF 之类的东西。这表明您的申请正在处理中,但没有跟踪任何具体进度。