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
 csetvalue recalculate mode
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

kalakuta24

Switzerland
5 Posts

Posted - 03/31/2016 :  07:06:45 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 9
Operating System:w7

Hello,

I'm not an expert, sorry if it is a dumb question...

I want to set a column B automaticaly when I copy/paste manually a column A (or in general way, when column A change).
I use csetvalue in recalculate mode to do that.
Before the execution of the "formula" I need to perform a "script". The script is a user defined function, define in the same labtalk file as main (with the csetvalue function).
When I run the file, col B is implemented correctly with the green recalculate symbol.
However, after then when I change column A, it perform automatically csevalue of column B but an error message appear "script:= function() is unknown"

function dataset test (dataset r )
{
r = r< 0 ? 0 : r;
return r;
}

setvalue col:=[%A]Sheet1!col(3) formula:="r1" script:="dataset r1=test(col(2))" recalculate:=1;[/i]

Have you an idea to solve this issue ?

Thank you !

Hideo Fujii

USA
1582 Posts

Posted - 03/31/2016 :  11:07:34 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi kalakuta24,

I have tried the following script, and it worked even at the recalculation time:
function double test (double r ) {
  rr = r< 0 ? 0 : r;
  return rr;
}
csetvalue col:=[Book1]Sheet1!col(3) formula:="r1" script:="dataset r1=test(col(2))" recalculate:=1;
I used double data type for the internal scalar calculation.

Hope this helps.

--Hideo Fujii
OriginLab

Edited by - Hideo Fujii on 03/31/2016 11:16:40 AM
Go to Top of Page

kalakuta24

Switzerland
5 Posts

Posted - 03/31/2016 :  12:26:43 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello Hideo,

thanks for your help!
Use double instead of dataset do not seem to be the problem because it is still the same problem for me.
Unknown function: TEST(Book1_B) (green symbol became red on the displayed column.
Moreover, I work with 50000 datapoints and use double type take more more long time to calcul
Do you think that it is do to general setting in my origin environement ?

Actually, I need to perform a fit analysis when data in column A have been changed. I use a user labtalk file to perform a nlfit from column A. But in this way I don't find how I can use the recalculate mode. That's why I would like use the recalculate mode of the csetvalue function and call the function fit in the script section.
May have you an other way to do that ?

Thank you so much !
kala,


Go to Top of Page

Hideo Fujii

USA
1582 Posts

Posted - 03/31/2016 :  2:00:25 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi kalakuta24,

> Do you think that it is do to general setting in my origin environement ?

Probably because you run the script from an external script file, and it may be a matter of the scope
(within the session) of the function definition. You can try the following as putting the definition
inside the stored script:
csetvalue col:=[Book1]Sheet1!col(3) formula:="r1" script:="function double test (double r) {rr = r< 0?0:r;return rr;}; dataset r1=test(col(2))" recalculate:=1;

Hope this makes your script work.

--Hideo Fujii
OriginLab

Edited by - Hideo Fujii on 03/31/2016 2:03:31 PM
Go to Top of Page

kalakuta24

Switzerland
5 Posts

Posted - 04/01/2016 :  04:22:37 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Hideo,

Thank you for your reply,
I would like use a function to avoid to have a huge string in the script:="" section of csetvalue, and therefore just call it.

When Origin perform a column automatic recalculation, it, first, execute the script. If I put any origin function (mathematical, ect...). It works well.

My script file (with the function definion) is saved in the folder :

C:\Users\Admin\Documents\OriginLab\91\User Files
How I can force origin to check also this folder during a session ?

Thanks!

Kala.


Go to Top of Page

Hideo Fujii

USA
1582 Posts

Posted - 04/01/2016 :  12:03:35 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Kala,

> I would like use a function to avoid to have a huge string in the script:="" section of csetvalue

You can just execute run.section from the script section in csetvalue, and in the script file, you can
define the function as global. That is for example:
In your script file:
csetvalue col:=[Book1]Sheet1!col(2) formula:="r1" script:="run.section(testsign.ogs,main); dataset r1=test(col(1));" recalculate:=1;

and in the subroutine script file (testsign.ogs in this sample): 
[main]
@global=1;
function double test (double r) {
  rr = r< 0?0:r;
  return rr;
}
@global=0;

This defining part is performed redundantly every time, but practically it may be okay.
Hope this works okay in your application.

--Hideo Fujii
OriginLab
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