Following on from Example 1, in this example I will demonstrate how I use a progress step sub routine as a way of calling many functions and sub routines to show progress through my mbx. The code uses a case statement to see what step count it is up to. It also demonstrates how to track if the progress bar cancel button was clicked, or if the code was ended prematurely because of user intervention.
This example enables you to show the progress bar, and set up a sequence of routines / scripts / functions and update the progress bar with a progress percentage when each task is complete.
Include "Mapbasic.def"
Declare Sub Main
Declare Sub StepProgress
Declare Sub Wait3Seconds
Declare Function ReturnTrue() as Logical
Dim iProgress as Integer
Dim iProgressRange as Integer
Sub Main
Print Chr$(12)
Set Window Message Position(1, 1) Width 3 Height 1
Print "*** Started Progress Bar Example ***"
iProgress = 1
iProgressRange = 5
ProgressBar "Processing...."
Calling StepProgress
Range iProgressRange
If CommandInfo(CMD_INFO_STATUS) then
If iProgress <= iProgressRange then
Note "You ended the Progress early because you only got to step " & iProgress
Else
Note "Progress Bar Example Complete!"
End If
Else
Note "You clicked the cancel button on the Progress Bar!"
End If
End Sub
'----------------------------------------------------------------
Sub StepProgress
Print "Progress is @ step " & iProgress
Do Case iProgress
Case 1
Note "Progress is @ step " & iProgress 'This is just an example process
Case 2
Note "Progress is @ step " & iProgress & ". Now going to wait 3 secs!"
Call Wait3Seconds 'This is just an example process
Case 3
Note "Progress is @ step " & iProgress 'This is just an example process
Case 4
If NOT ReturnTrue() then 'This is just an example process
Print "You eneded Progress"
ProgressBar = -1 'Now the progress bar will stop and hide
Exit Sub
End If
Case 5
Note "Progress is @ step " & iProgress 'This is just an example process
End Case
iProgress = iProgress + 1
If iProgress <= iProgressRange Then
ProgressBar = iProgress
Else
ProgressBar = -1
End If
End Sub
'----------------------------------------------------------------
Sub Wait3Seconds
Print "Waiting for 3 seconds"
Dim iCurrentTime, iElapsedTime, iWaitTime as Float
iCurrentTime = Timer()
iWaitTime= 3
Do While iElapsedTime <= iCurrentTime + iWaitTime
iElapsedTime = Timer()
Loop
End Sub
'----------------------------------------------------------------
Function ReturnTrue() as Logical
Dim bResult as Logical
bResult = Ask("Progress is @ step " & iProgress & ". Do you want the progress bar to Contiue or End?", "Continue", "End")
Print "Return True = " & bResult
ReturnTrue = bResult
End Function
Awesome post. Tahank you so much.
ReplyDeleteFor more tips web development go to https://webdesignvalley.com/
Using 3D printers for these functions recognized as} rapid prototyping. As it evolves, 3D printing technology is destined to remodel virtually each main industry and alter the way way|the way in which} we live, work, and play sooner or later. If you're be} nonetheless hesitating to share your models on Cults, be at liberty to read this text Why publish my designs on Cults? The development of 3D Slicer—including its quite a few modules, extensions, datasets, pull requests, patches, issues reports, suggestions—is made attainable by customers, developers, contributors and industrial companions around precision machining the world. The National Institutes of Health of the USA has been a major contributor by way of a variety of|quite so much of|a wide range of} aggressive grants and contracts.
ReplyDelete