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
 Forum for Origin C
 Returning list of folders
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

autopilot

26 Posts

Posted - 03/29/2009 :  1:22:13 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 7.5 SR6
Operating System: winxppro

Hello,

I have 2 simple questions.

1. I can not find an originc command to return the list of folders?
I know there is "FindFiles" for files, can it be used to return the list of folders?

2. I need to import files into a worksheet. Using my limited knowledge I am planning to use LabTalk and "open -a PATH\File" command. But how do I ASSIGN the file names from the list which is returned by "FindFiles" command?

Thank you for help.

rlewis

Canada
253 Posts

Posted - 03/31/2009 :  2:44:55 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
If my reading of what you are trying to do is correct you do not need to get a list of folder paths ... and it is probably be easier achieve your desired goal(s) using OriginC in place of labTalk.
The following OC code is an example. It will enable you to browse the various directories to find the files that you want to import and to import the data into an Origin worksheet using the "Open -w ..." LT command

bool Import_Data(void)
{
	StringArray strFiletypes, strFilePaths;
	strFiletypes.SetSize(1);
	strFiletypes[0]="[My Data Files]*.*";
	string strDlgName="Selecting My Data Files";
	int NumFiles = GetMultiOpenBox(strFilePaths,strFiletypes,NULL,NULL,strDlgName,false);
	if(NumFiles>0)
	{
		for (int i=0;i<NumFiles;i++)
		{
			string PathToFile=strFilePaths[i]; 
			if (ProcessDataFile(PathToFile)==false)
			{
				return (false); // Terminate Data import of ProcessDataFile error
			}
		}
		return (true);
	}
	return (false);
}
static bool ProcessDataFile(string PathToFile)
{
		string PathToTemplate=GetAppPath(true)+"origin.otw";
		WorksheetPage wPg;
		if(wPg.Create(PathToTemplate,true)==true)
		{
			Worksheet Wks=wPg.Layers(0);
			string strLTcommand="Open -w "+PathToFile;
			if(LT_execute(strLTcommand)==true)
			{
				// Code for additional processing of the data imported into the worksheet ...
				string FileName=GetFileName(PathToFile);
				wPg.Rename(FileName);
				return (true);
			}
		}
	return (false);
}
Go to Top of Page

autopilot

26 Posts

Posted - 04/07/2009 :  07:40:53 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I very much appreciate your help.
How I am supposed to run this script? I only have an experience in running custom.ogs LabTalk code and code from script window.

Thank you very much once again.
Go to Top of Page

rlewis

Canada
253 Posts

Posted - 04/08/2009 :  01:54:13 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Try the following ...
(a) Open the CodeBuilder workspace
(b) Create an ?????.C file (File New in the Codebuilder menu)
(c) Copy the origin C functions below to the new origin C file created
(d) Add the file to the CB workspace (Right ckick System AddFiles)
(e) Compile the Origin C file (Tools Build in the CodeBuilder menu)

#include <Origin.h>
////////////////////////////////////////////////////////////////////////////////////
bool Import_Data(void)
{
	StringArray strFiletypes, strFilePaths;
	strFiletypes.SetSize(1);
	strFiletypes[0]="[My Data Files]*.*";
	string strDlgName="Selecting My Data Files";
	int NumFiles = GetMultiOpenBox(strFilePaths,strFiletypes,NULL,NULL,strDlgName,false);
	if(NumFiles>0)
	{
		for (int i=0;i<NumFiles;i++)
		{
			string PathToFile=strFilePaths[i]; 
			if (ProcessDataFile(PathToFile)==false)
			{
				return (false); // Terminate Data import of ProcessDataFile error
			}
		}
		return (true);
	}
	return (false);
}
static bool ProcessDataFile(string PathToFile)
{
		string PathToTemplate=GetAppPath(true)+"origin.otw";
		WorksheetPage wPg;
		if(wPg.Create(PathToTemplate,true)==true)
		{
			Worksheet Wks=wPg.Layers(0);
			string strLTcommand="Open -w "+PathToFile;
			if(LT_execute(strLTcommand)==true)
			{
				// Code for additional processing of the data imported into the worksheet ...
				string FileName=GetFileName(PathToFile);
				wPg.Rename(FileName);
				return (true);
			}
		}
	return (false);
}


Under origin 7.5 or Higher the code listed above should compile without error
You can then open the script window and enter the command ...

Import_Data() ... to execute the function ...
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