We help IT Professionals succeed at work.

Check out this week's podcast, "Dairy Farms to Databases: Community's Hand in Technology"Listen Now

x

VB frontend for PERL script - progress bar

colind
colind asked
on
333 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
Comment
Watch Question

Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
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.
icd

Commented:
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.).


Author

Commented:
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

icd

Commented:
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.

Author

Commented:
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

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.