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
 Parsing filenames

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
kaiousama Posted - 09/09/2004 : 04:21:37 AM
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
4   L A T E S T    R E P L I E S    (Newest First)
kaiousama Posted - 09/09/2004 : 12:16:43 PM
Automating renaming is an option avaible for ASCII import but i have to import .abf Axon files.
Mike Buess Posted - 09/09/2004 : 10:14:52 AM
Thanks for correction. But why not use automatic renaming?

Mike Buess
Origin WebRing Member
kaiousama Posted - 09/09/2004 : 09:16:40 AM
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
Mike Buess Posted - 09/09/2004 : 07:15:54 AM
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

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