Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X
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).
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
}
Solved! Go to Solution.
I don't know why we can't add a second input, but you can use a vector for the input.
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
I don't know why we can't add a second input, but you can use a vector for the input.
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
Please carefully read for question #1:
As for question #2:
You aren't trying to have the Output read as PASS or FAIL but TextBox.Text("PASS"); or TextBox.Text("FAIL");
@DJNewman wrote:
Please carefully read for question #1:
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.?
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.
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.
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...