Author |
Topic  |
|
kaiouu
Germany
Posts |
Posted - 11/23/2005 : 11:45:31 AM
|
Origin Version (Select Help-->About Origin): 7.5Pro Operating System:win2000
Hi,
I use a Import script like this:
FDlog.dlgName$="Importiere vielfaeltige ASCII-Dateien "; FDlog.useGroup(ASCII); if( FDlog.MultiOpen()==0/0 ) return; for(j=1;j<=fdlog.multiopen.count;j++) { %Z=""; fdlog.get(A,j); win -t D Originkai; open -w %A; if (%[%Z]>0){ page.info.add(User); page.info.User.addSection(Variables); loop(i,1,49){ if (%[%[%Z,@(50-i)]]==0) nlines=49-i; }; loop(i,1,nlines){ if (%[%[%Z,@i]]>0) page.info.user.variables.L$(i)V1$=%[%Z,@i]; }; if (nlines>1) %T=page.info.user.variables.L2V1$; if (%[%T, 3] == "#%") { window -r %H %[%(%H,@W,L2V1$),>'%']; loop(i,2,nlines-1){ %T= page.info.user.variables.L$(i+1)V1$; page.info.user.variables.L$(i)V1$=%T; };
.....
The aim is to get the headerlines of the ascii-file to display it. Another feature is that I can define shortnames in the second header-line, like
#first header line #% shortname
that means the script asks for the % token, and renames the worksheet, and shifts the system variables. This works fine so far, except that to shortnames are the same, or ith first significant 14 characters are the same. Then Origin asks to rename the filename, which doesn't work and then origin crashes.
My question is now: Is there a way to use the renaming-feature of Origin in Labtalk? And how can I check, if the worksheetname already exists? Then I could just check this, and change the name eventually...
Kai
|
|
Mike Buess
USA
3037 Posts |
Posted - 11/23/2005 : 12:40:13 PM
|
First I suggest you let Origin give the wks default names and put the (full) desired name in the label. If the name you want is in the string variable %A then label the wks window like this...
page.label$=%A; // create page label page.title=3; // show page label
Later you can find the wks labelled %A like this...
%W=""; doc -e W { %L=page.label$; if("%L"=="%A") {%W=%H; break}; }; %W=; // name of desired wks
If you don't like that then use the exist() function to test if a window named %A already exists. I think the actual limit to the length of a window name is 13 (not 14) characters, so something like this will work...
if(%[%A]>13) %A=%[%A,14]; // truncate to 13 characters if( exist(%A,2)==2 ) type %A exists; else type %A does not exist;
But what to do if it already exists? If your names are always truncated one possibility is to truncate further to 11 (for example) characters and enumerate...
%A=%[%A,12]; // truncate to 11 characters for(i=1;i>0;i++) { if(exist(%A$(i),2)==0) {%A=%A$(i); break;} }; win -r %H %A; // give wks the next valid name
Mike Buess Origin WebRing Member |
 |
|
kaiouu
Germany
Posts |
Posted - 11/25/2005 : 09:52:01 AM
|
Hi Mike,
thanks a lot for the code. The if-then-else works, but the for-loop alway causes an error: Error: For loop-size to big. I tried the for-loop itself alone, and it worked, as well as the rest of the script without the loop, so I have no idea what this means..
Kai |
 |
|
Mike Buess
USA
3037 Posts |
Posted - 11/25/2005 : 10:12:12 AM
|
Hi Kai,quote: but the for-loop alway causes an error: Error: For loop-size to big.
I get no error when I run the loop so you must have a syntax error such as a missing or extra semicolon or bracket.
Mike Buess Origin WebRing Member |
 |
|
|
Topic  |
|
|
|