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
 Forum for Origin C
 Returning list of folders

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
autopilot Posted - 03/29/2009 : 1:22:13 PM
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.
3   L A T E S T    R E P L I E S    (Newest First)
rlewis Posted - 04/08/2009 : 01:54:13 AM
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 ...
autopilot Posted - 04/07/2009 : 07:40:53 AM
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.
rlewis Posted - 03/31/2009 : 2:44:55 PM
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);
}

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