Shalu
Shalu

Reputation: 290

Progress bar not Working properly

I am using a progress bar and I think it's not working properly. My requirement is when my replacement are over that time progress bar show a message and it must be reached to end point.If I run my code more than one time then the current value of progress bar property is automatically set to 100 I am using the following code

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 
-------------------------------------------------------------------------

Upvotes: 0

Views: 176

Answers (1)

Scott Rossi
Scott Rossi

Reputation: 885

Since you've made tCurrentProgress a global variable, its contents will stay in memory until you change it. Whenever you start your mouseUp process, you need to put 0 into tCurrentProgress and you need to set the thumbPosition of your progressbar to its startValue (probably 0).

Keep in mind that using a progressbar implies that you have a specific number of tasks that will be completed, and the percentage of completed tasks corresponds with the filled percentage of the progressbar. It's not clear from your example that the value of the progressbar corresponds with the number of replacements being done by your code.

If there's no way to know how long a process will take, you should use something that communicates indeterminate progress, like changing the cursor to watch or busy, or using something like a loading/spinning GIF. This shows your application is processing, but without tracking any specific progress.

Upvotes: 1

Related Questions