Skip to main content
6-Contributor
Mar 14, 2025 1:50 AM UTC
Solved

Mathcad prime 10. Advanced Controls. List. Writing a script on JS

I have an array (numbers of rows - 1,  number of columns - can be different). Example: I enter a variable in mathcad d = [1 5 10 15] and i want this array to be displayed in my list as d = 1   d= 5 etc... Help please. Preferably in JS. Translated using Google Translate.

Werner_E
Werner_EAnswer
25-Diamond I
Mar 14, 2025 4:41 AM UTC

> i want this array to be displayed in my list as d = 1

 

Which list? And where? An external text file?

Please specify more precisely and if possible give one or two examples to show what you are looking for.

 

Ahh, you shouldn't hide important informations just in the thread subject!

In case you are looking for a vector to be the input for the items of a list box, you will find some examples here in the forum - some more , some less sophisticated.

 

A simple one is attached - hope it helps

Werner_E_0-1741928104322.png

 

// TODO: Add your initialization code here
// Initialize Selection If desired
ListBox.CurSel(0);

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

function ListBoxEvent_Exec(Inputs, Outputs) {
	var options = Inputs[0].Value;

	ListBox.ResetContent()
	for(var i=0; i < options.length; i++) {
	ListBox.AddString(options[i]);
	}

	Outputs[0].Value = options[ListBox.CurSel()];
};

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

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

 

 

4 replies

18-Opal
Mar 14, 2025 4:10 AM UTC

Like this?  

ppal_1-1741925420206.png

 

Translate
Werner_E
Werner_E25-Diamond IAnswer
25-Diamond I
Mar 14, 2025 4:41 AM UTC

> i want this array to be displayed in my list as d = 1

 

Which list? And where? An external text file?

Please specify more precisely and if possible give one or two examples to show what you are looking for.

 

Ahh, you shouldn't hide important informations just in the thread subject!

In case you are looking for a vector to be the input for the items of a list box, you will find some examples here in the forum - some more , some less sophisticated.

 

A simple one is attached - hope it helps

Werner_E_0-1741928104322.png

 

// TODO: Add your initialization code here
// Initialize Selection If desired
ListBox.CurSel(0);

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

function ListBoxEvent_Exec(Inputs, Outputs) {
	var options = Inputs[0].Value;

	ListBox.ResetContent()
	for(var i=0; i < options.length; i++) {
	ListBox.AddString(options[i]);
	}

	Outputs[0].Value = options[ListBox.CurSel()];
};

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

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

 

 

Translate
6-Contributor
Mar 14, 2025 3:02 PM UTC

This is exactly what i wanted, thank you

Translate
Werner_E
25-Diamond I
Mar 14, 2025 3:46 PM UTC

@panzerbaha wrote:

This is exactly what i wanted, thank you


Glad you got what you needed.

So you may consider closing the thread unless there are additional related questions.

Translate