ProgressBar
This object is used to display a progress bar in the host program while doing time consuming tasks.
Constructor
ProgressBar(string text, ProgressBarMode progress_bar_mode)
Creates a new progress bar and displays it in the host program.
text (string) The text displayed to the left of the progress bar. progress_bar_mode (integer) Type of progresss bar to create.
- Valid values are:
- ProgressBar.LINEAR Use this when you can compute your percentage progress while processing.
- ProgressBar.PINGPONG Use this when you cannot compute your percentage progress.
Methods
:SetPercentProgress(integer percent)
Call this moderately frequently to update the progress bar with your percentage progress. Should be used in conjunction with ProgressBar.LINEAR percent (integer) The percentage task completion between 0 and 100, does not have to be monotonically increasing in value. Progress bars can be reappropriated for different tasks by using SetText().
:StepProgress()
Call this moderately frequently to update the progress bar when you cant complete your percentage progress. Should be used in conjunction with ProgressBar.PINGPONG
:SetText(string text)
Sets the text displayed to the left of the progress bar. text (String) The text to be displayed.
:Finished()
This should always be called when you are finished with a progress bar.
function ProgressAmount(TotalRecords, Record) -- Calculates the percent amount of progression based on total process --[[ local MyProgressBar MyProgressBar = ProgressBar("Working", ProgressBar.LINEAR) -- Setup Type of progress bar MyProgressBar:SetPercentProgress(0) -- Sets progress bar to zero MyProgressBar:SetPercentProgress(ProgressAmount(Door.Records, myRecord)) -- sends percent of process progress bar (adds to the bar) MyProgressBar:SetPercentProgress(ProgressAmount(12000, 416)) -- sends percent of process progress bar (adds to the bar) MyProgressBar:SetText("Compete") -- Sets the label to Complete MyProgressBar:Finished() -- Close Progress Bar ]] local X1 = (100.0 / TotalRecords) local X2 = X1 * Record local X3 = math.abs(X2) local X4 = (math.floor(X3)) return (math.floor(math.abs((100.0 / TotalRecords) * Record))) end -- function end
Example Code:
References
Please Note: The base material for the contents found in this WiKi was sourced from Vectric Lua Interface for Gadgets, version 10.0, published August 21, 2019. by Vectric Ltd. Most current document from Vertric can be downloaded at Vertric Developer Information