Solved

VB frontend for PERL script - progress bar

Posted on 1998-01-19
6
294 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
  • 3
  • 3
6 Comments
 
LVL 5

Accepted Solution

by:
icd earned 200 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

895 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now