|
-
Apr 29th, 2002, 03:28 PM
#1
Thread Starter
Frenzied Member
VBScript Data Structures
I'm not sure that this is what I want to use, but I was playing with the idea of having a hash with one element being an anonymous array. VBScript doesn't have a push, so I have to work around that. Now I have something that borders on obfuscation.
Code:
<% @Language="VBScript" %>
<%
Option Explicit
Dim myDictionary
Set myDictionary = Server.CreateObject("Scripting.Dictionary")
Dim currItem
myDictionary.Add "myArray", Array(5)
myDictionary.Item("myArray") = Split(Join(myDictionary.Item("myArray"), ",") & "," & 10, ",")
myDictionary.Item("myArray") = Split(Join(myDictionary.Item("myArray"), ",") & "," & 15, ",")
%>
<html>
<head>
<title>Test Page</title>
</head>
<body>
<%For currItem = 0 To UBound(myDictionary.Item("myArray"), 1)%>
<p><%=myDictionary.Item("myArray")(currItem)%></p>
<%Next%>
</body>
</html>
Like I said, I'm not completely sold on the anon array as part of the hash, but it is the best set up so far. Question is, is there an easier way to handle it?
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
Apr 29th, 2002, 05:41 PM
#2
Why not use a object? you can create an object in ASP, and then add each object to the dictionary?
<%
Class Video
Public VideoID
Public CategoryID
Public Title
Public Size
Public AttachmentID
Public Preview
Public ProductID
End Class
%>
Hope this helps,
Joan
-
Apr 29th, 2002, 06:03 PM
#3
Thread Starter
Frenzied Member
Wow, objects in VB, it would be almost like using a real language.
Okay, I am making a report from the log of a systems monitoring tool. The report figures out the time monitored for the day and the time down, the percent up and a host of other metrics.
Right now I have a dictionary of dictionaries.
Code:
dictDays.Item(someDate).Item("TimeMonitored")
I wonder if using objects would make the ASP faster. And since I can't use anonymous names, I wonder what would be the best way to group the objects, a dictionary of objects, an array of objects, or do I build an object with methods to access the group of objects.
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
Apr 30th, 2002, 05:55 PM
#4
Thread Starter
Frenzied Member
Well, now that my ASP is 73KB and growing, it is too late to rewrite it so it is OO. VB/VBScript OO, why? Why not just use a real language? I'll never understand.
Code:
<% @Language="VBScript" %>
<%
Option Explicit
Class Foo
Public Bar
Public Function Hello(strWho)
Response.Write Bar & " says, ""Hello, " & strWho & """"
End Function
End Class
Dim myFoo
Set myFoo = New Foo
myFoo.Bar = "Blah"
%>
<html>
<head>
<title>Test ASP</title>
</head>
<body>
<p><%=myFoo.Hello("1user")%></p>
</body>
</html>
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
Apr 30th, 2002, 06:23 PM
#5
Lucky we have .NET so no more worries about being a real language
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|