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
Click For Summary
SUMMARY

This discussion focuses on controlling Mathematica through the MS-DOS command line using Visual Basic for Applications (VBA) within CST Microwave Studio. The user successfully initiates Mathematica with the command Shell("math", vbNormalFocus), but encounters issues when attempting to send commands directly via Shell("1+1", vbNormalFocus), as it opens a new command line instance instead of sending the command to the existing Mathematica session. The solution proposed involves generating a script file with the desired commands and executing it through the shell, which is a common approach for interfacing with external applications.

PREREQUISITES
  • Familiarity with Visual Basic for Applications (VBA)
  • Understanding of command line operations in MS-DOS
  • Basic knowledge of Mathematica syntax
  • Experience with CST Microwave Studio macros
NEXT STEPS
  • Research how to create and execute script files in VBA
  • Learn about the WinWrap Basic variant used in CST macros
  • Explore advanced command line techniques for Mathematica
  • Investigate methods for inter-process communication in Windows
USEFUL FOR

This discussion is beneficial for developers working with CST Microwave Studio, VBA programmers looking to integrate Mathematica, and anyone interested in automating command line operations in Windows environments.

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.
 

Similar threads

  • · Replies 18 ·
Replies
18
Views
6K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
Replies
12
Views
4K
  • · Replies 13 ·
Replies
13
Views
4K
Replies
13
Views
13K
  • · Replies 27 ·
Replies
27
Views
11K
Replies
14
Views
6K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 1 ·
Replies
1
Views
3K