Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 02:20:21 PM

Login with username, password and session length
Search:     Advanced search
* Home Help Search Calendar Links Login Register
+  Machsupport Forum
|-+  Mach Discussion
| |-+  VB and the development of wizards
| | |-+  External program called from VB Script
Pages: 1   Go Down
Print
Author Topic: External program called from VB Script  (Read 1800 times)
0 Members and 1 Guest are viewing this topic.
kc5qoc
Active Member

Offline Offline

Posts: 13


View Profile
« on: June 26, 2006, 01: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.
Logged
Brian Barker
Administrator
*
Offline Offline

Posts: 3,383



View Profile
« Reply #1 on: June 26, 2006, 06:10:03 PM »

Is this in a text file? or are you reading it from a program that is running?
Logged

Fixing problems one post at a time Wink

www.newfangledsolutions.com
www.machsupport.com
kc5qoc
Active Member

Offline Offline

Posts: 13


View Profile
« Reply #2 on: June 27, 2006, 09: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
Logged
Brian Barker
Administrator
*
Offline Offline

Posts: 3,383



View Profile
« Reply #3 on: June 27, 2006, 06: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
Logged

Fixing problems one post at a time Wink

www.newfangledsolutions.com
www.machsupport.com
kc5qoc
Active Member

Offline Offline

Posts: 13


View Profile
« Reply #4 on: June 28, 2006, 09: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  Cheesy

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

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.  Smiley

Thanks for looking into this - I appreciate your efforts.
Logged
kc5qoc
Active Member

Offline Offline

Posts: 13


View Profile
« Reply #5 on: July 05, 2006, 01: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.
Logged
Brian Barker
Administrator
*
Offline Offline

Posts: 3,383



View Profile
« Reply #6 on: July 05, 2006, 08:13:16 PM »

Thank you for the input! You are going to save many people from pulling out there hair Wink
Logged

Fixing problems one post at a time Wink

www.newfangledsolutions.com
www.machsupport.com
Pages: 1   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!