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
 Looping over User Parameter
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

AKazak

Russia
1205 Posts

Posted - 07/07/2021 :  12:22:02 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
OriginPro 2021b (64-bit) SR2 9.8.5.212
Windows 10 21H1 x64

Greetings!

I want to fix User Parameters using LT.
For this purpose, I want to loop over visible User Parameters.
To do this I need to get the total number of defined items.

How do I get User Parameter count?

Thanks.

---
Andrey

AKazak

Russia
1205 Posts

Posted - 07/07/2021 :  12:42:09 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I tried using the following snippet:
for(int j = 1; j <= 10; j++)
  {
   type wks.UserParam$(j)$;
  }

However, when j equals from 1 to 3 it returns units of the columns.
This seems to be odd since UserParam should return parameter names.

---
Andrey

Edited by - AKazak on 07/07/2021 12:42:58 PM
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 07/07/2021 :  2:42:51 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Try

loop(i,1,10){wks.userparam$(i)=;};


And to find the count, try

nn=0;loop(i,1,10) {if(wks.userparam$(i)) nn = i;};nn=;


CP
Go to Top of Page

AKazak

Russia
1205 Posts

Posted - 07/08/2021 :  05:51:59 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by cpyang

Try

loop(i,1,10){wks.userparam$(i)=;};


And to find the count, try

nn=0;loop(i,1,10) {if(wks.userparam$(i)) nn = i;};nn=;


CP



Got it!
Thanks.

---
Andrey
Go to Top of Page

AKazak

Russia
1205 Posts

Posted - 07/08/2021 :  06:19:51 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I had another side question.
https://www.originlab.com/doc/LabTalk/guide/Looping-Over-objs provides many examples using both for and loop LT commands.
What are the principal differences between for and loop commands?

---
Andrey
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 07/08/2021 :  06:56:35 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
There is no difference on how they work. Loop command was introduced first to cover the most typical use of a loop and for command was added later to be like C language.

CP
Go to Top of Page

AKazak

Russia
1205 Posts

Posted - 07/08/2021 :  09:08:04 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by cpyang

There is no difference on how they work. Loop command was introduced first to cover the most typical use of a loop and for command was added later to be like C language.

CP




OK, thank you for clarifying this.

---
Andrey
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 07/15/2021 :  5:49:54 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
We added wks.UPC (user parameter count) for 2022, so it can be

loop(i,1,wks.upc) {wks.userparam$(i)$=;};


CP
Go to Top of Page

AKazak

Russia
1205 Posts

Posted - 07/21/2021 :  05:53:48 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by cpyang

We added wks.UPC (user parameter count) for 2022, so it can be

loop(i,1,wks.upc) {wks.userparam$(i)$=;};


CP




Great idea!
Looking forward to testing this.

---
Andrey
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