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
 import vs. worksheet script execution
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

juannim

USA
Posts

Posted - 03/23/2007 :  6:49:45 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.5
Operating System:xp
Why does this script execute properly when I run it from a worksheet script window, but not when I set it to run automatically after import? Jonathan
loop(i,1,fdlog.multiopen.count) {
ii=5*(i-1);
fdlog.get(A,i,1);
wks.col$(ii+5).label$=%A;
};
wks.labels();

delete col(a)
delete col(b)
delete col(c)
delete col(d)
delete col(f)
delete col(g)
delete col(h)
delete col(i)
delete col(k)
delete col(l)
delete col(m)
delete col(n)
delete col(p)
delete col(q)
delete col(r)
delete col(s)
delete col(u)
delete col(v)
delete col(w)
delete col(x)
delete col(z1)
delete col(z2)
delete col(z3)
delete col(z4)
delete col(aa1)
delete col(aa2)
delete col(aa3)
delete col(aa4)
delete col(ab1)
delete col(ab2)
delete col(ab3)
delete col(ab4)
delete col(ac1)
delete col(ac2)
delete col(ac3)
delete col(ac4)
delete col(ad1)
delete col(ad2)
delete col(ad3)
delete col(ad4)
delete col(ae1)
delete col(ae2)
delete col(ae3)
delete col(ae4)
delete col(af1)
delete col(af2)
delete col(af3)
delete col(af4)
delete col(ag1)
delete col(ag2)
delete col(ag3)
delete col(ag4)
delete col(ah1)
delete col(ah2)
delete col(ah3)
delete col(ah4)
delete col(ai1)
delete col(ai2)
delete col(ai3)
delete col(ai4)
delete col(aj1)
delete col(aj2)
delete col(aj3)
delete col(aj4)
delete col(ak1)
delete col(ak2)
delete col(ak3)
delete col(ak4)
delete col(al1)
delete col(al2)
delete col(al3)
delete col(al4)

Mike Buess

USA
3037 Posts

Posted - 03/23/2007 :  10:17:20 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
It doesn't execute from the script window because each of the delete commands must end with a semicolon. If you're executing at import from the Worksheet Script then it works for the same reason your Worksheet Script failed in your zeroing topic. Namely, scripts that run from the Worksheet Script dialog are executed one line at a time so semicolons are not necessary.

Mike Buess
Origin WebRing Member
Go to Top of Page

zachary_origin

China
Posts

Posted - 03/23/2007 :  10:50:06 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Another point: why not use a loop to delete the columns? maybe you can try...

Zachary
OriginLab Technical Services.

Go to Top of Page

juannim

USA
Posts

Posted - 03/28/2007 :  3:42:31 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Zachary,
Why won't this script for deleting the first 4 of every 5 columns work in custom.ogs?
loop(i,1,fdlog.multiopen.count)
{
ii=5*(i-1);
fdlog.get(A,i,1);
wks.col$(ii+5).label$=%A;
};
wks.labels();
loop(i,1,fdlogmultiopen.count)
{
ii=5*(i-1);
delete col(ii+4);
delete col(ii+3);
delete col(ii+2);
delete col(ii+1);
};
Jonathan

Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 03/28/2007 :  9:52:53 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
1. The col() function only accepts a column name or number as argument. If you need to identify a column by a variable use wcol() instead.

2. Deleting a column renumbers all subsequent columns and usually causes scripts like yours to fail.

Following script will delete all columns with indices that are not multiples of 5. (It counts backwards in order to maintain the numbering.)

for(i=wks.ncols;i>0;i--) {
if( mod(i,5) ) del wcol(i);
};

Mike Buess
Origin WebRing Member
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