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
 file names into Worksheet after ASCII import
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

J.S.Schulte

Germany
11 Posts

Posted - 07/16/2014 :  10:26:47 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release: OrigPro 9.1SR3
Operating System:Win7 64bit

Hi everybody,
after importing several ASCII-files into new rows of a worksheet, I want to replace the first cell of each row with the respective filename of each imported file.

Here is my script I'm executing in the script window:
fdlog.reset();
impASC options.FileStruct.NumericSeparator:=1;
loop(ii,1,fdlog.multiOpen.count)
{
fdlog.get(A,ii,1);
cell(ii,1)$=%A;
};

- Executing the script, I at first select 10 files which are correctly imported into 10 rows of the active worksheet
- The replacement of first columns rows with the imported file names does not work!
- When i type "count=" into the script window, it returns "0"

Does anybody has a clue what the problem is?

Kathy_Wang

China
159 Posts

Posted - 07/17/2014 :  04:46:07 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Your script does not work as expected because the "Open" dialog (the one you used to select files) is not brought up by the fdlog object, but the "impASC" x-function because you did not specify file name.

In fact, you could try to use the dlgFile x-function(http://www.originlab.com/doc/X-Function/ref/dlgFile) instead, then the script would be something like below:


newbook;
dlgfile group:=ASCII multi:=1;
string file$, fileName$;
loop(ii, 1, fname.GetNumTokens(CRLF))
{
   file$ = fname.GetToken(ii, CRLF)$;

   fileName$ = file.GetFileName(1)$;

   impASC fname:=file$ options.ImpMode:=2 options.FileStruct.NumericSeparator:=1; 
   cell(ii,1)$ = fileName$;  
}


Kathy
Originlab

Edited by - Kathy_Wang on 07/17/2014 04:53:17 AM
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