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
 Exporting notes
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

gali01

Israel
5 Posts

Posted - 05/18/2011 :  1:54:34 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. 8.1 SR2
Operating System: Vista business

I'm trying to export all the data into ASCII files
I got the data by I'm having problem with the notes in each workbook

The current code is

// choose directory
fdlog.openpath(B);
// Loop over all books
doc -e W {
// loop over all sheets
doc -e LW {
// put sheet name into variable
sheet$=layer.name$;
if (%(sheet$) == "Note")
{
save -n %H %B%H-%(sheet$).txt
}
else
{
save -w %H %B%H-%(sheet$).txt
}
}
}

I think that I need to open a window from the note sheet in the workbook in order for the save -n to work. but how ?
And if I use the save -w on that sheet I do get a file but the experiment data is truncated (the ~6k limit per cell ?)

Penn

China
644 Posts

Posted - 05/24/2011 :  02:33:36 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Do you have inserted a note window into a cell? If so, please note that, save -w is used to save the worksheet data to a ASCII file, and the inserted note window cannot be converted to ASCII data here.

Penn

Edited by - Penn on 05/24/2011 02:46:29 AM
Go to Top of Page

gali01

Israel
5 Posts

Posted - 05/24/2011 :  03:19:36 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks for the quick response

The script executes w/o any error, however I'm not getting the information I need
The "note sheet in workbook" is a sheet which contains the test's setup parameters (in what looks like a single cell). It is automatically created by the instrument (fluoremeter) and contains the content of the instrument setup file
The setup file is a xml file, but since it has many characters the export function (save -w) is truncating that

I've tried the expASC function in the following

// choose directory
fdlog.openpath(B);
// Loop over all books
doc -e W {
// loop over all sheets
doc -e LW {
// put sheet name into variable
sheet$=layer.name$;
if (%(sheet$) == "Note")
{
expASC type:=csv path:=%B%H-%(sheet$)-n
}
else
{
save -w %H %B%H-%(sheet$).txt
}
}
}

but the file is empty although the script window output said "Note is exported to C:\ASCII\Try6-Note-n.csv"


Go to Top of Page

Penn

China
644 Posts

Posted - 05/24/2011 :  05:53:12 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Maybe it needs your project file to see what the problem is. Please send your project with your serial number to Origin technical support by following the instruction in this page. Please refer to this post in your email.

Penn
Go to Top of Page

gali01

Israel
5 Posts

Posted - 05/24/2011 :  12:32:58 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
OK, I've uploaded the project file
I also modified my script a bit

using some Origin C

void set_note_show(string strName = "Notes")
{
Note note(strName);
note.SetShow();
}

// choose directory
fdlog.openpath(B);
// Loop over all books
doc -e W {
// loop over all sheets
doc -e LW {
// put sheet name into variable
sheet$=layer.name$;
if (%(sheet$) == "Note")
{
set_note_show();
save -n "Notes" %B%H-%(sheet$).txt;
win -cn "Notes";
}
else
{
save -w %H %B%H-%(sheet$).txt
}
}
}

which is good for the first note but the set_note_show function doesn't seem to be working on the following worksheets in the project
Go to Top of Page

lizahunk

USA
1 Posts

Posted - 05/25/2011 :  07:26:31 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi nice discussion
Go to Top of Page

gali01

Israel
5 Posts

Posted - 05/25/2011 :  3:43:23 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
OK, so I've got it to do most of what I need by using both LabTalk and OriginC

// choose directory
fdlog.openpath(B);
// Loop over all books
doc -e W {
// loop over all sheets
doc -e LW {
// put sheet name into variable
string sheet$=layer.name$;
sheet.Remove("/");

if ((%(sheet$) != "Note") && (left(sheet$,5)$ != "Graph") && (left(sheet$,7)$ != "Contour"))
{
save -w %H %B[%H]%(sheet$).txt
}

}
}

int Project_Notes_Export()
{
char NoteFileName[1000];
string strBooksheet;
Window wnd;

Worksheet wks;
int nRow, nCol;
DWORD dwCntrl;

// Loop over all the note pages in the project
foreach(Note nte in Project.Notes)
{
// create the file name
if(nte.GetEmbeddingInfo(wks, &nRow, &nCol, &dwCntrl))
{
strBooksheet = wks_get_book_sheet_name(wks);
}
sprintf(NoteFileName, "%s%s%s", "C:\\ASCII\\" , strBooksheet , ".txt");
// show the window
nte.SetShow();
// save the note
BOOL bOK = nte.SaveToFile(NoteFileName);
//get the winodw
wnd = nte.GetWindow();
// hide window
if(wnd)
{
wnd.ShowWindow(SW_HIDE);
}
}
return 0;
}

The main issue left, is the fact that somehow all the notes windows are left open after it is done
Go to Top of Page

Penn

China
644 Posts

Posted - 05/25/2011 :  10:35:40 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

In Origin C, you can just get the text of the note window, and then write this text to a file by WriteString in stdioFile class. For example (pay attention to the red lines):

int Project_Notes_Export()
{
	char NoteFileName[1000];
	string strBooksheet;
	Window wnd;
	
	Worksheet wks;
	int nRow, nCol;
	DWORD dwCntrl;
	
	// Loop over all the note pages in the project
	foreach(Note nte in Project.Notes)
	{
		// create the file name
		if(nte.GetEmbeddingInfo(wks, &nRow, &nCol, &dwCntrl))
		{
			strBooksheet = wks_get_book_sheet_name(wks);
		}
		sprintf(NoteFileName, "%s%s%s", "C:\\ASCII\\" , strBooksheet , ".txt");
		
		// 
		stdioFile ff(NoteFileName, file::modeCreate|file::modeReadWrite);
		ff.WriteString(nte.Text);
	}
	return 0;
}


Penn
Go to Top of Page

gali01

Israel
5 Posts

Posted - 05/26/2011 :  02:50:34 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Great. Thanks
So here is the generic form of this routine

int Project_Notes_Export()
{
string strPath;
char NoteFileName[1000];
string strBooksheet;

Worksheet wks;
int nRow, nCol;
DWORD dwCntrl;

//get the user to select a folder
strPath = BrowseGetPath();
if( ! strPath.IsEmpty())
{
// Loop over all the note pages in the project
foreach(Note nte in Project.Notes)
{
//get the workbook this belongs to
if(nte.GetEmbeddingInfo(wks, &nRow, &nCol, &dwCntrl))
{
strBooksheet = wks_get_book_sheet_name(wks);
}
// create the file name
sprintf(NoteFileName, "%s%s.txt", strPath , strBooksheet );

//create a file
stdioFile ff(NoteFileName, file::modeCreate|file::modeReadWrite);
//write the note's text to the file
ff.WriteString(nte.Text);
}
}

return 0;
}
Go to Top of Page

JoSummers

1 Posts

Posted - 06/14/2011 :  06:29:56 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Will this work for the Windows 7 operating system? I've recently upgraded and wanted to make sure that I don't need to be doing anything different.
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