Shoutbox

Enumeration? - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: Enumeration? (/showthread.php?tid=85978)

Enumeration? by Zero on 09-16-2008 at 07:29 PM

Hi folks, I guess this is just a basic programming question, but I've been reading the MSDN doc's on JScript's enumeration object and am having troubles 'getting it'.

In my specific scenario, I've opened a connection to a database using the ADODB object. That object has a property called State, which has several values to indicate what's going on with the connection - adStateOpened, adStateClosed, etc, all of type "ObjectStateEnum".

I know the numeric values for these constants, but don't want to have to refer to them as numbers as that's less meaningful than using the given enumerated names. What do I need to do to have access to them in my script??? So, for example, I could write:

code:
if (objDBHandle.State == adStateOpened) { ... }


Instead of...

code:
if (objDBHandle.State == 1) { /* Opened state */ ... }


or...

code:
var _adStateClosed = 0;
var _adStateOpened = 1;
/* ... more states ... */

if (objDBHandle.State == 1) { /* Opened state */ ... }


Ideas?





RE: Enumeration? by vaccination on 09-16-2008 at 07:51 PM

code:
var _adStateClosed = 0;
var _adStateOpened = 1;
/* ... more states ... */

if (objDBHandle.State == _adStateOpened) { /* Opened state */ ... }



will work

RE: Enumeration? by TheSteve on 09-18-2008 at 12:44 AM

Can you use the enum statement (not sure if plus uses JScript .NET)?

http://msdn.microsoft.com/en-us/library/y94acxy2(VS.71).aspx


RE: Enumeration? by ShawnZ on 09-18-2008 at 01:09 AM

quote:
Originally posted by TheSteve
(not sure if plus uses JScript .NET)?

it doesn't. you can't.