| T O P I C R E V I E W |
| evanm |
Posted - 08/18/2004 : 10:15:01 AM Hello, I am having a problem with LT_execute and/or %() substitution. I have some graph names and I want to loop through them and get the names of the datasets plotted in the graph windows. A simple section of code would look as follows:
//find the dataset name from the first graph: string graphName = "somegraphname"; LT_set_str("%R", graphName); LT_execute("%S = %(%R,@D)"); //this sets %S to the dataset name char charTemp[50]; LT_get_str("%S",charTemp,50); string dsYName = charTemp; //now have the first dataset name. The code works fine up to here but doing the same thing again does not work...
//now find the dataset name from the second graph: graphName = "someothergraphname"; LT_set_str("%R", graphName); LT_execute("%S = %(%R,@D)"); LT_get_str("%S",charTemp,50); dsYName = charTemp;
The first section of code works perfectly, however doing the exact thing again fails to work for some reason. Does anyone know what is wrong here?
Thank you, Evan. |
| 8 L A T E S T R E P L I E S (Newest First) |
| cpyang |
Posted - 08/19/2004 : 12:07:23 PM You can not compile in one version of Origin and hope that it (OCB file?) will run on a different version. There are those OP files that you can compile in OriginPro version and then run on regular version of Origin. When you compile some C files, Origin will create OCB files and when you get to run these OCBs, Origin will check that it was produced by which version and if dose not match, Origin will attampt to find the source and compiles it again. Basically, some features were not present in 7SR0, so you will need to patch all the machines to 7SR4.
CP
|
| evanm |
Posted - 08/19/2004 : 11:56:19 AM easwar,
if I install SR4 and then compile my function can I then run it on other machines that do not have the SR package installed? (ie O7SR0)
|
| easwar |
Posted - 08/19/2004 : 11:46:43 AM quote:
That would work for me except for that I forgot to mention that I am using version 7SR0, and I am unable to upgrade right now.
Hi Evan,
The OC code that I posted works in version 7 SR4. So if you want to use the OC code, just get the free SR4 update for your version 7 installation from our website.
Easwar OriginLab
|
| Mike Buess |
Posted - 08/19/2004 : 11:33:43 AM Hi Evan,
You have row and col indices mixed up in wks.GetCell(). Should be wks.GetCell(0,i,graphName).
...My mistake. I thought your graph names were all in the first row. Your code works perfectly in my Origin 7.0 SR4.
Another reason to update to SR4?
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 08/19/2004 3:46:58 PM |
| evanm |
Posted - 08/19/2004 : 10:37:27 AM Thanks Mike,
your method also works, but ONLY for the first graph. When I loop through that section of code using Origin C for some reason only the first iteration of that code segment works.
Suppose wks1 has 3 graph names in its first column. I want to programatically find the names of the first dataset plotted in each graphs active layer. Using what you suggested, this is my code:
void myfunc() { Worksheet wks("wks1"); char temp[50]; string graphName; for(int i = 0; i < 3; i++) { wks.GetCell(i,0,graphName); LT_set_str("%R", graphName); LT_execute("win -o %R {%S=%(1, @D)}"); LT_get_str("%S", temp, 50); string dsYName = temp; printf("dsname %s\n", dsYName); } }
When I run this I get output like: dsname dsYName1 //this one is correct dsname ### //the other 2 are garbage; I actually get ### out dsname ###
Any more suggestions would be greatly appreciated. Thanks, Evan.
Edited by - evanm on 08/19/2004 10:38:51 AM |
| Mike Buess |
Posted - 08/19/2004 : 08:47:41 AM Hi Evan,
I think the problem lies in your Labtalk method for getting the dataset name. When I use it from the script window I get the following results (Graph1 exists and has a dataplot)...
%R=Graph1; %S=%(%R, @D); %S=; % (%R, @D)
Try something like this instead...
%R=Graph1; win -o %R {%S=%(1, @D)}; %S=; Data1_B
If your plot has more than one layer that will get the first dataset in the active layer.
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 08/19/2004 08:56:13 AM |
| evanm |
Posted - 08/19/2004 : 05:51:18 AM Thanks for the reply. That would work for me except for that I forgot to mention that I am using version 7SR0, and I am unable to upgrade right now. Does anyone know of another way to get the dataset names? Or else why the labtalk code is failing?
Thanks, Evan.
|
| easwar |
Posted - 08/18/2004 : 11:16:28 AM Hi Evan,
You don't need to use LabTalk to get the data plot names. You can use OC code similar to what is pasted below. This works in v7SR4 - v7.5SR4
Easwar OriginLab
void get_dataplot_names() { // Loop over all graphs in project foreach( GraphPage gpg in Project.GraphPages ) { printf( "Graph Page: %s\n", gpg.GetName() ); // Loop over all layers foreach( GraphLayer gl in gpg.Layers ) { printf( " Layer %d:\n", gl.GetIndex() + 1 ); // Loop over all data plots foreach( DataPlot dpl in gl.DataPlots ) { printf( " %s\n", dpl.GetDatasetName() ); } } printf("\n"); } }
|
|
|