Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 21st, 2004, 12:26 AM
Registered User
 
Join Date: Sep 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Enums

Hi,
My question is can I use Enums(Enumerator) in ASP2.0? If the answer is "yes" then I am sure you will send me an example as well.
my email: [email protected]

Thanks,
Vikas
 
Old September 21st, 2004, 01:06 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 331
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to qazi_nomi
Default

The following example shows the behavior of enumerations

enum CarType {
   Honda, // Value of zero, since it is first.
   Toyota, // Value of 1, the successor of zero.
   Nissan // Value of 2.
}

// Declare a variable of type CarType, and give it the value Honda.
var myCar : CarType = CarType.Honda;
print(int(myCar) + ": " + myCar);

myCar = "Nissan"; // Change the value to "Nissan".
print(int(myCar) + ": " + myCar);

myCar = 1; // 1 is the value of the Toyota member.
print(int(myCar) + ": " + myCar);
The output of this code is:

0: Honda
2: Nissan
1: Toyota


Example 2

// Explicitly set the type to byte, as there are only a few flags.
enum FormatFlags : byte {
   // Can't use the default values, since we need explicit bits
   ToUpperCase = 1, // Should not combine ToUpper and ToLower.
   ToLowerCase = 2,
   TrimLeft = 4, // Trim leading spaces.
   TrimRight = 8, // Trim trailing spaces.
   UriEncode = 16 // Encode string as a URI.
}

function Format(s : String, flags : FormatFlags) : String {
   var ret : String = s;
   if(flags & FormatFlags.ToUpperCase) ret = ret.toUpperCase();
   if(flags & FormatFlags.ToLowerCase) ret = ret.toLowerCase();
   if(flags & FormatFlags.TrimLeft) ret = ret.replace(/^\s+/g, "");
   if(flags & FormatFlags.TrimRight) ret = ret.replace(/\s+$/g, "");
   if(flags & FormatFlags.UriEncode) ret = encodeURI(ret);
   return ret;
}

// Combine two enumeration values and store in a FormatFlags variable.
var trim : FormatFlags = FormatFlags.TrimLeft | FormatFlags.TrimRight;
// Combine two enumeration values and store in a byte variable.
var lowerURI : byte = FormatFlags.UriEncode | FormatFlags.ToLowerCase;

var str : String = " hello, WORLD ";

print(trim + ": " + Format(str, trim));
print(FormatFlags.ToUpperCase + ": " + Format(str, FormatFlags.ToUpperCase));
print(lowerURI + ": " + Format(str, lowerURI));
The output of this code is:

12: hello, WORLD
ToUpperCase: HELLO, WORLD
18: %20%20hello,%20world%20%20




Numan
--------------------------------------------------
Love is the most precious thing of this world. So find it and grab it!
 
Old September 21st, 2004, 01:18 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Now that doesn't look like classic ASP (2) to me......

It looks like JScript.NET.....

(http://msdn.microsoft.com/library/de.../jsstmenum.asp)

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Enums VS Structs MoDulus Intro Programming 4 January 19th, 2012 10:42 AM
Enums.cs allanhu BOOK: ASP.NET Website Programming Problem-Design-Solution 3 November 2nd, 2004 10:37 PM
working with enums & properties miguel.ossa C# 2 January 22nd, 2004 04:16 AM
Enums for accounts??? rcarter BOOK: ASP.NET Website Programming Problem-Design-Solution 3 November 8th, 2003 12:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.