Machsupport Forum
Mach Discussion => VB and the development of wizards => Topic started by: kc5qoc 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.
-
Is this in a text file? or are you reading it from a program that is running?
-
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
-
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
-
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.
-
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.
-
Thank you for the input! You are going to save many people from pulling out there hair ;)