Option Explicit in .wsf and .asp files

Hi

I have a number of .vbs files in the following format:

C1.vbs:
Option Explict

Class clsC1

End Class

I can include these files in a .wsf file like this:
<package>
    <job>
	    <script language="VBScript" src="C1.vbs"/>
	    <script language="VBScript" src="C2.vbs"/>
    </job>
</package>

I also want to include the same files in an .asp file like this:
<script language="VBScript" runat="SERVER" src="C1.vbs"></script>
<script language="VBScript" runat="SERVER" src="C2.vbs"></script>

However, this fails because of the repeated Option Explicit Statements. I 
can remove each Option Explicit statement from the .vbs files and add <% 
Option Explicit%> to the .asp file, but then Option Explicit is not working 
in the .wsf file.

Is there a way that I can include the same .vbs files in a .wsf and .asp 
file and having Option Explicit working in both?

Regards,

Michael Larsen

0
Utf
3/4/2010 1:39:02 PM
scripting.vbscript 564 articles. 0 followers. Follow

7 Replies
1262 Views

Similar Articles

[PageSpeed] 25

Michael Larsen wrote:
> Hi
> Is there a way that I can include the same .vbs files in a .wsf and
> .asp file and having Option Explicit working in both?
>
No

-- 
HTH,
Bob Barrows


0
Bob
3/4/2010 4:09:27 PM

"Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message 
news:OGgFSU7uKHA.796@TK2MSFTNGP05.phx.gbl...
> Michael Larsen wrote:
>> Hi
>> Is there a way that I can include the same .vbs files in a .wsf and
>> .asp file and having Option Explicit working in both?
>>
> No

But why would you need option explicit? If you are including code to define 
classes, presumably you would have debugged them individually. Once free of 
the bugs of spelling a variable name incorrectly or using an undefined 
variable, option explicit is not doing anything for you. I'd say just leave 
it out.

Of course, if your code is executing code built at run-time, you might 
require option explicit.

/Al
 

0
Al
3/5/2010 4:11:13 AM
Al Dunbar wrote:
> "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
> news:OGgFSU7uKHA.796@TK2MSFTNGP05.phx.gbl...
>> Michael Larsen wrote:
>>> Hi
>>> Is there a way that I can include the same .vbs files in a .wsf and
>>> .asp file and having Option Explicit working in both?
>>>
>> No
>
> But why would you need option explicit?

Ummmm ... I don't know. You'll need to ask the OP. :-)
Or is this one of the cases where your newsreader failed to pick up the 
original post, forcing you to reply to me?

But it is a valid question. Oprion Explicit is only really needed while the 
code is being written and debugged, as you say.

-- 
Microsoft MVP - ASP/ASP.NET - 2004-2007
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM" 


0
Bob
3/5/2010 1:15:40 PM
"Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message 
news:eojoyXGvKHA.3896@TK2MSFTNGP02.phx.gbl...
> Al Dunbar wrote:
>> "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
>> news:OGgFSU7uKHA.796@TK2MSFTNGP05.phx.gbl...
>>> Michael Larsen wrote:
>>>> Hi
>>>> Is there a way that I can include the same .vbs files in a .wsf and
>>>> .asp file and having Option Explicit working in both?
>>>>
>>> No
>>
>> But why would you need option explicit?
>
> Ummmm ... I don't know. You'll need to ask the OP. :-)
> Or is this one of the cases where your newsreader failed to pick up the 
> original post, forcing you to reply to me?
>
> But it is a valid question. Oprion Explicit is only really needed while 
> the code is being written and debugged, as you say.

Ummmm ... I don't know.  I'm thinking that Option Explicit is really needed 
as long as the possibility exists that it may catch an error.  I suppose it 
is no longer needed then the code is retired.

-Paul Randall 


0
Paul
3/5/2010 7:36:21 PM
Paul Randall wrote:
> "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
> news:eojoyXGvKHA.3896@TK2MSFTNGP02.phx.gbl...
>> Al Dunbar wrote:
>>> "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
>>> news:OGgFSU7uKHA.796@TK2MSFTNGP05.phx.gbl...
>>>> Michael Larsen wrote:
>>>>> Hi
>>>>> Is there a way that I can include the same .vbs files in a .wsf
>>>>> and .asp file and having Option Explicit working in both?
>>>>>
>>>> No
>>>
>>> But why would you need option explicit?
>>
>> Ummmm ... I don't know. You'll need to ask the OP. :-)
>> Or is this one of the cases where your newsreader failed to pick up
>> the original post, forcing you to reply to me?
>>
>> But it is a valid question. Oprion Explicit is only really needed
>> while the code is being written and debugged, as you say.
>
> Ummmm ... I don't know.  I'm thinking that Option Explicit is really
> needed as long as the possibility exists that it may catch an error.

Explain please. How can an error that Option Explicit would "catch" occur if 
the code is not changed?

-- 
Microsoft MVP - ASP/ASP.NET - 2004-2007
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM" 


0
Bob
3/5/2010 8:54:23 PM
"Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message 
news:%23zPfEaKvKHA.3408@TK2MSFTNGP06.phx.gbl...
> Paul Randall wrote:
>> "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
>> news:eojoyXGvKHA.3896@TK2MSFTNGP02.phx.gbl...
>>> Al Dunbar wrote:
>>>> "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
>>>> news:OGgFSU7uKHA.796@TK2MSFTNGP05.phx.gbl...
>>>>> Michael Larsen wrote:
>>>>>> Hi
>>>>>> Is there a way that I can include the same .vbs files in a .wsf
>>>>>> and .asp file and having Option Explicit working in both?
>>>>>>
>>>>> No
>>>>
>>>> But why would you need option explicit?
>>>
>>> Ummmm ... I don't know. You'll need to ask the OP. :-)
>>> Or is this one of the cases where your newsreader failed to pick up
>>> the original post, forcing you to reply to me?
>>>
>>> But it is a valid question. Oprion Explicit is only really needed
>>> while the code is being written and debugged, as you say.
>>
>> Ummmm ... I don't know.  I'm thinking that Option Explicit is really
>> needed as long as the possibility exists that it may catch an error.
>
> Explain please. How can an error that Option Explicit would "catch" occur 
> if the code is not changed?

Good point.  I guessASP code that doesn't run because of multiple Option 
Explicit statements can not have run time errors.

-Paul Randall 


0
Paul
3/6/2010 2:58:34 AM

"Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message 
news:#zPfEaKvKHA.3408@TK2MSFTNGP06.phx.gbl...
> Paul Randall wrote:
>> "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
>> news:eojoyXGvKHA.3896@TK2MSFTNGP02.phx.gbl...
>>> Al Dunbar wrote:
>>>> "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
>>>> news:OGgFSU7uKHA.796@TK2MSFTNGP05.phx.gbl...
>>>>> Michael Larsen wrote:
>>>>>> Hi
>>>>>> Is there a way that I can include the same .vbs files in a .wsf
>>>>>> and .asp file and having Option Explicit working in both?
>>>>>>
>>>>> No
>>>>
>>>> But why would you need option explicit?
>>>
>>> Ummmm ... I don't know. You'll need to ask the OP. :-)
>>> Or is this one of the cases where your newsreader failed to pick up
>>> the original post, forcing you to reply to me?
>>>
>>> But it is a valid question. Oprion Explicit is only really needed
>>> while the code is being written and debugged, as you say.
>>
>> Ummmm ... I don't know.  I'm thinking that Option Explicit is really
>> needed as long as the possibility exists that it may catch an error.
>
> Explain please. How can an error that Option Explicit would "catch" occur 
> if the code is not changed?

It can't, unless...

- There is a piece of code that has never executed in testing, but that 
could execute under certain conditions, or:
- the code is self-modifying.

The first should never happen in a script containing functions or class 
definitions.

The second is to flirt with danger.

That said, I always leave in the option explicit, because to take it out 
means modifying working code :-)

Seriously, though, the only reason I see for ever wanting to remove option 
explicit is the situation posed by the OP, in which a piece of code is 
included in different contexts that handle option explicit differently.

/Al
 

0
Al
3/6/2010 3:08:09 AM
Reply:

Similar Artilces:

Cannot open excel files; Installation error; source CD won't run
None of my excel files (Outlook 2003) can be opened. Message: please wait while Windows configuresoutlook standard 2003. Then further message: Installation error file not found, run original CD. Have tried but the CD will not run ...

Ach File
Hello everyone, acct. created the .ach file before they realized they were supposed to remove one person as he was supposed to get a check instead. When trying to remove this person after the fact and regenerate the .ach file he is still in there. Are we missing a step or do we have to manually edit the .ach file Hello - we have been told that you have to actually edit the raw data of your created ACH file. We choose not to do that. Let the deposit go in and send our bank a reverasal on the same day. "Brian" wrote: > Hello everyone, acct. created the .ach f...

asp.net 2.0 forms, controls, and capabilities
Eventhough I know this is a major jump that will never see the light in CRM, ideally, the CRM should use the technologies of .NET 2.0. I mean, it is Microsoft's direction for developers, they should utilize their own technologies. Creating a form/code, etc for CRM should be easy as choosing a project or template type in Visual Studio and then creating the necessary items. A "CRM DataSource" could be available, in line with the "data source" features that will be presented in Visual Studio 2005. Caching (table watching, etc) should be available, the types of contr...

Max .xls file name in windows
Hi, I would like to know, if there is any limit on the max length of .xls filename and filepath. On the path "C:\Documents and Settings\parag_mahajan\Desktop" I am able to create a file name of xls file upto 170 characters (166 characters for filename and .xls = 4 chars), which opens up properly. Also does it have to do anything with the file path length.?? since, when & On the path, "C:\" I can open the xls file with length upto 215 characters (211 + 4 for .xls). And if I try to add one more character to the file name , the MS excel says, it cannot find the file. I...

Office 2003 Missing File:C:\SKU011:CAB trying to update to Office
Somehow my source file C:\SKU 011.cab for Office 2003 is missing & I can't install Office 2007. How can this be overcome? If you do not have the installation cd and want to solve this issue follow these steps: (works most of the time with all sku.cab files) 1. Click on start==>run==>type "excel /s" without quotations and click ok. 2. Once Excel is up in safe mode with the error message in front, hold down ctrl+Alt+Delete keys on your keyboard to bring the task manager up. 3. Click on the processes tab==>look for msiexec.exe (only the one next to your...

Why is redirect rule absent from my rules and alerts options?
Outlook 2003 help at <http://office.microsoft.com/en-au/outlook/HA011502011033.aspx?pid=CH063564671033> offers a choice of either forwarding or redirecting mail. I want to redirect mail to a webmail address to access it more easily while travelling. Redirect suits me better than forwarding, as forwarded mail all appears to come from me (i.e. original sender is not visible until mail is opened -- bit inconvenient). The forwarding option/s are visible among the checkboxes under 'Rules and alerts' but there is no sign of the 'Redirect it to people or distribution list&#...

File paths button
We have a customer that used to use Office 2003 and had a simple way of inserting the file path in the document footer. (we created a button that was one of the menu items) After the upgrade them to Office 2007, there are many more steps to getting the same information, and we don't seem to be ablet to create the same button. How can we add a button to his Office 2007 toolbar that will insert the file path? (The closest thing I found was creating a customer footer with this, but it overwrites existing footers with other information in them, so this is not an option.) Thank...

RMS matrix attribute option
Adding an existing item in the RMS 2.0.0114 matrix with 219 attributes and 826 items and saving it takes about 2 hours to complete (using Windows XP SP2 Pentium D 3.0 Ghz with 2 G RAM). Since the backend is SQL Server, we don’t see any reason for the application not to support matrix records of this size, considering that the Item has 219 attributes and 826 items only. I think it would be better if RMS has the option not to load the existing attributes for the dropdown list. Just enable the addition of new dimensions. ---------------- This post is a suggestion for Microsoft, and Micro...

Why No "Format Cells" Choice Option Always ?
Hello, Using Excel 2007. When I select a Column of numbers, I usually see a choice for "Format Cells" At other times, for different Columns (also with numbers in the cells, I do not get the Format Cells choice. All that shows up as being selectable are: Cut, Copy, Clear Contents Why might this be ? Thanks ...

Exporting to text file
I'm trying to export data to a space delimited text file, which will be uploaded to a mainframe dataset for processing. I need to define an output format, such as Column1 is position 1-4, column2 is positon 5-15, column3 is position 16-40. Using the File-Save As - .prn option does not give me precise control over column positions in the output file. Can I do this in Excel or should I move the data to Access and work from there? You can manually adjust the column width for each column to the number of characters the column should hold. Column1 width should be 4, Column2 should b...

Tools,Options, Email Options, AdvancedE-mail Options,
Hi, Windows XP, Outlook 2003, Desktop Alert stop popup, When it check in - Tools,Options, Email Options, AdvancedE-mail Options, It supposed to be "Preview" option, its not , In "When new item arrive in my Inbox" all the option mark, But when new mail arrived Desktop Alert not popup, What could be the problem Thank you & Bets Regards, Yakov Do you have a rule set to move messages? If you do then you need to add showing the Desktop Alert to that rule. "Yakov" <Yakov@discussions.microsoft.com> wrote in message news:304C2EEA-5839-47B1-A737-475921A51D...

Power options issue 06-24-10
When I click on Control Panel and then Power Options and set turn off monitor to 20 minutes and turn off hard drive to 20 minutes nothing happens. However if I change those settings to turn off monitor to 1 minute and turn off hard drive to 3 minutes it works every time. I do not know what the problem is or how to correct it, so any help would be greatly appreciated. You should also know that no changes to my system have been made since this problem started happening. The turn off cannot be executed until the computer is not running anything for the amount of time you selec...

Options okn Tools Menu
I have a user who is using Excel 97. When he goes to the menu bar and selects Tools then Options, the Options chioce is there but when you clck on it it does nothing. Has anyone had this issue before and if so how can I get his Options functionality back? Excel and Office has been uninstalled and reinstalled several times. Maybe this is it: XL97: Page Fault or Violation When You Click Options on the Tools Menu http://support.microsoft.com/default.aspx?scid=kb;en-us;108032 sounds like it describes your Tools|Options problem (it says it was corrected in xl97 SR2). Ron Davidson wrote:...

Converting text files from scanner output
I was hoping someone could help me with find a program that converts a text generated file into QIF format. My process involves scanning bank & credit card statements into a OCR application which then generates a text file. From there, I would like to run a conversion program which would format the text file into a QIF. Any suggestions? Thanks, Mick You're probably going to have to write something yourself--or get the data into Excel. From Excel, there are quite a number of options for generating QIF. See http://umpmfaq.info/faqdb.php?q=8. "Mick H" <micster@sbcgl...

Lotus 123 files in XL 2007
I have an ancient Lotus 123 file (.wk1) that used to open fine in Excel 2002 but will not open in Excel 2007. Is there a way to make XL 2007 recognize it? Jeff On 5/19/2010 10:41 AM, Jeff@nospam.fake wrote: > I have an ancient Lotus 123 file (.wk1) that used to open fine in Excel > 2002 but will not open in Excel 2007. Is there a way to make XL 2007 > recognize it? > Jeff Solved the problem. Re-installed XL 2002 and saved the file as xls which then opened fine in XL 2007. "J...@nospam.fake" <J...@nospam.fake> wrote... >J...@nospam.fake wrote: ...

Opening Office Files
I typically open my documents/excel files/power point by clicking on the file directly. Everytime I do I get the following message: "Please wait while Windows configures Microsoft Office Professional Hybrid 2007". This causes a long delay in opening the file and my previous system(XP) did not perform this task. My new system is Vista. I also have a problem every time I open Outlook, it starts installing Visio and PowerPoint. Any reason why it should do any of these? How do I alleviate these from happening? Thanks, -- Gevan "Gevan" <Gevan@discus...

How to send bmp file over network?
hi everyone click in here i 've two applications client & server, both developed using CSocket in vc+ client application : requests the desktop capture of the system where server is runnin server application : captures the desktop as bmp file and send it to client iteratively here the problem is how to send bmp file to client application through sockets, since i got captured desktop as bmp file thx in advanc Dharmara Wouldn't you send it like you would any other file? I don't think network protocols are discriminatory, are they? "Dharmaraj" <anonym...

corrupt file or not a money back up file
I know that this has been posted before, but never saw any where the issue was resolved and how it was resolved. I have three sets of back up money files that all give the same error. I had to reload money when my computer crashed. I get the error after I click on *d1.mbf and then hit ok after inserting the second disk. It states that d1.mbf is corrupt or is not a money backup file. I also tried this from the hardrive. Same results Any suggestions please? Thnks, Miss Cammy In microsoft.public.money, Cammy wrote: >I know that this has been posted before, but never >saw any wh...

open mht file
Hi When I save the excel as mht and then open it in the IE , the size of the sheet very small How can I config the size of the page ? thx ...

transfering files #2
I am having a problem transfering a file from an old computer with windows 95 MSMoney. My new computer with windows xp will not open it. I have tryed a lot of options and windows instant suport could not help can some one out there??? Should another version of MSMoney work? I did downlpad it, but to no avail in opening the file in spreadsheet form. Help Please! In microsoft.public.money, me wrote: >I am having a problem transfering a file from an old >computer with windows 95 MSMoney. My new computer with >windows xp will not open it. I have tryed a lot of >options and w...

Change printing options based on tender types
I have curerntly setup our POS registers to automotically print 40-column receipts and to prompt the user for whether or not to print a large 80-column invoice. However, I would like to have large invoices automatically print for all charge account tenders. Is there a way to specify the print behavior based on the tender type for the transaction? Thanks, Paul Arenson Anderson Plywood Sales, Culver City, CA not without an add-in. Seems like someone posted something about that within the last few weeks - try searching the newsgroup. -- Glenn Adams Tiber Creek Consulting http://ww...

Can I delete this file ?
After resize harddisk by Norton Partition magic Now there are three partitions C , D , F But I find a empty file named D in D Drive . It cannot be deleted , renamed or hidden . Can I delete the file ? If yes , how can I delete it ? Do it in safe mode or use software such as unlocker ? Thanks ! *(Sorry For My Poor English )* -- kwanami ------------------------------------------------------------------------ kwanami's Profile: http://forums.techarena.in/members/168181.htm View this thread: http://forums.techarena.in/windows-xp-support/1293971.htm http://forums.techar...

Adding on Option to an Option Group
I have created a form to give a report of 3 tables and give the user the ability to sort on a column by checking the check box on the header. I had to add another field to one of the tables and now need to add this to the option group.. how? Thanks Sue Found it - for others, you need to add the field to the record source for the form, then with the option group selected, open the field list and drag the new field onto the option group (at least I hope that is it) Sue (Sometimes it actually pays off to have a stack of books over a foot high on Access) "Design by Sue" wrote...

Remove Marketing and Service Option from Left Nav Bar
When the only entity selected in a security role is Account access, we would like the options for Marketing and Service not to be seen in the left hand Nav bar. -- Thanks, Justin ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane. http://www.microsoft.com/Businesssolutio...

Using VBA to link Excel and Powerpoint files
I am working on a VBA project wherein I would like to link portions of a PowerPoint presentation within the macros of excel file. Any suggestions ...