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
 New XYYY tables according to file name
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Clairekun

Germany
175 Posts

Posted - 10/01/2013 :  06:40:28 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 9 SR2
Operating System: Windows 7

Hello, I would like to know if there's a script for what I need. I would need a script to open files (in the same folder) with similar file name into an XYYY table, for example:

ABC_1.asc
ABC_2.asc
DEF_1.asc
DEF_2.asc
DEF_3.asc
GHIa.asc
GHIb.asc
JKL.asc

So, I would like to have 4 different tables: ABC files, DEF files, GHI files and the JKL file, in XYYY format. Please note that not all of them have an underscore to separate them, although I believe I could change that if needed, but all of them do have the first 3 characters unchanged.

I would like to avoid, if possible, writing the names manually; I mean, the script would have to be something along the lines of "files with identical 3 starting characters should be in the same table"

I currently know how to open all files in a folder, both XY and XYYY format, I think I would only need a script to determine that bit about names.

Again, I do not know if such an specific script can exist.

Thank you and sorry for the long post.

Edited by - Clairekun on 10/01/2013 06:41:01 AM

greg

USA
1378 Posts

Posted - 10/01/2013 :  5:30:13 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Maybe this will work the way you want?

dlgfile gr:=*.asc mu:=1;
loop(ii,1,fname.GetNumTokens(CRLF))
{
strFile$ = fname.GetToken(ii,CRLF)$;
strPart$ = strFile.GetFileName()$;
strPart$ = strPart.Left(3)$;
if(exist(%(strPart$))==2)
{
win -a %(strPart$);
newsheet;
impasc fname:=strFile$ options.FileStruct.NumericSeparator:=0 options.Names.FNameToBk:=0;
}
else
{
newbook name:=%(strPart$) option:=lsname;
impasc fname:=%(strFile$) options.FileStruct.NumericSeparator:=0 options.Names.FNameToBk:=0;
}
}
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