Skip to main content
gamedev.net
🔒 Locked

[web] ASP/Javascript "Scripting.Dictionary"

Started by NumberXaero Apr 6, 2009 at 5:58 PM 1 replies 1.9k views
Original Post
NumberXaero
NumberXaero
I dont do much web dev stuff so there is probably a pretty simple reason for this but I dont know what it is

var lookup = Server.CreateObject("Scripting.Dictionary");
lookup.Add("aaa", "Apple");
lookup.Add("bbb", "Bread");
lookup.Add("ccc", "Chicken");
lookup.Add("ddd", "Duck");

// this doenst works?
//var find = new String("ccc");  
//var found = lookup.Exists(find);  // whenever var is passed cant find it

// this does
var found = lookup.Exists("ccc");

if(found) {
	Response.Write("Found " + find);
}
else {
	Response.Write("Did Not Find " + find);
}

whats the reason for this, is there a way to pass what I want to check for to Exists() in a var?
Wan
Wan
I have never heard of the existence of String in ASP (the old scripting version that is). But I've never used JScript in ASP (always the 'default' VBScript).

A guess would be that that an object "ccc" is of a different type than a string "ccc", and therefor they are not equal. Have you tried this:
var find = "ccc"; // no explicit string typevar found = lookup.Exists(find);
NumberXaero
NumberXaero
Yes, that worked, but now Im trying to use what was typed into a text box as the value to find.

// ... fill the dictionary// ... print the values (i know they are in there)var v = Request.QueryString("lettersTextBox");  // find this, <form><input type=text">Response.Write("Value typed: " + v + "
"); // correct, and in the dictionaryvar found = lookup.Exists(v);Response.Write("Lookup returned: " + found + "
"); // false here everytime?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.