T O P I C R E V I E W |
masterd |
Posted - 08/25/2005 : 01:07:45 AM Origin Version (Select Help-->About Origin): Pro 7.5 SR4 Operating System: XP
Hello there,
I import an awful lot of ASCII files into Origin at the same time, so I have set up an import wizard with the following script to set filename as column label on all y columns:
%a = Doc.DropFileName$; // Get Path + File Name
// Need to extract just File Name from this string
ilen = %[ %a ]; // get length of string
for( ii = ilen; ii >= 1; ii-- ) // read from right end and find the "\" character
{
%b = %[ %a, ii : ii ];
if( %b == "\" ) break; // if "\" found, exit from loop
};
%b = %[ %a , ii + 1 : ilen ]; // get part of string to right of "\" found
wks.col$( wks.ncols ).label$ = %b; // assign extracted filename to column label
wks.labels(); // turn on display of label
It works fine except one small thing. it includes a file extension (.libs) in each label and I dont need file ext as some of the filenames are quiet long anyway. Is it possible to modify the script not to include file extension when setting column labels?
While we are at it, some filenames contain underscores("_"), so is it possible to replace underscores with a space?
Thanks in advance,
Darko
|
2 L A T E S T R E P L I E S (Newest First) |
masterd |
Posted - 08/25/2005 : 10:54:45 AM Thanks a lot Mike!
It took a bit of fiddling but now its all smooth sailing, just like hot knife through the butter! 
For some reason I could not get (%A=replace_withSpace(%A)$;) working but that last LT method certainly did solve my picky problem.
Extension stripping works just as it should.
Now I can show off at uni and convert all those loyal Excel workmates to Origin loyals. lol
Thanks again
Darko
|
Mike Buess |
Posted - 08/25/2005 : 07:38:37 AM Use this to strip the file extension.... %A=%[%A,'.'];
LabTalk can't do character replacement so you'd have to examine and manipulate the string character by character. Much easier to use this simple OC function...
string replace_withSpace(string str) { str.Replace('_',' '); return str; }
Use it in you scripts like this... %A=replace_withSpace(%A)$;
...Turns out there is a relatively simple LT method after all,
%A=one_two_three; %B=""; for(i=1;i>0;i++) { %T=%[%A,#i,_]; if(%T=="") break; %B=%B %T; }; %B=; one two three
So, take your pick.
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 08/25/2005 07:57:41 AM |
|
|