Hello Guest it is April 19, 2024, 05:11:01 AM

Author Topic: External program called from VB Script  (Read 6139 times)

0 Members and 1 Guest are viewing this topic.

External program called from VB Script
« on: June 26, 2006, 02:35:45 PM »
I am working on a wizard which needs to execute and external program. I is executable in a cmd window and requires several parameters. (i.e. >stretch file.in file.out xorg xact yorg yact )

Does anyone know how this can be accomplished in VB script ? I have looked at the shell command but can not figure for the life of me how to pass it variables.

Thanks for your help.
Re: External program called from VB Script
« Reply #1 on: June 26, 2006, 07:10:03 PM »
Is this in a text file? or are you reading it from a program that is running?
Fixing problems one post at a time ;)

www.newfangledsolutions.com
www.machsupport.com
Re: External program called from VB Script
« Reply #2 on: June 27, 2006, 10:52:57 AM »
The program is one I wrote a few years back in C. It is an exe and called from a command line with the parameters mentioned before.

I could put it in a script *********x.bat also if that would help. The biggest issue I have is passing it values read from the encoder DRO
Re: External program called from VB Script
« Reply #3 on: June 27, 2006, 07:31:48 PM »
There is a way to send keystrokes from VB... do you think that would help? Other than that there is no way to move the data...
Sorry
Brian
Fixing problems one post at a time ;)

www.newfangledsolutions.com
www.machsupport.com
Re: External program called from VB Script
« Reply #4 on: June 28, 2006, 10:47:25 AM »
I did some playing around with the shell() command in VB. I figured what the heck - the worst it could do is reformat my drive and I would have to load Linux  :D

I tried X=Shell("MyProg.bat hello there",1)
MyProg.bat is:
---------
echo off
echo %1% %2%
pause
--------------
and to my amazement IT WORKED   :)

It opened a cmd window which said:

Hello There
press any key to continue ....

So the documentation is a little misleading. In the statement X=Shell("command",window_style), "comand"  means anything you would type on the command line including parameters. So one is able to pass it the values from encoders or DROs very easily.

My wizard is 99% done.  :)

Thanks for looking into this - I appreciate your efforts.
Re: External program called from VB Script
« Reply #5 on: July 05, 2006, 02:55:15 PM »
I have the shell command working in VB but a word to the wise:
If you have multiple shell command which use the cmd.exe be aware that they all execute in order wheather the previous command is done or not. Thus if one program creates a file that the second is going to use, the file may be in an incomplete state. It varies as to the size of the file being processed. If you wish to do this type of thing use a bat file as this will allow control of the execution.
Re: External program called from VB Script
« Reply #6 on: July 05, 2006, 09:13:16 PM »
Thank you for the input! You are going to save many people from pulling out there hair ;)
Fixing problems one post at a time ;)

www.newfangledsolutions.com
www.machsupport.com