Progress Bar status indicator

Discussions related to Visual Prolog
Loffy
Active Member
Posts: 47
Joined: 15 Aug 2019 11:32

Progress Bar status indicator

Unread post by Loffy » 9 Oct 2019 13:28

I would like to put a progress indicator on the project status bar.

I have been experimenting with concepts for a project. So far so good.

I have been able to stream quite large files in and out of my project. One of these processes requires a progress indication to the user because it takes a few minutes without any indication on the Taskwindow, though I know I could switch focus from the input/output stream to the message window and switch back again to the streams. To me that seems to be a waste of resources.

I have a good calculation for the progress, but I am having some difficulties finding the correct code to put the progress number on the status bar. A simple progress percentage would be good, but a graphic control similar to that shown when a "Build All" is executed would be better.

I know the information is somewhere in the pfc documentation or the VP knowledgebase, but after a good deal of searching I have not yet found it. I know I will find it eventually, though a pointer to the correct help or an example would be appreciated.

I have found some hints from the PIE project, but either that is a little out of date or more likely I am missing something.

Any pointers will be appreciated.

Regards,

Loffy

Martin Meyer
VIP Member
Posts: 290
Joined: 14 Nov 2002 0:01

Re: Progress Bar status indicator

Unread post by Martin Meyer » 9 Oct 2019 13:50

I have no experiences with progress bars. But there is a demo for it named "progress" in the examples (which can be installed by "Help" / "Install Examples...").
Regards Martin

Loffy
Active Member
Posts: 47
Joined: 15 Aug 2019 11:32

Re: Progress Bar status indicator

Unread post by Loffy » 10 Oct 2019 7:11

Martin,

Thanks. I have found the files.

Regards,

Loffy

Loffy
Active Member
Posts: 47
Joined: 15 Aug 2019 11:32

Re: Progress Bar status indicator

Unread post by Loffy » 10 Oct 2019 12:03

Martin,

Thanks for the pointer to the progress files, though they are a bit obtuse and a little dated, at least to me. Maybe I am a bit "frazzled" after a day out with my grandchildren. That also makes me "dated".

My current plan is to spend a few hours optimising my stream out code for greater efficiency. I think I have some options.

If anyone has other suggestions re the status bar then I would be appreciative.

A really good option would be for someone to point me to the predicate and clauses for the "tiny" bit of code that displays on the status bar when the "Build All" option is selected when generating projects. The Status bar is really nicely laid out and informative.

After my optimisation work I will go back to trying to find the VP code that generates that really nice status bar. Again, I know it is there somewhere.

Regards,

Loffy

Martin Meyer
VIP Member
Posts: 290
Joined: 14 Nov 2002 0:01

Re: Progress Bar status indicator

Unread post by Martin Meyer » 10 Oct 2019 22:29

"Compile", "Rebuild All", etc. are displaying infos about what is currently going on at the bottom of VIP's main window. Analogously you want to display your own progress infos in a status line at the bottom of the application window. So your question is how to get texts to there.

As said I am not very experienced in these matters, but I have tried it and it worked out like this:

I create a new GUI application style project:
pic1.jpg
pic1.jpg (63.02 KiB) Viewed 1136 times
I create a new toolbar:
pic2.jpg
pic2.jpg (142.8 KiB) Viewed 1136 times
I add a static text field in the toolbar:
pic3.jpg
pic3.jpg (134.54 KiB) Viewed 1136 times
In the attributes of the new toolbar I set style "Bottom":
pic4.jpg
pic4.jpg (165.47 KiB) Viewed 1136 times
In the task window attributes I remove the default ProjectToolbar (also deleting the strange empty line) and add my new toolbar:
pic5.jpg
pic5.jpg (179.49 KiB) Viewed 1136 times
continuing in next post because it lets me attach only 5 pics in this post...
Regards Martin

Martin Meyer
VIP Member
Posts: 290
Joined: 14 Nov 2002 0:01

Re: Progress Bar status indicator

Unread post by Martin Meyer » 10 Oct 2019 22:34

...continued from previous post

I add a timer listener in the task window:
pic6.jpg
pic6.jpg (142.2 KiB) Viewed 1136 times
I insert some code in the onTimer listener which will display the time in the text field of the new toolbar:
pic7.jpg
pic7.jpg (164.25 KiB) Viewed 1136 times
In the onShow listener I add a line to start a timer:
pic8.jpg
pic8.jpg (154.78 KiB) Viewed 1136 times
I run the project, voilà!
pic9.jpg
pic9.jpg (24.13 KiB) Viewed 1136 times
Regards Martin

Loffy
Active Member
Posts: 47
Joined: 15 Aug 2019 11:32

Re: Progress Bar status indicator

Unread post by Loffy » 11 Oct 2019 3:48

Martin,

Thanks for all the work you put into that. I did not expect that much help.

Regards,

Loffy

Loffy
Active Member
Posts: 47
Joined: 15 Aug 2019 11:32

Re: Progress Bar status indicator

Unread post by Loffy » 11 Oct 2019 13:14

Martin,

Thanks again. Your solution worked.

Now it is up to me to provide the toolbar indications I need.

Regards,

Loffy

Martin Meyer
VIP Member
Posts: 290
Joined: 14 Nov 2002 0:01

Re: Progress Bar status indicator

Unread post by Martin Meyer » 12 Oct 2019 1:50

I have found an easier solution. In a newly created GUI style project do as follows:

Add the declaration for a predicate displayStatus/1 in projectToolbar.cl:

Code: Select all

class projectToolbar   predicates     create : (vpiDomains::windowHandle Parent).   predicates     displayStatus : (string Text).   end class projectToolbar
Edit projectToolbar.pro a little so that it becomes:

Code: Select all

implement projectToolbar     open vpiDomains, vpiToolbar, resourceIdentifiers   class facts     statusCell : statusBarCell := erroneous.   clauses     create(Parent) :-         StatusBar = statusBar::newApplicationWindow(),         statusCell := statusBarCell::new(StatusBar, 0),         StatusBar:cells := [statusCell],         Toolbar = vpiToolbar::create(style, Parent, controlList),         setStatusHandler(Toolbar, displayStatus).   clauses     displayStatus(Text) :-         statusCell:text := Text.   % This code is maintained automatically, do not update it manually. 16:42:04-24.4.2013           ...the automatically generated code, leave it as it is...   % end of automatic code   end implement projectToolbar
Now you can display progress info texts by calls to projectToolbar::displayStatus/1.
Regards Martin

Loffy
Active Member
Posts: 47
Joined: 15 Aug 2019 11:32

Re: Progress Bar status indicator

Unread post by Loffy » 12 Oct 2019 5:33

Martin,

Thanks again.

I will try this solution.

Regards,

Loffy

Loffy
Active Member
Posts: 47
Joined: 15 Aug 2019 11:32

Re: Progress Bar status indicator

Unread post by Loffy » 13 Oct 2019 13:18

Martin,

I have tried this solution, though I have a problem when I go to display the progress bar.

I can send you some code grabs, though I (stupid me) still do not understand how to encapsulate the code so that it is nicely readable. I have seen references to code/hash code symbols, but I have not yet found an explicate example (for an old dummy like me) to grab the code to send it to you "nicely". Any help here would be good.

Back to the problem.

Everything is fine until I attempt to display the text message on the toolbar. I think the problem is that I have not "declared" a toolbar to display the message.

To go back to your previous solution, everything worked fine when it was incorporated into my project. I may have been getting ahead of myself by not understanding properly your indications to install your latest solution into a "newly created GUI style project". I installed your suggested code into my current project and removed all of the previous solution re the status bar.

My guess is that I still need to install a status bar at the bottom of my project.

I have saved the error messages if you need them.

Regards,

Loffy

Martin Meyer
VIP Member
Posts: 290
Joined: 14 Nov 2002 0:01

Re: Progress Bar status indicator

Unread post by Martin Meyer » 13 Oct 2019 16:19

To put a code grab into the post, click the "Code display" button
pic.jpg
pic.jpg (26.58 KiB) Viewed 1069 times
which will insert a BBCode tag pair template into the text. Then place your code via copy/paste between the tags.

When you create a new project, VIP makes a copy of a default project template to start with. For GUI style projects it already contains a top and a bottom toolbar in the application window. You see these toolbars when you execute a newly created GUI style project. If you move the mouse on the "File" menu label, the text "Open File" is displayed on the bottom toolbar.

The easier solution utilizes that bottom toolbar which comes by default with new GUI projects. Thatfore I said start with a "newly created GUI style project" because when you have already removed that toolbar, as done in the first solution, the easier solution will not work anymore (at least not, until you re-establish the default toolbar).

I suppose the cause of your problem with the easier solution is that you have already removed the default toolbars. If so, you need to re-establish them (if you do not want to start over creating a new project). I think adding the "ProjectToolbar" in the attributes of the task window should suffice. Probably the strange empty line, which is also there in new projects, is not needed.
Regards Martin

Loffy
Active Member
Posts: 47
Joined: 15 Aug 2019 11:32

Re: Progress Bar status indicator

Unread post by Loffy » 14 Oct 2019 13:07

Martin,

Re the code display icon:

I get none of these icons in my installation of VIP. I first installed the personal version a few months ago, then upgraded to the commercial version.

I have played again tonight and I cannot see any of the icons you displayed re Code display, nor any of the other icons in the same display.

I may be missing an option setting?

Re the status bar question I originally asked about; tomorrow I will revert to your first solution as I can see a way where I can change your timer display into something closer to what I am trying to display. I am not complaining here re your solution as you could not possibly have guessed what I wanted to do.

I thank you again for all of your work.

Regards,

Loffy

Martin Meyer
VIP Member
Posts: 290
Joined: 14 Nov 2002 0:01

Re: Progress Bar status indicator

Unread post by Martin Meyer » 14 Oct 2019 16:34

Hit the Post Reply Button as you did before, if necessary login,
and have a look above the message editor box. :D :D :D
Attachments
pic11.jpg
pic11.jpg (122.42 KiB) Viewed 1048 times
Regards Martin

Loffy
Active Member
Posts: 47
Joined: 15 Aug 2019 11:32

Re: Progress Bar status indicator

Unread post by Loffy » 15 Oct 2019 3:40

Martin,

Thanks again. My fault.

Gee it is hard to get good help these days.

Regards,

Loffy

Post Reply