cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

Mathcad Prime 10 - Text Box Advanced Controls

Andy_C
11-Garnet

Mathcad Prime 10 - Text Box Advanced Controls

Hi,

I am trying to configure the new MCP10 Text Box Advanced Controls.

I want to use the Text Box as a PASS/FAIL display but I am having two issues.

1) How do I pass more than one input into the Text Box? Currently, I can only add one input.
2) How do I display text that is a result of the JScript routine in the box? (similar to how the Advanced Controls demo was shown in MCP10 promo, i.e., PASS = green, FAIL = red and so on).

Currently, because I cannot pass slider_test and Limit into the Text Box, I have manually set Limit = 5 in JS (testing code).

Andy_C_0-1716592254077.png

 

var slider_test; // Define the external variable
var test;
var Limit;
var limit;

function TextBoxEvent_Start(Inputs, Outputs) {
// Assign the value of 'slider_test'
slider_test = Inputs[0].Value; // Ensure this correctly gets the input value
Limit = 5; // Ensure this correctly gets the input value
test = slider_test
limit = Limit
}

function TextBoxEvent_Exec(Inputs, Outputs) {
// Output "PASS" or "FAIL" based on the value of 'slider_test' with the criterion slider_test > 1
if (test > limit) {
Outputs[0].Value = "PASS";
} else {
Outputs[0].Value = "FAIL";
}
}

function TextBoxEvent_Stop(Inputs, Outputs) {
// TODO: Add your code here
}

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:Andy_C)

I don't know why we can't add a second input, but you can use a vector for the input.

Werner_E_0-1716595646568.png

 

 

 

 

function TextBoxEvent_Start(Inputs, Outputs) {
    // TODO: Add your code here
   TextBox.Font.Size = 23;
   if (Inputs[0].Value[0] > Inputs[0].Value[1]) {
         TextBox.BackColor(0xAAFFAA);
         TextBox.Text("PASS"); 
   } else {
 	TextBox.BackColor(0xFFAAAA);
	TextBox.Text("FAIL");
    }
};

function TextBoxEvent_Exec(Inputs, Outputs) {
    Outputs[0].Value = TextBox.Text();
};

function TextBoxEvent_Stop(Inputs, Outputs) {
    // TODO: Add your code here
};

 

 

 

 

See attached file

 

 

View solution in original post

6 REPLIES 6
Werner_E
25-Diamond I
(To:Andy_C)

I don't know why we can't add a second input, but you can use a vector for the input.

Werner_E_0-1716595646568.png

 

 

 

 

function TextBoxEvent_Start(Inputs, Outputs) {
    // TODO: Add your code here
   TextBox.Font.Size = 23;
   if (Inputs[0].Value[0] > Inputs[0].Value[1]) {
         TextBox.BackColor(0xAAFFAA);
         TextBox.Text("PASS"); 
   } else {
 	TextBox.BackColor(0xFFAAAA);
	TextBox.Text("FAIL");
    }
};

function TextBoxEvent_Exec(Inputs, Outputs) {
    Outputs[0].Value = TextBox.Text();
};

function TextBoxEvent_Stop(Inputs, Outputs) {
    // TODO: Add your code here
};

 

 

 

 

See attached file

 

 

DJNewman
17-Peridot
(To:Andy_C)

Please carefully read for question #1:

https://support.ptc.com/help/mathcad/r10.0/en/index.html#page/PTC_Mathcad_Help/add_remove_variables.html#

 

As for question #2:

https://support.ptc.com/help/mathcad/r10.0/en/index.html#page/PTC_Mathcad_Help/textbox_state_properties.html#

 

You aren't trying to have the Output read as PASS or FAIL but TextBox.Text("PASS"); or TextBox.Text("FAIL");

I manage the Creo and PTC Mathcad YouTube channels for PTC, as well as all PTC Mathcad marketing in general.
Werner_E
25-Diamond I
(To:DJNewman)


@DJNewman wrote:

Please carefully read for question #1:

https://support.ptc.com/help/mathcad/r10.0/en/index.html#page/PTC_Mathcad_Help/add_remove_variables.html#

 

OMG! The way to add more than one input really is less than non-intuitive. Who would have thought of implementing something so impractical? Silly!

 

I found information in the help (Text Box Format Properties) about changing the font size. But where can we find information about changing  font family, font style, alignment, etc.?

 

@Andy_C 

Find attached a worksheet including a TextBox with two inputs rather than a vector input (thanks to the information in the link provided by @DJNewman )
You can also add an input by pressing Shift-Space (if the cursor is on an already existing input place holder.

 

DJNewman
17-Peridot
(To:Werner_E)

Honestly, I was surprised myself when I saw that was the way to add more than one input.

Font colour (or "ForeColor") is on the same page as font size: https://support.ptc.com/help/mathcad/r10.0/en/index.html#page/PTC_Mathcad_Help/textbox_format_properties.html#

I'm sure there is a class for alignment, but I don't know what it is; but you can adjust it in the script's Properties.

 

I haven't figured out the others yet.

I manage the Creo and PTC Mathcad YouTube channels for PTC, as well as all PTC Mathcad marketing in general.
Werner_E
25-Diamond I
(To:DJNewman)

Thanks, had found out that forecolor is the font color and implemented it in the last file I posted.

 

The documentation in the help is definitely very incomplete and there is a lot of room for improvement...

Andy_C
11-Garnet
(To:Werner_E)

Thank you @Werner_E  and @DJNewman. Both of you recommendations helped. 
@Werner_E especially! Always coming in with the fix - much appreciated!!

And, I agree--the documentation, and examples, for rolling out these features is definitely lacking!!

Announcements

Top Tags