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 for Programming
 LabTalk Forum
 Conditionally add column to worksheet
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

rmfleming

USA
Posts

Posted - 10/17/2006 :  10:58:09 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.5 SR6
Operating System:XP

I want to add a column named "Nd" to a worksheet if it doesn't already exist. The labtalk script below works most of the time, but sometimes it doesn't recognize that column(Nd) is already there and adds another column Nd1, Nd2 ...

if(!colnum(Nd)) {wks.addCol(Nd);}; # Add Nd column to worksheet;

Is there a more robust way to do this?
Robert

Mike Buess

USA
3037 Posts

Posted - 10/17/2006 :  11:04:08 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Robert,

The worksheet -v colName command is designed to do exactly what you want... add the named column if it doesn't exist, do nothing if it does.

wo -v Nd;

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