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
 Formatting Issue - Value should be numeric
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

alexisb2000

USA
7 Posts

Posted - 12/22/2008 :  5:43:28 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and SR (Select Help-->About Origin):
Operating System: Windows XP

Hi. I am new to OriginPro 8 and LabTalk. I wrote a basic program to load data from an Access 2003 database into an Origin Workbook and then copy the data into different workbooks within the same Origin project. Previously, the users were loading data manually from text files into the workbooks A1, A2, etc. There already was an Interpolate button in the project and it works fine when users manually load the data files. My load and copy program is meant to replace the manual load only.

My load program appears to load the data properly from Access into the correct workbooks, however, the Interpolate button no longer works properly. After my load program was added, only the string values work from the Interpolate button but none of the number values. Since the values look correct, I assume my program is copying the values as text rather than numbers.

I have pasted my code below. I had a hard time understanding substitution and hope that the problem with my code is an easy one. There is only one string value being copied in the code and it is always the first value being copied. I could therefore modify my code below to handle that value and then program the other columns.

Thanks for any help you can offer. I am really stuck!
Alexis
//data_copy.ogs Origin LabTalk Program

type -b "program start";

//load data from Access based on script examples under LabTalk Help
//string strdb$ = system.path.program$ + "Samples\Import and Export\stars.mdb";
string strdb$ = "C:\Documents and Settings\processtest\Desktop\Process_feLabData9.mdb";
string strConn$="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=%(strdb$); User ID=admin; Password=;";
string strSQL$="Select * From DBJVLTemp order by RecordNumber"; //need order by to keep records in sequence - couldn't use autonumber
dbEdit change conn:=strConn$ sql:=strSQL$;
dbImport;
dbEdit remove; // if you don't want to save the db obj

//copy data
//type -b %G; //displays project name

//don't use %c. %d or %h - they are used by origin and mess up if I use them
%a = JVLData!cell(1,3)$; //this value is how many sample id's used in this load so know when to stop going across (columns) file count 1 - 12 max
%b = JVLData!cell(1,4)$; //file1
%p = JVLData!cell(1,5)$; //file2
%e = JVLData!cell(1,6)$; //file3
%f = JVLData!cell(1,7)$; //file4
%g = JVLData!cell(1,8)$; //file5
%i = JVLData!cell(1,9)$; //file6
%j = JVLData!cell(1,10)$; //file7
%k = JVLData!cell(1,11)$; //file8
%l = JVLData!cell(1,12)$; //file9
%m = JVLData!cell(1,13)$; //file10
%n = JVLData!cell(1,14)$; //file11
%o = JVLData!cell(1,15)$; //file12

type -b "filecount=$(%a),rowcnt1=$(%b),rowcnt2=$(%p),rowcnt3=$(%e),rowcnt4=$(%f),rowcnt5=$(%g),rowcnt6=$(%i),rowcnt7=$(%j),rowcnt8=$(%k),rowcnt9=$(%l),rowcnt10=$(%m),rowcnt11=$(%n),rowcnt12=$(%o)";

//Process Files
int w=1; //w is factor for file so can get to correct col in worksheet 1 file has factor 1, 2nd file has factor 2, etc.
int x=1;
int y=16; //start col in entire sheet. First col range is from 4 to 14, second is 16 to 26 - same pattern for all
int z=w*y; //z is col to start for this file. Var w will be incremented to number of files to process (which is m from above)
int yval1=16;
int yval2=27;
int ab = %b; //start with first data set. Value ab stores number of rows for that data set.
int m = %a;
type -b "factor=$(w),startrow=$(x),startcol=$(y),filestartcol =$(z),numrowsFirstFile=$(ab)";

for (;w<=m;)
{
int s=0; //row in origin sheet
int t=0; //col in origin sheet
type -b "processing w=$(w),ab=$(ab),a=$(a)";

for (x=1;x<=ab;x++) //rows go down to value in a ie. 73 but since start at row 2 in sheet, needs to be +1
{
// type -b "x=$(x)";
s = s + 1;
int t = 0; //re-initialize
for (y=yval1;y<=yval2;y++)
{
t = t + 1;
if (w==1) {A1!cell(s,t)$ = JVLData!cell(x,y)$; }
if (w==2) {A2!cell(s,t)$ = JVLData!cell(x,y)$; }
if (w==3) {A3!cell(s,t)$ = JVLData!cell(x,y)$; }
if (w==4) {A4!cell(s,t)$ = JVLData!cell(x,y)$; }
if (w==5) {A5!cell(s,t)$ = JVLData!cell(x,y)$; }
if (w==6) {A6!cell(s,t)$ = JVLData!cell(x,y)$; }
if (w==7) {B1!cell(s,t)$ = JVLData!cell(x,y)$; }
if (w==8) {B2!cell(s,t)$ = JVLData!cell(x,y)$; }
if (w==9) {B3!cell(s,t)$ = JVLData!cell(x,y)$; }
if (w==10) {B4!cell(s,t)$ = JVLData!cell(x,y)$; }
if (w==11) {B5!cell(s,t)$ = JVLData!cell(x,y)$; }
if (w==12) {B6!cell(s,t)$ = JVLData!cell(x,y)$; }
}
}

w = w + 1;
yval1=yval1 + 12;
yval2=yval2 + 12;
//get number of rows for next data set
if (w==2) {ab = %p;}
if (w==3) {ab = %e;}
if (w==4) {ab = %f;}
if (w==5) {ab = %g;}
if (w==6) {ab = %i;}
if (w==7) {ab = %j;}
if (w==8) {ab = %k;}
if (w==9) {ab = %l;}
if (w==10) {ab = %m;}
if (w==11) {ab = %m;}
if (w==12) {ab = %o;}
}

type -b "program end";

cpyang

USA
1406 Posts

Posted - 12/22/2008 :  10:39:38 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
What is the reason for


A1!cell(s,t)$ = JVLData!cell(x,y)$;


Why not


A1!cell(s,t) = JVLData!cell(x,y);



CP

Go to Top of Page

alexisb2000

USA
7 Posts

Posted - 12/23/2008 :  4:12:45 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you, cpyang, for your help. You were right. This resolved my formatting issue and allowed me to move on to fine tune my program.

Thanks again.
Regards,
Alexis
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