Login | |
|
 |
Using "Include" files in VBScript Without Usi... - 1/12/2006 7:47:03 AM
|
|
 |
|
| |
DiGiTAL.SkReAM
Posts: 1056
Score: 6
Joined: 9/6/2005
From: Florida, USA
Status: offline
|
I searched, and didn't find anything else on this topic, so figured I'd post. If someone else has done this before, I am reasonably certain that some folks will take great pleasure in pointing it out to me. To use an include file in a vbscript, without have to reference it via ASP/HTA/html tags, etc. do the following: The 'include' file can contain any normal vbscript, etc. that you would have in any other .vbs file, including subs and functions. To access the code, set oFile = fso.OpenTextFile(sFileName,1) sText = oFile.ReadAll oFile.close ExecuteGlobal sText And voila, the commands that you had in the include file are ran.
_____________________________
"There's the one man who learns by reading, the two men that learn by watching, and the rest of us have to pee on the electric fence for ourselves." - Roy Rogers "Would you like to touch my monkey?" - Dieter (Mike Meyers)
|
|
| |
|
|
|
 |
RE: Using "Include" files in VBScript Without... - 1/14/2006 7:06:10 AM
|
|
 |
|
| |
Fredledingue
Posts: 297
Score: 0
Joined: 5/9/2005
From:
Status: offline
|
It can be useful for codes that are shared by a large number of vbs. I often use this method to pass parameters. I have in my file for example: x=1 y=2 z=3 string = "my string" ... Then I open this file for reading and do "Execute oFile.readAll". What's the difference between "Execute" and "ExecuteGlobal"?
_____________________________
Fred
|
|
| |
|
|
|
 |
RE: Using "Include" files in VBScript Without... - 3/19/2008 10:16:16 AM
|
|
 |
|
| |
TNO
Posts: 974
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
|
I think this was one of the reasons why script components were invented. Just too bad this is IE only technology.
_____________________________
Consolidated Script Component: Now in Testing stage! A universe of complexity...
|
|
| |
|
|
|
 |
RE: Using "Include" files in VBScript Without... - 3/19/2008 11:26:44 AM
|
|
 |
|
| |
DiGiTAL.SkReAM
Posts: 1056
Score: 6
Joined: 9/6/2005
From: Florida, USA
Status: offline
|
When you say 'too bad this is IE only technology', what exactly are you referring to?
_____________________________
"There's the one man who learns by reading, the two men that learn by watching, and the rest of us have to pee on the electric fence for ourselves." - Roy Rogers "Would you like to touch my monkey?" - Dieter (Mike Meyers)
|
|
| |
|
|
|
 |
RE: Using "Include" files in VBScript Without... - 3/19/2008 11:41:00 AM
|
|
 |
|
| |
TNO
Posts: 974
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
|
Creating a Windows Script component as you know, turns your script into a COM component basically. So, Dim TNO Set TNO = CreateObject("TNO.Framework"); Can be used in the browser, HTML Application and on an ASP page as Server.CreateObject("TNO.Framework") When I say this is IE only, I mean if I used the above in my webpage using JavaScript: var TNO = new ActiveXObject("TNO.Framework"); I don't expect Opera, Safari, FireFox, etc to execute it, forcing me to create a separate library. But, I may have spoken too soon, I haven't tested this yet, but perhaps by using the <object> tag instead and/or GeckoActiveXObject() would still allow sharing the same file across client/server. But of course I have no idea if a .wsc can be used in this manner (not using activeXObject/CreateObject)
_____________________________
Consolidated Script Component: Now in Testing stage! A universe of complexity...
|
|
| |
|
|
|
 |
RE: Using "Include" files in VBScript Without... - 3/19/2008 9:23:08 PM
|
|
 |
|
| |
DiGiTAL.SkReAM
Posts: 1056
Score: 6
Joined: 9/6/2005
From: Florida, USA
Status: offline
|
Actually, I didn't know. hehehe I work pretty exclusively in vanilla vbscript. .WSC, etc. are just random groupings of letters used to form arcane and mysterious filename externsions to me. When i want to get REALLY crazy and wild, I write a .HTA. I thought you were referring to the ExecuteGlobal and Execute commands.
_____________________________
"There's the one man who learns by reading, the two men that learn by watching, and the rest of us have to pee on the electric fence for ourselves." - Roy Rogers "Would you like to touch my monkey?" - Dieter (Mike Meyers)
|
|
| |
|
|
|
|
|