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
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 csetvalue recalculate mode

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
kalakuta24 Posted - 03/31/2016 : 07:06:45 AM
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 !

5   L A T E S T    R E P L I E S    (Newest First)
Hideo Fujii Posted - 04/01/2016 : 12:03:35 PM
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
kalakuta24 Posted - 04/01/2016 : 04:22:37 AM
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.


Hideo Fujii Posted - 03/31/2016 : 2:00:25 PM
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
kalakuta24 Posted - 03/31/2016 : 12:26:43 PM
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,


Hideo Fujii Posted - 03/31/2016 : 11:07:34 AM
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

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000