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
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 How to perform exist test on worksheet name?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Loksley Posted - 03/23/2009 : 10:49:49 PM
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.
4   L A T E S T    R E P L I E S    (Newest First)
Laurie Posted - 03/25/2009 : 10:22:09 AM
My mistake...sorry...

You need to use the following:

exist([book1]sheet1!)

OriginLab Technical Support
Loksley Posted - 03/24/2009 : 4:29:05 PM
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.
Laurie Posted - 03/24/2009 : 12:42:01 PM
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
Loksley Posted - 03/24/2009 : 09:43:22 AM
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";};
};


The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000