| Author |
Topic  |
|
|
Asmetana1
USA
9 Posts |
Posted - 05/15/2020 : 1:39:44 PM
|
Origin Ver. and Service Release (Select Help-->About Origin): OriginPro 2020 (64-bit) SR1 9.7.0.188 Operating System: Windows 10 I have a graph which plots data from an SQL database. The graph has a text object which includes a session variable that provides information about the data the user selected. The variable is set by a script which should run whenever the user selects a new set of data from the SQL database. If I run the script in the script window and then examine the text object properties, the preview shows the correct information. I added the script in the programming tab of the text object, but it never runs. I suspect this is because I haven't selected the correct combination of options (Attach to, Event, etc) on the programming tab. 1) Is the text object the correct place for the script? 2) If it is, what combination of options do I need to choose so the script will run whenever the user pulls new data from SQL? Thanks, Andy |
|
|
cpyang
USA
1406 Posts |
Posted - 05/15/2020 : 5:02:45 PM
|
Script in text object is not reliable. Origin has the general Recalculate framework and that is what you should use.
Add a column to the worksheet with the SQL connection, and use Before Formula script in that column to run your code.
Usually the column calculation will result in values that you want to show in a graph, and the triggering is done by setting the input of that column formula. If the calculation can be expressed by a formula, then the input is automatically analyzed by Origin, but you can explicitly add input in the Before Formula script like
double aa=col(A)[1];
so even though you don't use that in your code, Origin will still recognized col(A) is an input so when new data is imported, the formula will be triggered.
CP
|
 |
|
|
Asmetana1
USA
9 Posts |
Posted - 05/19/2020 : 09:07:08 AM
|
Thanks for the pointer. I was able to use "Set Column Values" to create the value for the text label. I was also able use the script tab in worksheet properties. I appreciate the help. |
 |
|
| |
Topic  |
|
|
|