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
 Origin Forum
 Labtalk: delete last character of longname
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

mariacm

17 Posts

Posted - 02/01/2023 :  4:46:37 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
In labtalk - how to delete the last character of the longname? My script works over many worksheets and my goal is to add a string fragment to the longname of two columns on each worksheet, but the last character (created at import) should be erased before the concatenation occurs.

Origin Ver. OriginPro 2022 (64-bit) SR1
Operating System: windows 10

snowli

USA
1397 Posts

Posted - 02/01/2023 :  5:05:44 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Col(A)[L]$ refers to long name of column A.
https://www.originlab.com/doc/en/LabTalk/ref/Column-Label-Row-Characters
There are many string related labtalk functions
originlab.com/doc/en/LabTalk/ref/String-obj
So write col(A)[L]$=Left(col(A)[L]$,len(col(A)[L]$)-1)$ to keep left length-1 chars.

To loop through all columns
https://www.originlab.com/doc/LabTalk/guide/Looping-Over-objs#Looping_over_Columns_and_Rows

for(int ii = 0; ii < wks.ncols; ii ++)
{
wcol($(ii))[L]$=Left(wcol($(ii))[L]$,len(wcol($(ii))[L]$)-1)$;
}

Thanks, Snow


Go to Top of Page

mariacm

17 Posts

Posted - 02/01/2023 :  6:21:30 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Perfect! Thanks.
Go to Top of Page

mariacm

17 Posts

Posted - 02/02/2023 :  11:19:35 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
---a somewhat related question:
how to make a longname be the worksheet name?


quote:
Originally posted by mariacm

Perfect! Thanks.

Go to Top of Page

snowli

USA
1397 Posts

Posted - 02/02/2023 :  11:29:53 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
wks.name$= col(A)[L]$

https://www.originlab.com/doc/LabTalk/guide/Worksheet-Basic-Operation

Some tips
In google search. Start the google search with originlab labtalk, e.g. originlab labtalk sheet name, usually u can find labtalk related info.

if you type wks.= // it will show all properties for wks.


Thanks, Snow

Go to Top of Page

mariacm

17 Posts

Posted - 02/02/2023 :  11:46:27 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks,
I tried that before, and the sheets ended up named Col(A)[L] instead of the actual value of the longname (maybe I didn't include de $ mark?). I tried it again and it worked just fine.
(I really try with the help, but it is not straightforward.)



quote:
Originally posted by snowli

wks.name$= col(A)[L]$

https://www.originlab.com/doc/LabTalk/guide/Worksheet-Basic-Operation

Some tips
In google search. Start the google search with originlab labtalk, e.g. originlab labtalk sheet name, usually u can find labtalk related info.

if you type wks.= // it will show all properties for wks.


Thanks, Snow



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