Controlling Mathematica Through the MS-DOS Command Line in VBA for CST MWS

  • Thread starter Thread starter LowerySj
  • Start date Start date
  • Tags Tags
    Line Mathematica
AI Thread Summary
Controlling Mathematica through the MS-DOS command line via Visual Basic for Applications (VBA) is challenging, particularly when trying to send commands after launching Mathematica. The initial command to open Mathematica works with Shell("math", vbNormalFocus), but subsequent commands like Shell("1+1", vbNormalFocus) inadvertently open a new command line window instead of sending input to the existing Mathematica interface. A suggested workaround involves creating a script file that contains all desired commands and executing it through the shell, which may allow for proper command execution without opening multiple command line instances. However, it's noted that the specific VBA variant used in CST Microwave Studio, WinWrap Basic, may present additional limitations in this context.
LowerySj
Messages
2
Reaction score
0
Hi, guys. I need to control Mathematica through the MS-DOS command line in Visual Basic for Applications as part of a macro for CST Microwave Studio. I can call Mathematica through the command line just fine with

Code:
Shell("math", vbNormalFocus)

but when I try to enter commands afterward, such as

Code:
Shell ("1+1", vbNormalFocus)

then VBA interprets this as me wanting to open another command line box instead of using the one I just opened and which has the Mathematica interface up. I've searched the internet for a few hours trying to fix this with no luck, so I thought I'd ask you guys. It seems like if I just knew one or two more lines of code I could fix this. Any help would be greatly appreciated.

On a side note: the variety of VBA that CST's macro system uses is WinWrap Basic.
 
Computer science news on Phys.org
Sending commands one after the other will never work.

Generally speaking (not sure this would work with Mathematica in particular) is to generate a script file containing all the commands one wants an external program to perform, then open a shell executing the program with input from the script file.
 
In my discussions elsewhere, I've noticed a lot of disagreement regarding AI. A question that comes up is, "Is AI hype?" Unfortunately, when this question is asked, the one asking, as far as I can tell, may mean one of three things which can lead to lots of confusion. I'll list them out now for clarity. 1. Can AI do everything a human can do and how close are we to that? 2. Are corporations and governments using the promise of AI to gain more power for themselves? 3. Are AI and transhumans...
Sorry if 'Profile Badge' is not the correct term. I have an MS 365 subscription and I've noticed on my Word documents the small circle with my initials in it is sometimes different in colour document to document (it's the circle at the top right of the doc, that, when you hover over it it tells you you're signed in; if you click on it you get a bit more info). Last night I had four docs with a red circle, one with blue. When I closed the blue and opened it again it was red. Today I have 3...

Similar threads

Back
Top