How to generate new numbers if i run the program everytime from the begining?

102 Views Asked by At

I am working on CATScript in optimization of a part.

When I run the script everytime it shoud provide numbers in ascending order.

For example if I run the program for the first time it should provide the output as " 1 " and if I run the program again it shoud provide the output as " 2 " and so on.

I am stuck with this and I could not figure out th logic that we have to use here.

Looking forward for your help.

Thank you!!

2

There are 2 best solutions below

0
On BEST ANSWER

An option (matlab based) could be to save a counter variable to a .mat-file at the end of the script, which is then loaded again at the beginning of the script.

That would allow you to keep track of how many times the script have been run.

0
On

In CATIA if it is being run multiple times on the same part/product, you could add a hidden, integer parameter to the specification tree and increment it each time the macro is run.

Another, more generic way would be to create a text file on the user's local and update the number in the text file.