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
 Origin Forum
 Add x amount of columns after each imported file
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Milchy

5 Posts

Posted - 01/30/2024 :  03:13:30 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin 2023 (64-bit) 10.0.0.154
WIN10

Hello,

I am importing multiple ASCII files and making new columns for each new file in the same sheet.

In the option to run a script after each import, I am trying to add 5 blank columns after each imported file, and I am expecting the next file to start in its own column after the inserted ones. However my script adds only the 5 extra columns after the whole import.

I am suspecting the 5 blank columns get added, however they get populated by the subsequent file. Please guide me where is the error:

The script I am using:

wks.ncols = wks.ncols + 5;
wks.col = wks.ncols;

YimingChen

1594 Posts

Posted - 01/30/2024 :  09:15:03 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

It's not working as intended because Origin imports the new data file into a blank new column. A less-than-ideal workaround is to set the first cell of the last inserted column with a number which functions as a marker. Try the script below

wks.ncols = wks.ncols + 5;
wcol($(wks.ncols)) = Data(0,0);


We will see whether there is a need for improvement.

James
Go to Top of Page

minimax

348 Posts

Posted - 01/31/2024 :  04:30:16 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Milchy,

Besides James' solution, you can make use of system variable @ISE.

This variable is used to determine if the empty column/sheet/book can be used to import.

i.e.
script after each import
if (doc.dropindex==1) tempise=@ISE; //backup the original value
wks.ncols = wks.ncols + 5;
@ISE=1;


script after all files import
@ISE=tempise;  //roll back as original
del -v tempise;
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