Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Accessing enumerated types from vbscript

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,29313
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Accessing enumerated types from vbscript
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1] 2   next >   >>
Login
Message << Older Topic   Newer Topic >>
 Accessing enumerated types from vbscript - 12/26/2005 12:27:18 AM   
  rewster1976

 

Posts: 2
Score: 0
Joined: 12/25/2005
Status: offline
Merry Xmas/Happy Holidays,

I am integrating a third party COM component from pure vbscript. All is working fine and I can interact with the API successfully until I try to access some enumerated types.

    e.g. ProWeb.engine = qasVerification

How can I specify the UUID so that my vbscript recognizes qasVerification. If this were ASP then I would do this as follows:

   <!--METADATA NAME="QuickAddress Pro Web SOAP Proxy" TYPE="TypeLib" UUID="{42F6FD66-C030-4942-840C-58B939EAEDE0}"-->
<%

 
Is there an equivalent to the above statement in pure vbscript?
 
Thanks,
 
Andrew
 
 
Post #: 1
 
 RE: Accessing enumerated types from vbscript - 12/26/2005 5:14:36 AM   
  ehvbs

 

Posts: 2204
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi rewster1976,

if .wsf files qualify as "pure vbscript", then look up "reference" in the VBScript docs.

if not, I'm afraid you'll have to define the Consts by hand. A typelib browser (e.g.
TLViewer by Mark Pryor) may be of help.

(in reply to rewster1976)
 
 
Post #: 2
 
 RE: Accessing enumerated types from vbscript - 12/27/2005 1:42:22 AM   
  rewster1976

 

Posts: 2
Score: 0
Joined: 12/25/2005
Status: offline
Thanks ehvbs,

I am all set now by just specifying the specific values instead of the enumerated types.

I appreciate your quick response to this novice question.

Andrew

(in reply to ehvbs)
 
 
Post #: 3
 
 RE: Accessing enumerated types from vbscript - 10/19/2006 12:59:42 AM   
  javidraaj

 

Posts: 5
Score: 0
Joined: 10/19/2006
Status: offline
I'm also having the same problem. I need to access the the methods and enumerated types from a third party DLL..

How do I do this? Could someone give an example on this. I'm new to VBScript.

Thanks

(in reply to rewster1976)
 
 
Post #: 4
 
 RE: Accessing enumerated types from vbscript - 10/19/2006 2:20:26 AM   
  ginolard


Posts: 1068
Score: 21
Joined: 8/10/2005
Status: offline
Download Visual Studio 2005 Express for Visual Basic (it's free).

Create a new project and add the DLL as a reference.

Open the Object Browser and you'll see all the methods

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to javidraaj)
 
 
Post #: 5
 
 RE: Accessing enumerated types from vbscript - 10/20/2006 2:43:47 AM   
  javidraaj

 

Posts: 5
Score: 0
Joined: 10/19/2006
Status: offline
It works in VB. But not in VBscript.

for ex:
eTypeWeek is defined as enum in the DLL like

enum
{
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday,
Sunday
}eTypeWeek;

then there is a function in dll which takes the enum as the argument.
like this

Function1(eTypeWeek week);

So when I call
Function1 from VB like this

Function1(Monday)
or

Dim varWeek as eTypeWeek
varWeek = Monday
Function(varWeek)

it works fine

But in VBScript

it gives errors saying Monday is not a record type or eTypeWeek is not a record type

So I want to know how do I use this enum in VBScript

Thanks
Raja

(in reply to ginolard)
 
 
Post #: 6
 
 RE: Accessing enumerated types from vbscript - 10/20/2006 2:45:37 AM   
  ebgreen


Posts: 5069
Score: 31
Joined: 7/12/2005
Status: online
I'm pretty sure that the answer is you can't. VBScript does not support enumerations.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to javidraaj)
 
 
Post #: 7
 
 RE: Accessing enumerated types from vbscript - 10/20/2006 5:49:25 AM   
  TNO


Posts: 1302
Score: 12
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
JavaScript offers an Enumerator Object:


      

As for a vbscript solution to Enumerating, I've seen an Enumerate()  method floating around the web but I've never used it since I generally use JavaScript first for my projects. But here is what I've seen about this elusive idea:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winrm/winrm/enumerator.asp

Otherwise maybe this idea may help:

strComputer = "."
Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objDisks = objWMI.InstancesOf("Win32_LogicalDisk")
For Each objDisk In objDisks
WScript.Echo "DeviceID: " & objDisk.DeviceID
WScript.Echo "FileSystem: " & objDisk.FileSystem
WScript.Echo "FreeSpace: " & objDisk.FreeSpace
WScript.Echo "Name: " & objDisk.Name
WScript.Echo "Size: " & objDisk.Size
WScript.Echo ""
Next

_____________________________

To iterate is human, to recurse divine. -- L. Peter Deutsch

(in reply to ebgreen)
 
 
Post #: 8
 
 RE: Accessing enumerated types from vbscript - 10/20/2006 6:02:03 AM   
  ebgreen


Posts: 5069
Score: 31
Joined: 7/12/2005
Status: online
I think the terms a little fuzzy. Enumerator = an Iterator. Enum = a Struct. You can create an Enumerator in vbscript to iterate through the contents of a collection. You can also create an Enumerator to iterate through the results of a Pull operation in ASP (the link that TNO provided). As far as I know however, neither VBScript nor JavaScript support Enums.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to TNO)
 
 
Post #: 9
 
 RE: Accessing enumerated types from vbscript - 10/20/2006 6:23:07 AM   
  TNO


Posts: 1302
Score: 12
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
Hold on.....now I'm getting confused too, lol

quote:

create an Enumerator to iterate


The whole concept of Iterating and Enumerating are different so I'm getting a bit lost here.

Iterating relies on an index value to work whereas an Enumerator does not.

Iteration: for (variable in [object | array])

vs

Enumeration: new Enumerator(fso.Drives);  for (;!e.atEnd();e.moveNext())

So what do you mean by not supporting Enumerators? Where are we differing in our definitions?

_____________________________

To iterate is human, to recurse divine. -- L. Peter Deutsch

(in reply to ebgreen)
 
 
Post #: 10
 
 RE: Accessing enumerated types from vbscript - 10/20/2006 6:29:35 AM   
  ebgreen


Posts: 5069
Score: 31
Joined: 7/12/2005
Status: online
You are correct that Iterating relies on an index, so my description was not entirely precise. Regardless, there is a difference between an Enumerating a collection (To count or list one by one) vs. an Enumerated type (aka enum - A type which includes in its definition an exhaustive list of possible values for variables of that type).

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to TNO)
 
 
Post #: 11
 
 RE: Accessing enumerated types from vbscript - 10/20/2006 6:49:47 AM   
  TNO


Posts: 1302
Score: 12
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
quote:

enum - A type which includes in its definition an exhaustive list of possible values for variables of that type


So a collection of array objects for example?

_____________________________

To iterate is human, to recurse divine. -- L. Peter Deutsch

(in reply to ebgreen)
 
 
Post #: 12
 
 RE: Accessing enumerated types from vbscript - 10/20/2006 6:55:04 AM   
  TNO


Posts: 1302
Score: 12
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
By array collection I mean an associative array collection

_____________________________

To iterate is human, to recurse divine. -- L. Peter Deutsch

(in reply to TNO)
 
 
Post #: 13
 
 RE: Accessing enumerated types from vbscript - 10/20/2006 7:04:57 AM   
  DiGiTAL.SkReAM


Posts: 1184
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: offline
At this point, it just seems to me like you guys are in a contest to see whose dictionary is toughest.
Or possibly a forum-obfuscation contest?  heh heh



_____________________________

"Would you like to touch my monkey?" - Dieter (Mike Meyers)

"It is better to die like a tiger, than to live like a pussy."
-Master Wong, from Balls of Fury

(in reply to TNO)
 
 
Post #: 14
 
 RE: Accessing enumerated types from vbscript - 10/20/2006 7:16:05 AM   
  TNO


Posts: 1302
Score: 12
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
After a bit more research I figured out what the difference was. So to get back to the subject at hand, ebgreen is right that vbscript doesn;t support enumerations. But JScript (ECMAScript Edition 4) DOES contain enum . So it MAY be possible through WSH. problem is I have yet to see a usage of enum outside of JScript .NET, so I'll have to dig around for a bit

_____________________________

To iterate is human, to recurse divine. -- L. Peter Deutsch

(in reply to DiGiTAL.SkReAM)
 
 
Post #: 15
 
 RE: Accessing enumerated types from vbscript - 10/20/2006 7:26:02 AM   
  ebgreen


Posts: 5069
Score: 31
Joined: 7/12/2005
Status: online
Here is a demonstration of the difference:

      

With that enum, in your code you could use TimeOfDay.Afternoon and the compiler would replace it with 1. Contrast that with implementing an enumerator. In C# when you do a foreach loop, it is simply shorthand for this code:


      

This code would enumerate through a collection of strings and DoSomething() with each one.

I think the first example (enum) is what the OP needs and is not supported in VBScript.

EDIT(EBGREEN): Corrected my code tag incompetence.

< Message edited by ebgreen -- 10/23/2006 8:42:01 AM >


_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to DiGiTAL.SkReAM)
 
 
Post #: 16
 
 RE: Accessing enumerated types from vbscript - 10/23/2006 7:37:43 AM   
  javidraaj

 

Posts: 5
Score: 0
Joined: 10/19/2006
Status: offline
So the final answer is in VB Script we cannot use the enum types. So I have to use Jscript or something else

Thanks

(in reply to ebgreen)
 
 
Post #: 17
 
 RE: Accessing enumerated types from vbscript - 12/4/2006 8:03:42 PM   
  TNO


Posts: 1302
Score: 12
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
I think we need another look at this concept, look what I found on MSDN:

"To use enumerated types when composing VBScript or JScript script files, copy the relevant constant definitions from the relevant"... "file to the constant declarations in your code."

For example, include the following code in the declarations section of your script:


      

The declaration of constants allows you to write the following:


      

If you always declare the appropriate constants in your declarations section at the beginning of each script, you can use enumerated types as you use them in C++ programs.

Alternatively, you can achieve the same effect by hard-coding the values, as shown in the following code:


      

These lines will perform the same task as the previous code lines, without the use of enumerated types.

When composing Windows script (.wsf) files that will run in a Windows Script Host environment, the constants can be included by including a <reference> element. The following code example, which displays the name of each network rule defined for the local computer followed by the value of its RoutingType property, shows how to include the ISA Server administration COM library in a .wsf file:


      

< Message edited by TNO -- 12/4/2006 8:08:59 PM >


_____________________________

To iterate is human, to recurse divine. -- L. Peter Deutsch

(in reply to javidraaj)
 
 
Post #: 18
 
 RE: Accessing enumerated types from vbscript - 12/5/2006 2:39:02 AM   
  ebgreen


Posts: 5069
Score: 31
Joined: 7/12/2005
Status: online
I would consider that to be a work around. It will get the job done but you still are not using the enum.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to TNO)
 
 
Post #: 19
 
 RE: Accessing enumerated types from vbscript - 12/5/2006 4:05:46 AM   
  ehvbs

 

Posts: 2204
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi ebgreen,

doesn't count "rule.AccessProperties.AppliesToContentMethod = fpcAppliesToAllContent" or
"Case fpcRoute" as 'using the enum'? What would you consider a 'real' solution - as opposed to
'work around'?

(in reply to ebgreen)
 
 
Post #: 20
 
 
Page:   [1] 2   next >   >>
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Accessing enumerated types from vbscript Page: [1] 2   next >   >>
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts