Prompting for a Text Entry
You can edit a macro to prompt for a text entry.
Text entries (strings) are used for various purposes in a Simcenter STAR-CCM+ simulation, such as renaming objects.

For this example, a simple macro was recorded to change the name of a continuum from Physics 1 to Fluid.

The macro, named string.java, contains the following code:
// STAR-CCM+ macro: string.java
package macro;
import java.util.*;
import star.common.*;
import star.base.neo.*;
public class string extends StarMacro {
public void execute() {
Simulation simulation_3 =
getActiveSimulation();
PhysicsContinuum physicsContinuum_0 =
((PhysicsContinuum) simulation_3.getContinuumManager().
getContinuum("Physics 1"));
physicsContinuum_0.setPresentationName("Fluid");
}
}
This typical macro code contains the value for the stopping criterion that is entered during recording—it remains constant. However, when the macro contains code for user input, it pauses to activate a dialog in which you can specify that value.

Once you click OK, the macro continues.
The code of string.java is modified as follows to make this work:
// STAR-CCM+ macro: string.java
package macro;
import java.util.*;
import star.common.*;
import star.base.neo.*;
public class string extends StarMacro {
public void execute() {
Simulation simulation_3 =
getActiveSimulation();
PhysicsContinuum physicsContinuum_0 =
((PhysicsContinuum) simulation_3.getContinuumManager().
getContinuum("Physics 1"));
String ret = promptUserForInput("Rename", "Physics 1"); /* <---- NEW CODE */
physicsContinuum_0.setPresentationName(ret); /* <---- "ret" replaces
* the text entry that was recorded automatically */
}
}