From the June 2011 Issue of Prestwood eMag
 
Paradox OPAL: Wicked Coding Tasks:
Implementing a Reusable Progress Bar in Paradox
 
Posted 4/25/2003 on 4/25/2003 and updated 6/12/2008
Take Away: This overview helps you create and use a reusable progress bar.

KB100239

The following overview helps you create and use a reusable progress bar. Click Here to download the progress.fsl form. Copy and paste the custom methods to a form or library.

Design Objects

Create the following forms:

View Data Mode:

 

cmOpenProgressBar

Follow the comments:
{----------------------------------------------
Title: desktop::#Library1::cmProgressBar*
By: Mike Prestwood
Date: 4:49:01 PM, 2/20/96
Company Name: Prestwood Software & Consulting
Notes: Also see cmSetProgressBar() & cmCloseProgessBar().
-----------------------------------------------}

method cmOpenProgressBar(sTitle String) Logical
   if sTitle.isBlank() then
                sTitle = "Please wait..."
   endIf

   if fProgress.attach(sTitle) then
                return(True)
   else
    if fProgress.open(cmFindCommon() + "\\Progress", 
       WinStyleDefault + WinStyleHidden) then
      fProgress.setTitle(sTitle)
      oleProgress.attach(fProgress.oleProgressBar)
      sleep()
      fProgress.bringToTop()
      return(True)
    else
      return(False)
    endIf
  endIf
endMethod
cmSetProgressBar
{-----------------------------------------------
Title: Shared\desktop::#Library1::cmSetProgressBar*
Date: 3:16:29 PM, 2/23/96
Description: Pass siPercent 0 if you wish to keep the 
current setting. 
-----------------------------------------------}

method cmSetProgressBar(sText String, 
  siPercent SmallInt) Logical

if not fProgress.isAssigned() then
   if not cmOpenProgressBar("") then
      return(False)
   endIf
endIf

switch
  case siPercent < 1
    : smallInt(siPercent = oleProgress.Pos)
  case siPercent > 100
    : siPercent = 95
      fProgress.txtLine2.text = "Almost finished..."
endSwitch

fProgress.txtLine1.text = sText
oleProgress.Pos = siPercent
return(True)
endMethod

cmGetProgressBar
{-------------------------------------------
Title: Shared\desktop::#Library1::cmGetProgressBar*
Date: 3:22:38 PM, 2/23/96
Description: Returns 0 if not open.
-------------------------------------------}

method cmGetProgressBar() SmallInt
  if not fProgress.isAssigned() then
     return(0)
  endIf

  return(SmallInt(oleProgress.Pos))
endMethod

cmIsOpenProgressBar

method cmIsOpenProgressBar() Logical
   return(fProgress.isAssigned())
endMethod
cmCloseProgressBar
method cmCloseProgressBar() Logical
  if fProgress.isAssigned() then
     sleep(kSleep)
     fProgress.close()
     return(True)
  else
     return(False)
  endIf

endMethod

Using the progress bar
Uses ObjectPAL
 "common.lsl"
endUses

method pushButton(var eventInfo Event)
  var
    libCommon  Library
    siCounter  SmallInt
  endVar

  libCommon.open("common")
  libCommon.cmOpenProgressBar("Processing...")
  for siCounter from 1 to 20
   libCommon.cmSetProgressBar(String(siCounter)
   +" of 20",sicounter*5)
   sleep(250)
  endFor

  libCommon.cmCloseProgressBar()
endMethod

 

 


Comments

1 Comments.
Share a thought or comment...
Comment 1 of 1

 Hey.. what happened to this page.. no longer available.. can you get it to work again?

Posted 11/23/2019
KB Post Contributed By Mike Prestwood:

Mike Prestwood is a drummer, an author, and creator of the PrestwoodBoards online community. He is the President & CEO of Prestwood IT Solutions. Prestwood IT provides Coding, Website, and Computer Tech services. Mike has authored 6 computer books and over 1,200 articles. As a drummer, he maintains play-drums.com and has authored 3 drum books. If you have a project you wish to discuss with Mike, you can send him a private message through his PrestwoodBoards home page or call him 9AM to 4PM PST at 916-726-5675 x205.

Visit Profile
www.prestwood.com For service: 916-726-5675
or support@prestwood.com
Copyright (C) Prestwood IT Solutions.
All Rights Reserved.
Printed 2/20/2020