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
 LabTalk Forum
 split wksheet in smaller wksheets

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
jmbeaujour Posted - 01/01/2013 : 8:26:40 PM
Origin Ver. and Service Release (Select Help-->About Origin): 8.6
Operating System: WinXP

I am having trouble finding the source of the error in the following code:

dlgpath;
// Find all files with the extension: _1.mdd
findfiles ext:="*_1.mdd";
int numFiles = fname.GetNumTokens(LF);
// Loop over all files
int nFirst = 1;
for(int ifile = 1; ifile <= numFiles; ifile++)
{
string filepath$, filename$;
// Get next file name
filepath$=fname.gettoken(ifile,LF)$;

// Parse out just file name without path and without extension
filename$ = filepath.GetFileName(1)$;

// Make a new PE subfolder using the file name and set it active
pe_mkdir filename$ cd:=1;

// Add a new book and import data file
// Filter for file import PL Loop Analyis SVD Loop is in user folder
// The filter imports the data columns with appropriate names and X or Y settings
newbook;
impfile fname:=filepath$ filtername:="MDD-Dyn-Import.oif" location:=user;
// Remember Book and Sheet names
string bkname$ = page.name$;
string shname$ = layer.name$;
//Activate the worksheet of imported data
page.active$= shname$;
int thisWksNbr = 1;
string thisWksNbrStr$ = $(thisWksNbr);
type "$(thisWksNbrStr)";
string newSheetName$ = shname$ + "-" + thisWksNbrStr$;
int value = wks.maxRows;
for(int rowi = 1; rowi <= wks.maxRows; rowi++){
val1 = col(1)[rowi];
checkVal1 = ISNA(val1);
if(checkVal1 == 1){
//Add a sheet name 'shname' with 8 columns to current workbook
page.active$= shname$;
thisWksNbr++;
string thisWksNbrStr$ = $(thisWksNbr);
string newSheetName$ = shname$ + "-" + thisWksNbrStr$;
newsheet name:=newSheetName$ cols:=8;
}
else{
//The following script copies rows from 5 to 9 of [book1]sheet1! to a worksheet named CopiedValues in
//Book1 (if the worksheet does not exist it will be created), and assigns the values in row 4 from
//[bkname$]shname$! to the long name of the destination worksheet, [book1]CopiedValues!
type "fail";
//wrcopy iw:=[bkname$]shname$! r1:=rowi r2:=rowi name:=1 ow:=newSheetName$!;
};
type "next";
}
};
// Set PE folder to previous level and go to next file
pe_cd ..;

//////////////////////////////////////////////////////////////////
the *_1.mdd file has 8 columns. In the first column, there are a series of rows with numbers and each series is separated by a empty row.
Thank you.
Is there a good tool for Labtalk to debug codes. I mean error such as '#Command Error!' does not give much info about the error, what line?
1   L A T E S T    R E P L I E S    (Newest First)
greg Posted - 01/03/2013 : 5:01:31 PM
Make the first line of code:
[Main]
then save your code to a text file with an OGS extension.
You can load this file into Code Builder and put in break points, see variables change, single-step through the code, etc.

Maybe what you need is something like this:

shname$ = layer.name$;
range ra = 1;
startrow = 1;
loop(idx,1,ra.GetSize())
{
if(ISNA(ra[idx]))
{
newsheet name:=shname$ cols:=8 outname:=tname$;
wrcopy iw:="%(shname$)"! ow:=tname$ r1:=$(startrow) r2:=$(idx-1) label:=LUC format:=1;
startrow = idx + 1;
}
}
newsheet name:=shname$ cols:=8 outname:=tname$;
wrcopy iw:="%(shname$)"! ow:=tname$ r1:=$(startrow) r2:=$(ra.GetSize()) label:=LUC format:=1;

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