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
 LabTalk Forum
 Origin 7.5 vs Origin 8
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

verrallr@a

Canada
44 Posts

Posted - 03/16/2009 :  10:37:34 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin):Origin 8 SR4.
Operating System:Windows XP

We have used this code with Origin 7.5, but it doesn't work with Origin 8. Can you help me.

MAIN]
// "an" list area number. Next line deletes all Area Graphs if they exist. If no area graphs exist
// then "exist" defaults to No and loop exits immediately.

loop (i,1,an) {
if (exist(area$(i))!=0) {del area$(i);del area$(i)_A1;del area$(i)_A2;del area$(i)_A3;};
};
del -v an; del -a; del baseline; //INITIALIZE:

// Next lines open data txt file. %H is the current worksheet file. So, this is give then hard name %N.

getfile *.txt;
open -w %A; %N=%H; //OPEN FILE. %H is the active page (the worksheet). %N gives it a fixed name.
win -z; //MAXIMIZE WINDOW
ColNum= wks.maxRows;


getyesno (Do you want the time column to be corrected?) Var (Time column);

If (Var == 1) {

for (ii = 1; ii <= ColNum;ii ++)

{

Col(times)[ii]=5*ii;

};
};

%Q=%(%N,@#); //Records the number of columns in the worksheet.
tempcol=(%Q<9?6:10); //SET DEFAULTS FOR THE WORKSHEET COLUMNS NAMES.
currentcol=tempcol-1;
timecol=1;


// Data file to be default columns for timecol, currentcol and tempcol.
getn -s (time col) timecol (current col) currentcol (temp col) tempcol (SELECT COLUMNS FOR PLOTTING);
secs=24*3600; st=wcol(timecol)[1]; wcol(timecol)-=st;

if (%Q<9) wcol(timecol)*=secs;
if(%Q>9) wcol(currentcol)*=1000.;


//Check for Glitches in the lednma column.

Getyesno (Fix potential glitches in the ledmna column) fixx (Glitches in ledman column?);
If (fixx==1){


For (ii=1;ii<=ColNum;ii++) {
If(%N_iednma[ii]>0.01) {
aa=%N_iednma[ii];
bb=%N_iednma[ii+1];
mm=Abs((aa-bb)/aa);
if (mm>0.2) {
cc=%N_iednma[ii+2];
if (Abs((aa-cc)/aa)<0.2) %N_iednma[ii+1]=aa;
};
};
};
};





work -s currentcol 0 currentcol 0; //SELECTS THE CURRENT COLUMN FOR PLOTTING
run.section(Plot,LineSymbol); //PLOTS THE DATA.
axis -ps x a 3; //PUTS TOP AXIS ON GRAPH
layer -n Y; //ADDS NEW LINKED LAYER WITH RIGHT Y AXIS
layer -i %(%n,tempcol); //PLOTS TEMP CURVE
layer -a; //SCALES TEMP CURVE
layer2.y.from=0; //FORCES TEMP CURVE TO START WITH ZERO
label -yr Temperature (C); //PUTS TEMPERATURE ON Y AXIS
yr.rotate=90; //ROTATES TEMPATURE 90.
layer -i200 %(%N,tempcol); //changes plot to line
set %(%N,tempcol) -c 2; //color for temp plot.
layer2.y2.color=color(red); //makes tics black

//SET SYMBOL SHAPE AND FILL AND GET AXES SET PROPERLY

page.active=1; //SETS LAYER 1 AS ACTIVE
set %(%N,currentcol) -k 2; //SETS CURRENT COL TO BE CIRCLES
set %(%N,currentcol) -kf 1; //SETS INTERIOR TO BE OPEN (HELP SEEMS TO BE ONE DIGIT WRONG)
set %(%N,currentcol) -z 4; //SET SIZE TO BE 4 UNITS.
layer1.x.from=0; //PUTS X AXIS TO START FROM ZERO
c=-6;
label -j 1 -p 50 c -s %N; //PUTS file NAME AT TOP CENTRE. (C=-6 INDICATES ABOUT UPPER Y AXIS)
label -xb Time (sec); //BOTTOM X LABEL
label -yl Titration Current (\g(m)A); //LEFT Y LABEL
label -r legend; //DELETE THE LEGEND LABEL.
win -r graph1 %N_Graph; //CHANGE THE NAME OF THE GRAPH FILE TO //O041228_GRAPH OR EQUIVALENT.

//LOOP TO CHOOSE SCALE

page.active=1; //MAKES SURE LAYER 1 IS ACTIVE
GETYESNO (Re-Scale AXES?) yes (AXES); //ASK READER IF HE WANTS TO RESCALE AXES
//K AND KK ARE DUMMIES. WE JUST QUESTION IF YES=1 OR YES=0.
for (k=1;yes!=0;kk=1) {
GETN (X1=) X1 (X2=) X2 (Y1=) Y1 (Y2=) Y2 (AXES SCALE);
GETYESNO (AGAIN?) yes (AXES);
};

//CHECK FOR UNEXPECTED ZEROS IN TEMP DATASET

//FAIRLY SIMILAR TO "CHOOSE SCALE" ITEM.
//getyesno (Fix temperature graph?) tfix (IRREGULAR ZEROS);
//if (tfix==1) {
// startfix=xindex(x1,%(%N,tempcol)); endfix=xindex1(x2,%(%N,tempcol));
// for (i=startfix;i<=endfix;i++1) {if (%(%N,tempcol,i)<10) {mark -m //%(%N,tempcol) -b i -t 1}}
//};
label -p (-10) 115 -s -n Datenam "Graph created $(@D,D20) h";
Datenam.fsize=16; //FORMAT SIZE=16 FOR DATENAM
page.connect=1; //CONNECT MISSING IN LINE DATA PLOTS.
//type -b DONE!; //INPUTS TO READER "DONE"

[BASELINE]

//GETPTS AT BOTTOM CHOOSES TWO DATA POINTS FOR BASELINE. THE REST OF THE FILE
//STARTING WITH "def EndToolBox" IS A MACRO THAT BEGINS RIGHT AFTER GETPTS.
//THIS IS NEEDED BECAUSE GETPTS DOESN'T WAIT FOR THE REST OF THE PROGRAM.
//BUT THE MACRO def EndToolBox BEGINS ONLY AFTER GETPTS IS DONE LOOKING FOR
//POINTS. ESSENTIALLY THIS IS A TRICK TO FORCE REST OF PROGRAM TO BEGIN
//ONLY AFTER GETPTS IS DONE.
//def EndToolBox MUST START BEFORE THE GETPTS ITEM. IF NOT GETPTS HAS A DEFAULT.

def EndToolBox
{
layer -s 1; //SETS THE ACTIVE LAYER TO 1
mkx1=_xpos[1];mkx2=_xpos[2]; //GETS THE 2 XPOSITIONS INTO VBLES
//NOW PUT THE CURRENTCOL VALUES INTO TWO OTHER VBLES.
mk1=xindex(mkx1,%(%N,currentcol)); mk2=xindex1(mkx2,%(%N,currentcol));
create base -t 12; //CREATES A TEMPORARY DATASET 12 PTS
mk1s=mk1-3; //TWO MORE VBLES SET TO EQUAL -3.
mk2s=mk2-3; //THIS IS SO WE CAN PERFORM AVERAGE VALUES OVER 6 PTS.
copy -b mk1s %(%N,currentcol) base -b 1 -e 6; //CREATES 6 POINTS FOR AVERAGE - INSTEAD OF ONE ONLY.
copy -b mk2s %(%N,currentcol) base -b 7 -e 12;
lff=sum(base); //CREATES A DATA SET CONTAINING SUMS TO N
lffy1=lff[6]/6;lffy2=(lff[12]-lff[6])/6; //GETS Y AVERAGES
//CREATES DATASET AND PUT IN X,Ys
create baseline -c 2; //CREATES BASELINE OF TWO POINTS
baseline_A={mkx1,mkx2}; //baseline_A IS THE TWO X POINTS OF GETPTS.
baseline={lffy1,lffy2}; //baseline Y IS THE TWO AVERAGE Y VALUES.
slop=(baseline[2]-baseline[1])/(baseline_A[2]-baseline_A[1]); //FORMULATE THE SLOPE OF CURVE.
window -a %N_Graph; //SETS %N_Graph TO BE THE WINDOW SELECTED.
layer -s 1; //SETS THE ACTIVE LAYER TO 1.
layer.include(baseline,200); //CREATES THE CURVE baseline ONTO THE GRAPH. LINE GRAPH.
del lff; del -v lffy1; del -v lffy2;
//del base;
type -b DONE!\r\nslope is $(slop) microamp/sec;
};
getpts -a (Choose two points for baseline determination. Dble-click or Click/Enter) 2 ;


[AREA]

//THIS SECTION USES GETPTS IN SIMILAR WAY TO THE PREVIOUS SECTION.

if (exist(an)==0) {an=1;} else {an=an+1;}; //BEGINS an PARAMETER. SETS TO 1 IF FIRST CURVE; an+1 OTHERWISE.
LN=0;
def QuitToolBox {an=an-1;}; //IF PROBLEM WITH GETPTS, SET an=an-1
def EndToolBox
{
def QuitToolBox {}; // IS THIS NECESSARY??
page.zoomWhole=1; //ZOOMS TO FULL PAGE SO THAT GRAPHS ARE RIGHT SIZE
mkx1=_xpos[1];mkx2=_xpos[2];
mk1=xindex(mkx1,%(%N,currentcol));mk2=xindex(mkx2,%(%N,currentcol));
end=mk2-mk1;
create area$(an) -w end A1 A2 A3; // Create a worksheet with #rows=end, cols named A1...
window -a area$(an); // activates the new worksheet
work -t 1 4;work -t 2 1;work -t 1 4; //SETS COLUMN TYPES
copy -b mk1 %(%N,timecol) area$(an)_A1 -b 1 -e end;
copy -b mk1 %(%N,currentcol) area$(an)_A2 -b 1 -e end;
loop (i,1,end) {col(3)[i]=baseline(col(1)[i])};
work -s 2 0 3 0;
run.section(plot,fillarea); //RUN THE fillarea OF THE plot SECTION.
ffp=an*3; ffc=an+18;
set area$(an)_A2 -pfp ffp; //SET THE FILLPATTERN TO ffp
set area$(an)_A2 -cf ffc; //SET THE COLOR TO ffc
label -r xb; label -r yl; //GET RID OF GRAPHS, I THINK.
layer.x.showAxes=0;layer.x.showLabels=0; //GET RID OF AXES LABELS (TO THEM MERGE GRAPHS)
layer.y.showAxes=0;layer.y.showLabels=0;
win -m; //MERGES ALL GRAPHS
ln=2+an;
layer$(ln).y.from=layer1.y.from;layer$(ln).y.to=layer1.y.to; //SCALE AXES TO BE SAME
layer$(ln).x.from=layer1.x.from;layer$(ln).x.to=layer1.x.to;
layer$(ln).link=1;layer$(ln).x.link=1;layer$(ln).y.link=1; //AXES LINK
layer.unit=7; //SETS DIVISIONAL (i.e. UNIT) OF LAYER TO % OF LINKED LAYER

//READ IN MASS OF SAMPLE FOR AREA INTEGRATION AND CALC. OF STOICHOMETRY CHANGE
getn -s (Mass in mg = ) mass (Sample Mass);
integrate -r area$(an)_A3 area$(an)_A2;
wtper100mg=8*integ.area/(964950*mass);
deltasto=wtper100mg*2.7/16; //with mass in mg and current in microamps
end2=end/2; xloc=area$(an)_A1[end2]; yloc=area$(an)_A2[end2];
label -a xloc yloc -j 0 -s -sa -n OU$(an) "Area of peak is equivalent\r\nto \g(D)(O/U) = $(deltasto)Wt.(mg) of Ox per 100 mg\r\nsample = $(wtper100mg)"; OU$(an).fSize=18;
// Next 2 lines would put in a hidden label of wt. per 100 mg.
//label -a xloc yloc -j 0 -s -n wt$(an) wt(mg)/100mg of sample is $(wtper100mg);
//wt$(an).show=0;
window -c area$(an);win -c %N_GRAPH;win -c graph1; win -r graph2 %N_GRAPH;
run.section(STANDARD,Refresh);
type -b DONE!;
};
getpts -a 2 (Pick start and end pts for integration);


There is more to this code, but I think this should give the problem.

[MAIN] work fine, but the problems ari in [BASELINE]

In particular, in the section [Baseline] the statement
getpts -a (Choose two points for baseline determination. Dble-click or Click/Enter) 2 ;

gives an error.

And, also in [BASELINE], there should be a baseline curve in the graph.

I will show the graph the graph we want to work on:

Time U(up)/mV I(up)/A U(down)/mV I(down)/A T(oven)
00:06:45.3 1200.66 0.00 180.11 26884.02 50.00
00:07:06.7 1200.85 0.00 179.89 26879.98 50.00
00:07:28.0 1200.99 0.00 180.08 26881.65 50.00
00:07:49.3 1200.76 0.00 179.97 26868.78 50.00
00:08:10.7 1201.06 0.00 180.31 26872.33 50.00
00:08:32.0 1201.15 0.00 179.67 26877.28 50.00
00:08:53.3 1201.30 0.00 180.19 26896.83 50.00
00:09:14.7 1201.56 0.00 180.03 26864.81 50.00
00:09:36.0 1201.85 0.00 179.96 26872.43 50.00
00:09:57.3 1201.92 0.00 180.11 26862.37 50.00
00:10:18.7 1201.76 0.00 180.14 26877.35 50.00
00:10:40.0 1202.02 0.00 180.04 26863.72 50.00
00:11:01.3 1202.14 0.00 178.94 26824.90 50.00
00:11:22.7 1202.36 0.00 179.87 26873.82 50.00
00:11:44.0 1202.12 0.00 180.92 26838.56 50.00
00:12:05.3 1202.49 0.00 180.24 26831.97 50.00
00:12:26.7 1202.66 0.00 179.95 26849.33 50.00
00:12:48.0 1202.64 0.00 179.93 26871.39 50.00
00:13:09.3 1202.57 0.00 179.46 26863.08 50.00
00:13:30.7 1202.51 0.00 179.97 26853.95 50.00
00:13:52.0 1202.73 0.00 180.07 26847.55 50.00
00:14:13.3 1203.06 0.00 180.06 26859.93 50.00
00:14:34.7 1203.04 0.00 180.44 26867.12 50.00
00:14:56.0 1203.24 0.00 179.89 26871.32 50.00
00:15:17.3 1203.01 0.00 178.29 26838.61 50.00
00:15:38.7 1203.60 0.00 179.87 26875.09 50.00
00:16:00.0 1203.27 0.00 180.04 26858.77 50.00
00:16:21.3 1203.56 0.00 179.89 26868.37 50.00
00:16:42.7 1203.61 0.00 179.99 26873.39 50.00
00:17:04.0 1203.62 0.00 180.24 26855.01 50.00
00:17:25.3 1203.57 0.00 180.15 26867.22 50.00
00:17:46.7 1203.96 0.00 179.75 26865.91 50.00
00:18:08.0 1204.31 0.00 179.80 26850.04 50.00
00:18:29.3 1204.36 0.00 179.89 26861.78 50.00
00:18:50.7 1204.31 0.00 179.99 26870.33 50.00
00:19:12.0 1204.39 0.00 179.86 26867.59 50.00
00:19:33.3 1204.38 0.00 179.17 26859.71 50.00
00:19:54.7 1204.38 0.00 179.88 26871.99 50.00
00:20:16.0 1204.41 0.00 180.07 26864.47 50.00
00:20:37.3 1204.63 0.00 180.01 26845.09 50.00
00:20:58.7 1204.71 0.00 180.22 26854.29 50.00
00:21:20.0 1204.65 0.00 179.93 26870.27 50.00
00:21:41.3 1204.98 0.00 179.95 26868.91 50.00
00:22:02.7 1204.82 0.00 179.72 26872.20 50.00
00:22:24.0 1204.64 0.00 179.88 26860.80 50.00
00:22:45.3 1204.65 0.00 179.90 26855.40 50.00
00:23:06.7 1204.44 0.00 179.99 26872.51 50.00
00:23:28.0 1204.56 0.00 180.01 26858.69 50.00
00:23:49.3 1204.26 0.00 180.03 26866.21 50.00
00:24:10.7 1204.52 0.00 179.89 26868.64 50.00
00:24:32.0 1204.41 0.00 179.84 26866.18 50.00
00:24:53.3 1204.41 0.00 179.89 26831.96 50.00
00:25:14.7 1204.58 0.00 179.90 26871.24 50.00
00:25:36.0 1204.69 0.00 179.90 26875.63 50.00
00:25:57.3 1204.44 0.00 180.11 26838.34 50.00
00:26:18.7 1204.39 0.00 180.01 26867.78 50.00
00:26:40.0 1204.56 0.00 179.85 26864.44 50.00
00:27:01.3 1204.70 0.00 179.92 26871.23 50.00
00:27:22.7 1204.49 0.00 179.82 26862.79 50.00
00:27:44.0 1204.73 0.00 179.89 26845.53 50.00
00:28:05.3 1204.50 0.00 179.90 26875.64 50.00
00:28:26.7 1204.43 0.00 179.94 26867.80 50.00
00:28:48.0 1204.98 0.00 179.88 26857.03 50.00
00:29:09.3 1204.80 0.00 179.96 26868.07 50.00
00:29:30.7 1204.40 0.00 180.02 26865.59 50.00
00:29:52.0 1204.56 0.00 180.44 26878.06 50.00
00:30:13.3 1204.72 0.00 179.97 26855.88 50.00

I hope I have put it enough to show the problems we are having.

Richard Verrall

Deanna

China
Posts

Posted - 03/16/2009 :  10:07:29 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The last line in your [baseline] section is:

getpts -a (Choose two points for baseline determination. Dble-click or Click/Enter) 2 ;


This is problematic. Looking at the help file of the getpts command, you can see the number of points to get should be specified right after "-a" and before the prompted message. Please try to change it as the follows to see if the problem can be fixed:

getpts -a 2 (Choose two points for baseline determination. Dble-click or Click/Enter);


Deanna
OriginLab Technical Services
Go to Top of Page

mourisj

Canada
1 Posts

Posted - 03/19/2009 :  10:20:19 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you, Deanna for your reply.

However, it didn't work.

May I transfer the program and data to you. If yes, I need your email address.

In case you are reluctant to give your address here, my email address is

Verrallr@aecl.ca

Richard

ps. I take Tues and Weds off each week. That is why I didn't respond sooner.

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