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
 Origin Forum
 Dialog to select a folder
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

peter.cook

UK
356 Posts

Posted - 10/30/2003 :  3:13:53 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
HI,

Is there any way I can set a dialog to search/browse for a folder rather than a file(s) in the folder eg user wants to selct a folder and assume that all files in that folder are then opened and appended into one worksheet?

Thanks,

Cheers,

Pete

Mike Buess

USA
3037 Posts

Posted - 10/30/2003 :  5:01:26 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Pete,

I think this is what you're looking for...

fdlog.OpenPath(B); // Open a folder selection dialog, assign selected path to %B

Mike Buess
Origin WebRing Member
Go to Top of Page

rlewis

Canada
253 Posts

Posted - 10/30/2003 :  5:14:33 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Pete..

You may alos find the following OriginC approach useful ...
bool FDLOG_LT_init(void)
{
// .... Initialize the LabTalk FDLOG Object
LabTalk.FDLOG.Reset();
LabTalk.FDLOG.DlgName$="";
LabTalk.FDLOG.OptionDLG$=""; //Reset button to off
LabTalk.FDLOG.checkname$=""; //Reset check box to null
LabTalk.FDLOG.ShowComment=0; //close the comments box
LabTalk.FDLOG.CheckStatus=0; //Set checkbox to off
LabTalk.FDLOG.default$=""; //Clrar the "File Name" edit box
LabTalk.FDLOG.MultiOpen.ComboName$="";
if(LabTalk.FDLOG.MultiOpen.ComboSel<1 || LabTalk.FDLOG.MultiOpen.ComboSel>3)
{
LabTalk.FDLOG.MultiOpen.ComboSel = 2;// import into new columns
}
return (true);
}
bool All_Files_In_Directory(void)
{
if (FDLOG_LT_init())
{
LabTalk.FDLOG.numTypes=1;
LabTalk.FDLOG.type1$="[All files]*.*";
LabTalk.FDLOG.Dlgname$="Select one or more Files in Directory";
if (LabTalk.FDLOG.multiopen()==0)
{
string PathToFileName, PathToFiles=LabTalk.Fdlog.Path$+"\\*.*";
WIN32_FIND_DATAA findFile;
HANDLE hFile;
int NumFiles=0;
if((hFile=FindFirstFile(PathToFiles,&findFile))!= INVALID_HANDLE_VALUE)
{
PathToFileName=LabTalk.Fdlog.Path$+"\\"+findFile.cFileName;
if(PathToFileName.IsFile())
{
out_str(findFile.cFileName);
NumFiles ++;
}
while (FindNextFile(hFile, &findFile)==true)
{
PathToFileName=LabTalk.Fdlog.Path$+"\\"+findFile.cFileName;
if(PathToFileName.IsFile())
{
out_str(findFile.cFileName);
NumFiles ++;
}
}
string strTemp;
strTemp.Format("%d",NumFiles);
out_str(strTemp+" Files found");
return (true);
}
}
}
return (false);
}
Go to Top of Page

rlewis

Canada
253 Posts

Posted - 10/30/2003 :  5:17:31 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Opps .. forgot to mention ..
With the OriginC approach outlined above .. you can navigate to the directory, but wou will have to select one of the files in the directory (its the only way the Okay button becomes active) ...
Go to Top of Page

rlewis

Canada
253 Posts

Posted - 10/30/2003 :  6:55:53 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Here is a bit more compact OriginC approach using Fdlog.OpenPath (see Mike Buess"s post above ...

bool List_All_Files_In_Directory(void)
{
if(!LabTalk.Fdlog.OpenPath("Z"))
{
char strBuffer[MAXFULLPATH];
LT_get_str("%Z",strBuffer,MAXFULLPATH);
string PathToFileName, PathToFiles=strBuffer+"*.*";
WIN32_FIND_DATAA findFile;
HANDLE hFile;
int NumFiles=0;
if((hFile=FindFirstFile(PathToFiles,&findFile)) != INVALID_HANDLE_VALUE)
{
PathToFileName=strBuffer+findFile.cFileName;
if(PathToFileName.IsFile())
{
out_str(findFile.cFileName);
NumFiles ++;
}
while (FindNextFile(hFile, &findFile)==true)
{
PathToFileName=strBuffer+findFile.cFileName;
if(PathToFileName.IsFile())
{
out_str(findFile.cFileName);
NumFiles ++;
}
}
string strTemp;
strTemp.Format("%d",NumFiles);
out_str(strTemp+" Files found");
return (true);
}
}
return (false);
}


It has the advantage that you do not have to select a file from the directory to activate the process. But on the down side you do not get to see what files are in the directory before selecting the directory
Go to Top of Page

peter.cook

UK
356 Posts

Posted - 10/31/2003 :  03:16:02 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Thanks alot for the assist Mike and Ruthven - much appreciated.

Cheers,

Pete

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