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
 LabTalk Forum
 file names into Worksheet after ASCII import

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
J.S.Schulte Posted - 07/16/2014 : 10:26:47 AM
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?
1   L A T E S T    R E P L I E S    (Newest First)
Kathy_Wang Posted - 07/17/2014 : 04:46:07 AM
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

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