Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VB frontend for PERL script - progress bar

Posted on 1998-01-19
6
Medium Priority
?
303 Views
Last Modified: 2012-06-21
Currently i have a perl script that I am developing a Visual Basic frontend for.  Basically, all Visual Basic does is present forms to the user, in which data is entered, then writes that to file...  PERL waits for the VB program to terminate, then reads the data from file and processes it.  Simple stuff.  However, I have a new need... I would like to implement a nice windows progress bar for my script and for that I am guessing that I need PERL to send some kind of message to my Visual Basic Program.  I'm pretty sure that this can be done with the Win32API module.

Can somebody give me some example code of how perl might tell VB to upgrade a progress bar by a certain increment?  What I thought might be possible is for perl to figure out what the increment is (out of 100), to send that information to the VB program, then to send another message every time the progress bar is to be updated by that increment.  I have no idea how to do this.  Any help is very much appreciated.

Colin
0
Comment
Question by:colind
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 5

Accepted Solution

by:
icd earned 800 total points
ID: 1209613
I assume that this is *not* a cgi script.

If the perl program is taking some time to complete, say more than two or three seconds, then the following approach would work.

Every few seconds (there is no need for a more frequent update than about once per second). The perl script writes to a file with a single value, the percentage of the process that is completed, and then closes the file. The VBScript can open and read this file periodically to find out the progress.

If you want to use inter-process communication then this depends upon the operating system (which you did not specify, but I assume is Windows NT). This is more difficult and requires a knowledge of Windows programming, rather than perl programming. If you want to take this approach then you should obtain a module to add to perl that gives access to the API functions. I am sure one exists, I can't remember the name but I will do a search for it for you.

0
 

Author Comment

by:colind
ID: 1209614
I thought about doing this...  The problem I had was that I wasn't sure what would happen if PERL and VB both tried to open the file at the same time.  Would there be some kind of error?  I guess I would just have to do a test in PERL to make sure that the file was open before trying to write to it.  If I wrote to an unopen file, my progress bar would show something like 80% when the processing was actually at 100%.  How might this affect the VB side?

I knew about the perl module that interfaces with the Win32 API, it is maintained by Aldo Calpini...  It's called Win32::API and can be found at:  http://194.247.167.1/DADA/PERL/API/index.sht

I was hoping somebody could show me how to use this to pass a value from PERL to VB and then how to cause an event which the VB program could respond to.

I will try your method though and see how it pans out.

Thank you.
0
 
LVL 5

Expert Comment

by:icd
ID: 1209615
There should be little chance of a conflict. VB is only reading and Perl only writing. If either VB or Perl fail to open the file then at worst there will be a small jump from (say) 80% to 82% missing out 81%. I suspect that any attempt to calculate percentage done (percentage of time?) will always be jumpy anyway. (At least all the ones I have seen so far have been anyway.).


0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:colind
ID: 1209616
That's right...  I was thinking of just passing a message to VB saying update the progress bar by the increment...  If instead I say, put the progress bar at 76.8%, then the progress bar would always be right.  

Actually, the way that my program works, the progress bar thing won't be all that jumpy.  It's one huge loop which takes a fairly specific amount of time for each iteration and so time-wise, the progress bar would always be very close.

Do you have any knowledge of how to do implement a progress bar in VB?  Is it difficult?  Let's say I use your idea and perl writes 80.7% to the first line of a file.  How would VB turn that into a progress bar showing 80.7% completion?

Thanks in advance,

Colin

0
 
LVL 5

Expert Comment

by:icd
ID: 1209617
I am not familar with VB although I once saw some code written in either C++ or VB, I can't remember. It is something to do with creating a couple of images, one in blue with white text, one in white with blue text (for example) and then displaying the first 80.7% of the blue image and then the final 19.3% of the white image.

I could not comment on the specifics however. The article I saw was on the Microsoft Developers Network CD-ROM's. You might find it if you do a search for progress bars on the Microsoft site.

0
 

Author Comment

by:colind
ID: 1209618
I had another idea. I know that it is quite easy to use OLE through perl using the win32::ole module...  I could just control some property of some object on my VB form and then VB could read from that property and respond.  I think that that will actually turn out to be the easiest and most reliable solution.  Thanks for your help.

COlin
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question