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

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

SRIPT EDITOR

johanpg
1-Newbie

SRIPT EDITOR

Hello,

I used the Metadata to save the values on my ListBoxState.

The issue I have now, is that I am using the same ListBox, with different Inputs in different locations of my calculations.

When I save the file close and reopen it, all my values are now set as the one I saved the last. Is there any way to keep the values as their original input??

I am attaching a sample of what I have been doing.

Please Help

Thank you,
Johan
12 REPLIES 12

I do not really understand your question but I noticed that you use the variable myMetadata.Name
has the same name "ListBoxState_GRADE"

Hello,

Thank you very much for your answer. By using a different name, for every script editor we will get different results, what is what we want to achieve.

The only issue we have now, is that every time that we want to use the same Script Editor, we will need to Edit the Script, change the metadata name internally, and then save it with a different name.

Is there any way that we can change the name of the metadata internally without editing the Script every time we want to do so??

For Example:

myMetadata.Name = "ListBoxState_Grade_[i_cont]"

i_cont will be different for every name, and we will need to define:

i_cont:=i_cont + 1 every time we use the ListBox.

Thank you for your help,
Johan
RichardJ
19-Tanzanite
(To:johanpg)

The script needed a little work. I would have done it days ago, but I have been really busy.

Richard

Hello Richard,

Thank you very much for your answer, it is very helpful.

I noticed that you save the listbox with diferent names: "Listbox1", "Listbox2", "Listbox3",... each time we are using it

So we will need to rename the Listbox each time we are using it, which we would like to avoid, because I am not the only using these calculations.

This is the reason I include a parameter i_cont, and i_cont = i_cont + 1 each time we are using the Listbox. So we would like to rename the Listbox as:

"Listbox[i_cont]" , so each time we will use the Listbox, it is saved with a different name without having to rename it manually, ie:

i_cont = 0 ---> "Listbox[0]"
i_cont = 1 ---> "Listbox[1]"
i_cont = 2 ---> "Listbox[2]" ....

Is there any way to do it automatically or similar to what I am proposing?

Please see the attached file.

Thank you once again Richard for your help,
Johan

RichardJ
19-Tanzanite
(To:johanpg)

Use concat("Listbox",num2str(i_cont)) in the placeholder in the listboxes.

Richard

Thank you Richard,

You are awesome!!!!!!!!!!

Johan

Hello Richard,

I made my first calculation using script editors, and they work good in my computer. Then I submitted this calculations to a coworker by email for checking, and when he try to open the file a lot of errors pop out. We both are using MathCAD 14.

Then I converted the file to mathcad 13, and re-send it, and he has the same errors.

Do you know what could be the issue causing these errors ??

I am attaching the file.

Thank you,
Johan

Hello Richard,
This is the file I am referencing in the previous message, causing several errors when my co-worker try to open it in his computer.
Thank you,
Johan
RichardJ
19-Tanzanite
(To:johanpg)

Sorry. I've been away on a business trip.

If I open it I don't get any errors, although it takes a heck of a long time to calculate. If I open some of the collapsed areas there is some red, because you are trying to access the 7th value of "bending" (because i_cont=6), which doesn't exist. Is that what you mean?

Richard

Hello Richard,

Yes you are right, some of the collapsed areas have the bending in red. I don't really needed this calculation in those locations, so I removed them.

After I removed the "red" calculations, I re-sent it to my coworker and he still have the same errors:

Line 22, 23 , 28 �

He is also asking me:

Is there a file that defines the properties of each species that I�m missing, as the pr, qr values are not defined?

I think it could be something related to his settings but I don't know.

Another question, how could I make my calculations quicker, because like you saw, this calculations are simple but take a heck of time...

Thank you Richard,
Johan
RichardJ
19-Tanzanite
(To:johanpg)

On 7/28/2009 3:51:52 PM, johanpg wrote:
> he still have
>the same errors:
>
>Line 22, 23 , 28 �

How can he have errors at three lines? When the script encounters an error it exits.

what is the error message he gets?

>He is also asking me:
>
>Is there a file that defines
>the properties of each species
>that I�m missing, as the pr,
>qr values are not defined?

Well, they are not defined because the listboxes don't work.

>I think it could be something
>related to his settings but I
>don't know.

Check "Tools", "Preferences", "Script Security".

>Another question, how could I
>make my calculations quicker,
>because like you saw, this
>calculations are simple but
>take a heck of time...

The listboxes take a long time to calculate. You seem to have some that are duplicates, so you could reduce the number. You could also switch to the other way of saving the state. Because it doesn't write to the metadata it is much faster (on my machine about 6.5 times faster). See the attached for a comparison. Scroll to the end, then hit Ctrl F9 to recalculate everything and look at the times. I suspect the operation of writing the metadata may slow down as the worksheet size increases too. The listboxes in your sheet seem to take longer to calculate than the ones in this sheet.

Richard

Richard,
Thank you very much for the new approach. With this new approach the mathcad file you sent me is about 5.5 faster in my computer.
Thank you again,
Johan
Top Tags