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
 Put variable numeric value to X-Function argument
 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 - 02/19/2021 :  10:43:52 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
OriginPro 2021b (64-bit) Beta 6 9.8.5.111
Windows 7 Pro x64 SP1

Greetings!

A simple, but important question: how does one put a variable numeric value to X-Function argument?

For example, this piece of code doesn't work:
plot_gboxindexed -r 1 irng:=[%(page.name$)]"%(wks.name$)"!3:%(wks.nCols)


How do I put the value of wks.nCols after the colon?

Thank you.

---
Andrey

cpyang

USA
1406 Posts

Posted - 02/19/2021 :  11:37:15 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
% convert string expression to a string, so you should use $ to convert a numeric expression to a string, so try

plot_gboxindexed -r 1 irng:=[%(page.name$)]"%(wks.name$)"!3:$(wks.nCols)


better yet, use 0 as end


plot_gboxindexed -r 1 irng:=[%(page.name$)]"%(wks.name$)"!3:0


0 as end was not as fully implemented before 2021b, so might need to use <end>

You can read more about % and $ here

https://www.originlab.com/doc/LabTalk/guide/Substitution-Notation

CP

Go to Top of Page

AKazak

Russia
1205 Posts

Posted - 02/19/2021 :  3:14:24 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by cpyang

% convert string expression to a string, so you should use $ to convert a numeric expression to a string, so try

plot_gboxindexed -r 1 irng:=[%(page.name$)]"%(wks.name$)"!3:$(wks.nCols)


better yet, use 0 as end


plot_gboxindexed -r 1 irng:=[%(page.name$)]"%(wks.name$)"!3:0


0 as end was not as fully implemented before 2021b, so might need to use <end>

You can read more about % and $ here

https://www.originlab.com/doc/LabTalk/guide/Substitution-Notation

CP



I will study more about % and $ @ https://www.originlab.com/doc/LabTalk/guide/Substitution-Notation.
Thank you for the suggestion.

As for 0 and <end>: Do both act in the same way? Can I use any?

---
Andrey
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 02/19/2021 :  6:34:29 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
0 was not generally implemented before, but in 2021b we try to cover all cases to allow 0, like

wcol(0)=col(A)
and in such case <end> cannot be used. <end> was only supported in range notation and in 2021b, 0 will work the same as <end> for range, but 0 can also be used like

layer -d 0
to delete the last sheet.

CP
Go to Top of Page

AKazak

Russia
1205 Posts

Posted - 02/20/2021 :  04:01:57 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by cpyang

0 was not generally implemented before, but in 2021b we try to cover all cases to allow 0, like

wcol(0)=col(A)
and in such case <end> cannot be used. <end> was only supported in range notation and in 2021b, 0 will work the same as <end> for range, but 0 can also be used like

layer -d 0
to delete the last sheet.

CP




Thank you.
Very handy syntax and I will be using it in my code.

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