Reputation: 19
Hello Progress Experts!!!
I am trying to display the different colors based on percentage completion in progress bar like percentage 0% - 25% - Red , 25% - 50% - Yellow , 50% - 100% - Green Color.
The concern here is the following codes helps to provide percentage completion in FILL-IN box but I don't know how to give colors.
Note - Color should change and move gradually in FILL-IN box. (like we usually see progress bar in the system while copy and paste into another folder).
I heard we can use .NET methods in progress. It would be better if possible using this.
This might be stupid question(move gradually ) or unviable in progress. Yeah! as you know keep asking question why or why not is good for get some knowledge.
Please throw a small lamp here which gives bright to the dark.
DEFINE VARIABLE I AS INTEGER NO-UNDO.
DEFINE VARIABLE iPercentage AS INTEGER NO-UNDO.
DEFINE VARIABLE iComp AS INTEGER NO-UNDO.
DEFINE VARIABLE iRec AS INTEGER NO-UNDO.
ASSIGN
I = 0
iComp = 0
iRec = 0
iPercentage = 0.
/* Calculating Total records*/
FOR EACH <table> NO-LOCK:
iRec = iRec + 1.
END.
/* Taking each records from the same table to update*/
FOR EACH <table> NO-LOCK:
I = I + 1.
IF I = 1 THEN DO:
RUN UpdateRecord.p (INPUT <table>.<tablefield>)
ASSIGN
iComp = iComp + I.
iPercentage = 100 * (iComp / iRec).
DO WITH FRAME {&FRAME-NAME}:
ASSIGN
/* fiProgress is FILL-IN */
fiProgress:SCREEN-VALUE = STRING(iPercentage) + '%'.
PROCESS EVENTS.
END.
IF iPercentage = 100 THEN DO:
MESSAGE "Record Updation Is completed".
END.
ELSE DO:
I = 0
NEXT.
END.
END.
END.
Upvotes: 1
Views: 579
Reputation: 19
I found some other way for my question and could see bar moving gradually. Thanks @bupereire for an idea.
Note - FILL-IN box width should be 1.00
DEFINE VARIABLE iCount AS INTEGER NO-UNDO.
DEFINE VARIABLE iCalc AS INTEGER NO-UNDO.
DO WITH FRAME {&FRAME-NAME}:
REPEAT:
ASSIGN iCount = iCount + 1
iCalc = INT(100 - iCount)
fill-in-1:WIDTH = 1
fill-in-1:WIDTH = (fill-in-1:WIDTH + iCount)
fill-in-1:BGCOLOR = IF iCount < 25 THEN 4
ELSE IF (iCount > 25 AND iCount < 50) THEN 9
ELSE IF (iCount > 50 AND iCount < 75) THEN 14
ELSE IF (iCount > 75 AND iCount < 100) THEN 10
ELSE fill-in-1:BGCOLOR.
IF iCount = 100 THEN LEAVE.
PAUSE 0.5 NO-MESSAGE.
PROCESS EVENTS.
END.
END.
END PROCEDURE.
Upvotes: 0
Reputation: 1498
(...) color should change and move gradually (...)
If by gradually you would like a real gradient effect, you're out of luck using pure Progress. BGCOLOR only accepts the colors defined in the palette (1-15, unless you want to create your own dynamic new colors (which is possible, but would require some work). You can, however, assign it to an ActiveX field (formerly known as OCX) using the RGB-VALUE function, but if you're going down that route, I bet you can probably find an ActiveX progress bar to use and eliminate the need to recreate the wheel. I'll take your question as a pure progress feature you'd like to add.
For the sake of code reusability and adaptation, which is the goal of this site, I decided to create something that can be independent from your posted code (if you'll allow me), but easily built into it.
So in this example you should have 2 fill-ins, one of them with NO-LABEL and on top of the first, at the exact same column and row coordinates.
DEFINE VARIABLE iCount AS INTEGER NO-UNDO.
DEFINE VARIABLE iCalc AS INTEGER NO-UNDO.
REPEAT:
ASSIGN fill-in-1:BGCOLOR = IF iCount = 0 THEN 12
ELSE IF iCount = 25 THEN 14
ELSE IF iCount = 50 THEN 2
ELSE IF iCount = 75 THEN 10
ELSE fill-in-1:BGCOLOR.
ASSIGN iCount = iCount + 1.
/* Calculate reduction and placement of white fill-in */
ASSIGN iCalc = INT((100 - iCount) * fill-in-1:WIDTH / 100)
fill-in-2:WIDTH = if iCalc <> 0 then iCalc else 0.1
fill-in-2:COLUMN = fill-in-1:COLUMN + (fill-in-1:WIDTH - iCalc).
IF iCalc = 0 THEN
ASSIGN fill-in-2:VISIBLE = NO.
/* /End calculation */
ASSIGN fill-in-1:SCREEN-VALUE = STRING(iCount).
IF iCount = 100 THEN LEAVE.
PAUSE 0.2 NO-MESSAGE.
PROCESS EVENTS.
END.
This snippet works by itself sleeping for 0.2 seconds so you can get the idea of what's going on. Remove the pause and replace iCount with your percentage and you should get what you are looking for. PROCESS EVENTS would be a good idea, but not necessary to have.
Hope this helps.
EDIT: Shout out to my buddy Marlon Berkenbrock @marlonberkenbrock for bringing to my attention he got a zero width warning (which never showed to me due to my session configurations). The current version fixes that.
Upvotes: 4
Reputation: 772
You may be able to achieve this with fiProgress:BGCOLOR but color values in ABL GUI are pretty limited as they are limited to the color palate loaded at session start. You can, technically, overwrite them at runtime, but it's not a great idea.
Upvotes: 0