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
 Forum for Origin C
 wks declaration of variable worksheet names

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
filippo.canta Posted - 10/14/2005 : 12:18:32 PM
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...
2   L A T E S T    R E P L I E S    (Newest First)
filippo.canta Posted - 11/02/2005 : 06:18:11 AM
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



Mike Buess Posted - 10/17/2005 : 1:30:09 PM
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

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