Author |
Topic  |
|
aplotnikov
Germany
169 Posts |
Posted - 06/29/2020 : 06:42:16 AM
|
Origin: 2020b Operating System: W10Pro 1809
Exist() does not work with string arrays.
I would appreciate any helpful hint. |
|
YimingChen
1666 Posts |
|
Chris D
428 Posts |
Posted - 06/29/2020 : 09:39:55 AM
|
You can try this little coding trick:
StringArray sa;
int stringarray_exists = 0;
{
sa; // Change me to a non-existant StringArray name to test
stringarray_exists = 1;
}
stringarray_exists=;
Thanks, Chris Drozdowski Originlab Technical Support
|
 |
|
YimingChen
1666 Posts |
Posted - 06/29/2020 : 09:49:19 AM
|
Nice trick!
quote: Originally posted by Chris D
You can try this little coding trick:
StringArray sa;
int stringarray_exists = 0;
{
sa; // Change me to a non-existant StringArray name to test
stringarray_exists = 1;
}
stringarray_exists=;
Thanks, Chris Drozdowski Originlab Technical Support
|
 |
|
AKazak
Russia
1205 Posts |
Posted - 06/29/2020 : 4:51:26 PM
|
quote: Originally posted by Chris D
You can try this little coding trick:
StringArray sa;
int stringarray_exists = 0;
{
sa; // Change me to a non-existant StringArray name to test
stringarray_exists = 1;
}
stringarray_exists=;
Thanks, Chris Drozdowski Originlab Technical Support
Hm. Is stringarray_exists a function returning int? Why non-existing sa; will prevent stringarray_exists = 1; ?
--- AK |
Edited by - AKazak on 06/29/2020 4:51:42 PM |
 |
|
cpyang
USA
1406 Posts |
Posted - 06/29/2020 : 7:30:51 PM
|
if(sa.GetSize()==0/0)
type "no sa";
CP
|
 |
|
aplotnikov
Germany
169 Posts |
Posted - 06/30/2020 : 04:31:02 AM
|
quote: Originally posted by YimingChen
I will report it to see if we are going to improve it.
Hi, James,
thank you for your response!
Is it possible to make this type deletable as well?
Regards,
Alexei |
 |
|
aplotnikov
Germany
169 Posts |
Posted - 06/30/2020 : 04:40:27 AM
|
quote: Originally posted by Chris D
You can try this little coding trick
Hi, Chris,
Thank you for the coding trick - it is really amusing. However it does not work in the particular case - I do not understand, why. Unfortunately I cannot check it with different Origin versions anymore.
Anyway, many thanks and
Regards,
Alexei |
 |
|
aplotnikov
Germany
169 Posts |
Posted - 06/30/2020 : 05:12:54 AM
|
Hi, Chao,
Thank you very much for another nice coding trick! The problem is solved.
Regards,
Alexei |
 |
|
AKazak
Russia
1205 Posts |
Posted - 07/01/2020 : 12:32:02 PM
|
Still didn't get the trick by Chris. Appreciate any details.
--- AK |
 |
|
nick_n
Finland
125 Posts |
|
Chris D
428 Posts |
Posted - 07/02/2020 : 08:54:05 AM
|
Akazak,
To expound on what Nick said,
sa;
causes an error if the StringArray doesn't exist, so
stringarray_exists = 1;
would never get called and the script would abort.
But, wrapping the error-causing code in {} allows the error to get swallowed and the script jumps to after the closing }. The script continues without
stringarray_exists = 1;
ever getting called.
I hope this helps.
Thanks, Chris Drozdowski Originlab Technical Support
|
 |
|
AKazak
Russia
1205 Posts |
Posted - 07/02/2020 : 11:51:04 AM
|
quote: Originally posted by Chris D But, wrapping the error-causing code in {} allows the error to get swallowed and the script jumps to after the closing }.
Got it, thank you. Where does one read more about {...} wrap?
--- AK |
 |
|
nick_n
Finland
125 Posts |
|
nick_n
Finland
125 Posts |
|
AKazak
Russia
1205 Posts |
|
|
Topic  |
|