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
 How to perform exist test on worksheet name?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Loksley

France
18 Posts

Posted - 03/23/2009 :  10:49:49 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. : OriginPro8 Sr4
Operating System: Xp Sp2

Hi everybody!
I’d like to perform an exist test before running a script.
page.active$=Fitted_Datas;
if (page.active$!="Fitted_Datas") 
{type "Fitted_Datas doesn’t exist" ;
run.section(FitScript, Main);		//FitScript works fine without the test condition
};
else { type "Fitted_Datas exist. Please rename the wks.";};
return #Command Error! If Fitted_Datas worksheet doesn’t exist and it stops the script. (I understand that point)

I also tried this code :
str$="Fitted_Datas";
if (exist(str$)!==2)
…
But exist(str$) always return 0. No matter Fitted_Datas exist or not
And if I use "str$="[Book1]Fitted_Datas";", exist(str$) will always return 2.

I would be very pleased to get any tips.
Thank you for your help.

Loksley

France
18 Posts

Posted - 03/24/2009 :  09:43:22 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I found out:
I post one solution, hoping that might helps someone.

doc -e LW {
if ("%E" == "[%H]Fitted_Datas"){type -b "Fitted_Datas worksheet exist";};
else {type -b "Fitted_Datas worksheet doesn't exist";};
};

Go to Top of Page

Laurie

USA
404 Posts

Posted - 03/24/2009 :  12:42:01 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The exist function will work, if you specify the bookname and sheetname as follows:

exist([book1]sheet1)

It will return 2 if it exists. You can also use %H in place of the bookname if the workbook is the active window:

exist([%H]sheet1)

The solution you found will work. You can use layer.name$ instead of %E when looping through all sheets with the doc -e LW command. Layer.name$ will return each subsequent sheet name.

OriginLab Technical Support
Go to Top of Page

Loksley

France
18 Posts

Posted - 03/24/2009 :  4:29:05 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks for the answer.
But:
quote:
The exist function will work, if you specify the bookname and sheetname as follows:

exist([book1]sheet1)

It will return 2 if it exists.

I tried this before, but it always return 2 no matter if sheet1 exist or not!
I assum this bug comes from [%H] wich is recognized by the exist function as a worksheet path... Even if the Sheet1 doesn't exist.
Go to Top of Page

Laurie

USA
404 Posts

Posted - 03/25/2009 :  10:22:09 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
My mistake...sorry...

You need to use the following:

exist([book1]sheet1!)

OriginLab Technical Support
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