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
 Parsing filenames
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

kaiousama

Japan
Posts

Posted - 09/09/2004 :  04:21:37 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I'd like to rename a worksheet according to the name of the file i imported in it.
I have the filename with its full path obtained from the opendialog in %A variable:

FDLog.get[%A,1];

Is there a way to parse the filename without its path & file extension?
(for instance i have "c:\test\MyFile.abf" in %A and i want to parse the substring "MyFile" from it)

Thanks.

Origin Version : 6.0
Operating System: winXP

Mike Buess

USA
3037 Posts

Posted - 09/09/2004 :  07:15:54 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
That can be done automatically through ASCII Options... click the Other Options button and check 'Rename Worksheet to Data File Name'.

If for some reason that doesn't work you can do this...

for(i=%[%A];i>1;i--) {if("%[%1,i:i]"=="\") break};
%A=%[%A,>i+i]; // file name
%A=%[%A,'.']; // strip extension

Mike Buess
Origin WebRing Member
Go to Top of Page

kaiousama

Japan
Posts

Posted - 09/09/2004 :  09:16:40 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks Mike, your code had a couple of imprecisions but the basic principle works like a charm ;)
I've attached the corrected code if someone else need it:

FDLog.get(%A,1);
for(i=%[%A];i>1;i--) {if("%[%A,i:i]"=="\") break}; // Find last slash position
%A=%[%A,>i+1]; // Parse file name
%A=%[%A,'.']; // Strip extension
win -r %H %A; // Rename worksheet
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 09/09/2004 :  10:14:52 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks for correction. But why not use automatic renaming?

Mike Buess
Origin WebRing Member
Go to Top of Page

kaiousama

Japan
Posts

Posted - 09/09/2004 :  12:16:43 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Automating renaming is an option avaible for ASCII import but i have to import .abf Axon files.
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