Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > server-side JavaScript: Example 3: Dictionary class

Reply
Thread Tools

server-side JavaScript: Example 3: Dictionary class

 
 
GVDC
Guest
Posts: n/a
 
      06-28-2008
Example server-side JavaScript Web script, Dictionary class


//Dictionary class, hash array unlimited length configurable speed/efficiency
//
printf("<html><body>");

printf("<b>Creating dictionary</b><br\n>");

var dictobj = new Dictionary(5); //dictionary class
var dvname = "varnam0"; //dict var name

var smplobj = new Object(); //create object
smplobj.xx = "text1"; //add properties
smplobj.yy = "text2";

printf("<b>Storing object into dictionary</b><br\n>");
printf("<br\n>");
//put object into array
dictobj.set(dvname,smplobj);

printf("<b>Reading value stored in dictionary</b><br\n>");
printf("value of " ,dvname, " property xx: [", dictobj.get(dvname).xx, "]<br\n>");
printf("<br\n>");

printf("<b>Changing property xx value to otherval567</b><br\n>");

//values in dictionary are stored by reference, not copy
//modifying value of object's property also changes value stored in dictionary
smplobj.xx = "otherval567";

printf("value of " ,dvname, " property xx after change: [", dictobj.get(dvname).xx, "]<br\n>");
printf("<br\n>");


printf("<b>Checking array (dictionary) length</b><br\n>");
printf("array length: [", dictobj.len(), "]<br\n>");
printf("<br\n>");

printf("<b>Deleting value from array</b><br\n>");
//erase value from dictionary
dictobj.set(dvname,null);

printf("array length after delete: [", dictobj.len(), "]<br\n>");


printf("</body></html>");



--






 
Reply With Quote
 
 
 
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      06-28-2008
GVDC wrote:
> Example server-side JavaScript Web script, Dictionary class


Example client-side JavaScript, complete Idiot "class":

function Idiot()
{
var value = "GVDC";
this.who = function() { return value; };
}

window.alert((new Idiot()).who());

<http://jibbering.com/faq/>


PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Performance ordered dictionary vs normal dictionary Navkirat Singh Python 6 07-29-2010 10:18 AM
Re: Performance ordered dictionary vs normal dictionary Chris Rebert Python 0 07-29-2010 06:11 AM
creating a dictionary from a dictionary with regex james_027 Python 1 08-22-2007 07:39 AM
[DICTIONARY] - Copy dictionary entries to attributes Ilias Lazaridis Python 6 02-21-2006 11:27 AM
Nested Class, Member Class, Inner Class, Local Class, Anonymous Class E11 Java 1 10-12-2005 03:34 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57