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
 Forum for Origin C
 How to check existence and use objects?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

klunz

Germany
Posts

Posted - 09/18/2007 :  08:22:10 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.5G SR6
Operating System: XP

Hello again,

Ive got the following Problem:
I have a skript that is applied to only one Set of Data at a Time. In the process, the curve "kurveDaten" is drawn to the GraphLayer "graphSchicht" on the GraphPage "graphDaten".

What I would like to do now is the following:
If the skript is run again and applied to another Set of Data, and the GraphPage from the previous Dataset is still present (hence "exists") it should draw the new Curve in the same GraphPage, on the same Layer.

So it should go something like:
Start Skript -> ... ->Check if GraphPage "graphDaten" is already present -> if so, draw to same Graphpage, if not create GraphPage and draw onthere.

So far my code looks like this, but if i run it with the GraphPage already present it simply creates a new one called "graphDaten1".

GraphPage graphDaten;
bool ExistenzG = graphDaten.Create("Daten"); // Graph erzeugen
graphDaten.Rename("Graph Datensatz");
Curve kurveDaten(tabelleDaten,0,1); // Kurve definieren
GraphLayer graphSchicht = graphDaten.Layers(); // Schicht im Graph erzeugen
int Plot = graphSchicht.AddPlot(kurveDaten, IDM_PLOT_LINE); // Kurve auf Schicht zeichnen


My Problem is, that I just cant find anything really useful to check if something that wasnt created within the skript and is therefore unknown to the skript already exists and then give this already existing "thing" a useable name.

I hope my description is understandable, already thanks a lot for your help.

Greetings
Tobi

Mike Buess

USA
3037 Posts

Posted - 09/18/2007 :  09:05:58 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Tobi,

This will work...
	GraphPage graphDaten("GraphDatensatz");
if( !graphDaten ) // if graph page does not exist
{
graphDaten.Create("Daten");
graphDaten.Rename("GraphDatensatz");
}
GraphLayer graphSchicht = graphDaten.Layers();
Curve kurveDaten(tabelleDaten,0,1);
string kurveName = kurveDaten.GetName(); // name of curve
DataPlot kurvePlot(graphSchicht.DataPlots(kurveName));
if( !kurvePlot ) // if data plot does not exist
graphSchicht.AddPlot(kurveDaten, IDM_PLOT_LINE);
graphSchicht.Rescale();


Mike Buess
Origin WebRing Member
Go to Top of Page

klunz

Germany
Posts

Posted - 09/20/2007 :  09:44:44 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you very much, as always, that did it

Greetings
Tobi
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