The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 How to check the existence of a string array?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

aplotnikov

Germany
169 Posts

Posted - 06/29/2020 :  06:42:16 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin: 2020b
Operating System: W10Pro 1809

Exist() does not work with string arrays.

I would appreciate any helpful hint.

YimingChen

1666 Posts

Posted - 06/29/2020 :  09:37:54 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Exist() function doesn't search StringArray according to:
https://www.originlab.com/doc/LabTalk/ref/Exist-func

I will report it to see if we are going to improve it.

James
Go to Top of Page

Chris D

428 Posts

Posted - 06/29/2020 :  09:39:55 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

YimingChen

1666 Posts

Posted - 06/29/2020 :  09:49:19 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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


Go to Top of Page

AKazak

Russia
1205 Posts

Posted - 06/29/2020 :  4:51:26 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 06/29/2020 :  7:30:51 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply

if(sa.GetSize()==0/0)
  type "no sa";



CP
Go to Top of Page

aplotnikov

Germany
169 Posts

Posted - 06/30/2020 :  04:31:02 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

aplotnikov

Germany
169 Posts

Posted - 06/30/2020 :  04:40:27 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

aplotnikov

Germany
169 Posts

Posted - 06/30/2020 :  05:12:54 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi, Chao,

Thank you very much for another nice coding trick! The problem is solved.

Regards,

Alexei
Go to Top of Page

AKazak

Russia
1205 Posts

Posted - 07/01/2020 :  12:32:02 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Still didn't get the trick by Chris.
Appreciate any details.


---
AK
Go to Top of Page

nick_n

Finland
125 Posts

Posted - 07/01/2020 :  2:05:20 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

It's kind of error handling.
https://www.originlab.com/doc/LabTalk/guide/Error-Handling

stringarray_exists is a variable (not function) which stays 0 in case if {...} fails.
Best,

Nikolay
Go to Top of Page

Chris D

428 Posts

Posted - 07/02/2020 :  08:54:05 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

AKazak

Russia
1205 Posts

Posted - 07/02/2020 :  11:51:04 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

nick_n

Finland
125 Posts

Posted - 07/02/2020 :  1:29:20 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
:) https://www.originlab.com/doc/LabTalk/guide/Error-Handling
BR,

Nikolay
Go to Top of Page

nick_n

Finland
125 Posts

Posted - 07/02/2020 :  1:36:17 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Also,
https://www.originlab.com/doc/LabTalk/guide/Debugging-Tools
{script} (special syntax)

Nikolay
Go to Top of Page

AKazak

Russia
1205 Posts

Posted - 07/03/2020 :  04:32:16 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by nick_n

Also,
https://www.originlab.com/doc/LabTalk/guide/Debugging-Tools
{script} (special syntax)

Nikolay



Spasibo!


---
AK
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000