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 error

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
Francesco84 Posted - 06/26/2019 : 03:52:40 AM
Origin Ver. 2019b
Operating System: Windows 10

Good morning,
I would like to ask a question.

I have a workbook with 4 columns and 3 rows;

For each row, I have to sum the elements and write the sum in a fifth column (Col E).

I use this code:

csetvalue col:=col(E)
formula:="Sum"
script:="
dataset Sum;
for (int j=1; j<=3; j++) //Rows
{
for (int i=1; i<=4; i++) // Columns
Sum[j]+=Col($(i))[$(j)];
}
"
recalculate:=1;

I get the following errors:
Invalid Column Name: COL(--)

The strange thing is that if I go to "Set Column Value" menu and insert the script, I don't get errors

Where am I doing wrong?

Thank you
Francesco
4   L A T E S T    R E P L I E S    (Newest First)
Francesco84 Posted - 07/01/2019 : 08:33:52 AM
Thank you Chris,
I tried your suggestion; it was useful for me to better understand the difference between Project and Session variables.

Francesco
Chris D Posted - 06/27/2019 : 09:55:11 AM
It depends on your needs.

Run the command
list;
to open the LabTalk Variables and Functions dialog.

Then run your code and refresh the list in the dialog (there is a refresh button). You will observe your variable.

Now, trigger the recalculation on the new operation by changing either an X or Y value.

Back in the LabTalk Variables and Functions dialog, refresh the list and observe that the value of the variable has changed.

If you want the variable to persist with the project specify it as a Project variable. If you want it to persist only for the currently running Origin session, use a Session variable.

I hope this helps.

Thanks,
Chris Drozdowski
Originlab Technical Support
Francesco84 Posted - 06/27/2019 : 09:32:58 AM
Thanks Yuki,
it works perfectly.

Another small question, please.
I have to calculate an integral and store the area value for subsequent operations. I use the integ1 function.
This is the code:

double area_integ;
integ1 iy:=(col(B),col(C)) type:=math area:=area_integ -r 1;

I would like to know if the variable "area_integ" must be of type Project or Session (as I wrote in the code), so that if the function to be integrated changes, its value also changes.

Thank you
Francesco
yuki_wu Posted - 06/26/2019 : 06:18:16 AM
Hi Francesco,

When we execute the scripts in Script Window or Command Window, variable with $ will be resolved to its actual value directly before it is passed into Before Script options.
https://www.originlab.com/doc/Quick-Help/Avoid-Substituted

To fix this issue, we could change the code like:

%A = $;
csetvalue col:=col(E)
formula:="Sum"
script:="
dataset Sum;
for (int j=1; j<=3; j++) //Rows
{
for (int i=1; i<=4; i++) // Columns
Sum[j]+=Col(%A (i))[ %A (j)];
}
"
recalculate:=1;


In fact, we could easily use “A+B+C+D” to sum the values for each row:
csetvalue col:=col(E) formula:="A+B+C+D" recalculate:=1;


Regards,
Yuki
OriginLab

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