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
 wks declaration of variable worksheet names
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

filippo.canta

Italy
Posts

Posted - 10/14/2005 :  12:18:32 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version 7.5
Operating System: winXP

Hi to all!
My name is Filippo.
I am a beginner in Origin C.

I have a trouble: I'm using ''Import Wizard'' to import a set of 3 or more *.csv files. Using an origin C script I desire to plot on several graph some columns. I have compliled a working properly code. But now I desire to improve it capability. At the moment of the wks declaration, now I'm using the static names of the worksheets, imported by the wizard as ''Data2, Data3, Data4''. Now I desire to import the data in the worksheets assigning to these the original *.csv file names.
How can I write code that works with wariable worksheets names. Note that this need come from the desire of working with more than one series of *.csv files in more than one folder in the same project file.

Can you help me? I don't known if I was enough clear, I hope yes. Let me known.

Best regards,

Filippo





void prova()
{


Worksheet wks2 = "Data2";
Worksheet wks3 = "Data3";
Worksheet wks4 = "Data4";



// Crea il nuovo grafico e disegna le tre curve di HRR

Curve crvData2(wks2, 20, 8);
Curve crvData3(wks3, 20, 8);
Curve crvData4(wks4, 20, 8);

GraphPage gpg;
gpg.Create( "g.OTP" );
gpg.Rename( "HRR Curves + Average HHR" );
//gpg.Label = "This is Label"; // per aggiungere l'etichetta al grafico, inutile
GraphLayer gly = gpg.Layers( 0 );
gly.AddPlot( crvData2, IDM_PLOT_LINE );
gly.AddPlot( crvData3, IDM_PLOT_LINE );
gly.AddPlot( crvData4, IDM_PLOT_LINE );
gly.Rescale(); // per riscalare il grafico
gly.XAxis.Scale.From.nVal = 0; // per riscalare con l'asse x che parte da 0
gly.YAxis.Scale.From.nVal = 0; // per riscalare con l'asse y che parte da 0
// gly.LT_execute("legend;"); //per aggiungere e rinnovare la legenda, in questo caso inutile
string strThemeFile = GetAppPath() + "themes\\theme1.oth"; // per aggiungere il colore persnalizzato delle curve
gly.GetPage().ApplyFormat(strThemeFile); // anche questa riga per il colore personalizzato



// esegue il comando ''average multiple curves'' che si pu richiamare aprendo
//la finestra di script, crtl+shift+clic sul comando, poi crea il grafico con la
// curva average in un nuovo foglio

LT_execute("run.section(GRANALY,AveCurves)");

Worksheet wks5 = "Average1";

Curve crvAverage1(wks5, 0, 1);

GraphPage gpg5;
gpg5.Create( "g.OTP" );
gpg5.Rename( "Average HRR" );
GraphLayer gly5 = gpg5.Layers( 0 );
gly5.AddPlot( crvAverage1, IDM_PLOT_LINE );
gly5.Rescale();
gly5.XAxis.Scale.From.nVal = 0;
gly5.YAxis.Scale.From.nVal = 0;
gly5.LT_execute("legend;");




PS: Please forgive my italian comments...

Mike Buess

USA
3037 Posts

Posted - 10/17/2005 :  1:30:09 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
It's not clear to me how you intend to use this but one possibility is to supply the wks names as arguments...

void prova(string strWks2, string strWks3, string strWks4)
{
Worksheet wks2(strWks2);
Worksheet wks3(strWks3);
Worksheet wks4(strWks4);

// remaining code
}

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 10/17/2005 1:32:12 PM
Go to Top of Page

filippo.canta

Italy
Posts

Posted - 11/02/2005 :  06:18:11 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Mike! Thank you very much for your help. I'm sorry for my late in replying. I resolved my issue and now I'll post the solution that I have used to. I told you I'm a beginner...but seeking for a solution I have learned a some little things in more.
And so I resolved as follow:



 
void prova2()
{



//In questa sezione si definiscono quali sono i worksheet che devono essere utilizzati


WorksheetPage wp2;
Worksheet wks2;
wp2 = Project.WorksheetPages(1);
wks2 = (Worksheet) wp2.Layers(0);

WorksheetPage wp3;
Worksheet wks3;
wp3 = Project.WorksheetPages(2);
wks3 = (Worksheet) wp3.Layers(0);

WorksheetPage wp4;
Worksheet wks4;
wp4 = Project.WorksheetPages(3);
wks4 = (Worksheet) wp4.Layers(0);

WorksheetPage wp5;
Worksheet wks5;
wp5 = Project.WorksheetPages(4);
wks5 = (Worksheet) wp5.Layers(0);



// Crea il nuovo grafico e disegna le tre curve di HRR

//
Curve crvData2(wks2, 20, 8); //dichiara l'oggetto Curve assegnandogli il nome crv***, prendendo i dati al wks tra le parentesi, nelle colonne 20,x e 8,y
Curve crvData3(wks3, 20, 8);
Curve crvData4(wks4, 20, 8);
Curve crvData5(wks5, 20, 8);

GraphPage gpg; //dichiara un nuovo oggetto GraphPage
gpg.Create( "g.OTP" ); //crea il nuovo oggeto GraphPage utilizzando il tempalte specifico per le curve HRR definito tra le parentesi
gpg.Rename( "HRR Curves + Average HHR" ); //rinomina il nuovo oggetto Grahp page
//gpg.Label = "This is Label"; // per aggiungere l'etichetta al grafico, inutile
GraphLayer gly = gpg.Layers( 0 ); //dichiara il layer nell'oggetto GraphPage su cui si andr a lavorare
gly.AddPlot( crvData2, IDM_PLOT_LINE ); //aggiunge la curva crv*** sul layer indicato
gly.AddPlot( crvData3, IDM_PLOT_LINE );
gly.AddPlot( crvData4, IDM_PLOT_LINE );
gly.Rescale(); // per riscalare il grafico
gly.XAxis.Scale.From.nVal = 0; // per riscalare con l'asse x che parte da 0
gly.YAxis.Scale.From.nVal = 0; // per riscalare con l'asse y che parte da 0
gly.LT_execute("legend;"); //per aggiungere e rinnovare la legenda, in questo caso non essenziale
string strThemeFile = GetAppPath() + "themes\\theme2.oth"; // dichiara una nuova stringa in cui compare il tema grafico da utilizzare
gly.GetPage().ApplyFormat(strThemeFile); //



// esegue il comando ''average multiple curves'' che si pu richiamare aprendo
//la finestra di script, crtl+shift+clic sul comando, poi crea il grafico con la
// curva average in un nuovo foglio

LT_execute("run.section(GRANALY,AveCurves)");

Worksheet wks11 = "Average1";

Curve crvAverage1(wks11, 0, 1);

GraphPage gpg11;
gpg11.Create( "g.OTP" );
gpg11.Rename( "Average HRR" );
GraphLayer gly11 = gpg11.Layers( 0 );
gly11.AddPlot( crvAverage1, IDM_PLOT_LINE );
gly11.Rescale();
gly11.XAxis.Scale.From.nVal = 0;
gly11.YAxis.Scale.From.nVal = 0;
gly11.LT_execute("legend;");
gly11.GetPage().ApplyFormat(strThemeFile);



}
}



It works fine for my need. Thank you a lot anyway but my low skills in programming did't let me to make working your solution.

Kind regards,

Filippo



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