Run an external program?

Status
Not open for further replies.

Benjamin J. Weiner

Usenet Archive
Joined
Jan 6, 2002
Messages
3
Reaction score
0
Does anyone know how i can run an external program from the Microstation BASIC language? I want to run a postscript conversion program from with a maro I use to generate PS files.

Thank You,

Ben Weiner

Time Warner Cable, Albany - Design Department
 
Hi Benjamin,
Here's a macro I use to start a VB application:

Sub Main
Dim keyin As String
Dim vb_apps As String
vb_apps = MbeGetConfigVar ("VB_APPS")
keyin = "start " + vb_apps + "FileCreate.exe data=" + vb_apps + "filecreate.dat " & _ MbeDgnInfo.dgnFileName

If FileExists(vb_apps + "\FileCreate.exe") Then
MbeSendKeyin keyin
Else
MbeMessageBox "Required file FileCreate.exe is missing." End If End Sub

The important keyword is "start" which is then passed the location of the .exe from the config var VB_APPS. The rest of the keyin is just providing a data file, then the name of the current design file.

HTH,
Simon

"Benjamin J. Weiner" wrote:
Does anyone know how i can run an external program from the Microstation BASIC language? I want to run a postscript conversion program from with a maro I use to generate PS files.

Thank You,

Ben Weiner

Time Warner Cable, Albany - Design Department
 
An alternative is to compile an MDL program that is delivered uncompiled from Bentley called NTBANG. This lets the user pass DOS command lines back to the operating system from a microstation keyin.

I.E
If you write a macro the line could look like this:

MBESendCommand "MDL LOAD NTBANG"
MBESendKeyin "DOS C:\PROGRA~1\MICROS~1\OFFICE\WINWORD.EXE"

This does however lock up microstation until the external program is closed down.

To get round this is easy as you can call a DOS batch file to run the application you want. This batch file would close after completion thus releasing microstation with your new application now running.

Read the readme delivered with the NTBANG program.
 
In general I was thinking that we should resurrect the old ! and % syntax for key-ins. We did this a long time ago for DOS, but it still applies today.

So MicroStation would take the key-in !notepad and run notepad, or %mybatch.bat would open a command shell and run mybatch.bat.

! = send the key-in to operating system
% = start a command shell and process the key-in

(Note that the "start" key-in was for starting MicroCSL programs and does extra processing that you may not want for staring executables.)

Does this sound good, would anyone use it?

Thanks,

Gino

"Benjamin J. Weiner" wrote:

Does anyone know how i can run an external program from the Microstation BASIC language? I want to run a postscript conversion program from with a maro I use to generate PS files.

Thank You,

Ben Weiner

Time Warner Cable, Albany - Design Department
 
Hi Gino,
Great idea. One suggestion: when the ! is processed, assume the default directory of the current DGN file (or DWG file, I suppose), not x:\Bentley\... This is useful for commands such as Copy (the current file to another name) and to print files created by apps (macros) that automatically default to the current DGN dir. Along the same lines, this could be controlled by configuration var:
MS_BANG = 0 ...default to ...\Bentley\... dir
MS_BANG = 1 ...default to current dgn path
MS_BANG = 2 ...default to directory defined by MS_BANG_PATH path (MS_BANG_PATH = q:\myAppDirectory\)

One last thing: I if this is added to a maintenance release, please update J as well as V8. It'll probably be a while before we officially roll-out V8.

Thanks,
Simon

Gino Cortesi wrote:
In general I was thinking that we should resurrect the old ! and % syntax for key-ins. We did this a long time ago for DOS, but it still applies today.

So MicroStation would take the key-in !notepad and run notepad, or %mybatch.bat would open a command shell and run mybatch.bat.

! = send the key-in to operating system
% = start a command shell and process the key-in

(Note that the "start" key-in was for starting MicroCSL programs and does extra processing that you may not want for staring executables.)
...
 
Yes Gino - definitely. Can you confirm whether the "shell" function, which I use in MicroStation Basic is supposed to work and if it will remain supported. This seems a good alternative, but it only works from MS Basic as far as I know.
 
Status
Not open for further replies.

Latest threads

Back
Top