len(Dictionary.try_login) usage

Get help using Construct 2

Post » Thu Jun 21, 2012 8:29 am

Hello everyone,

I'd assume this is a bug, but as I'm new around here I decided to ask whether or not it's me doing something wrong :)

So, the case is that I'm receiving a string via AJAX and saving it to my dictionary:

[AJAX] On "try_login" completed -> [Dictionary] Add key "try_login" with value AJAX.LastData

Then, as a sub-event (fired after the value is stored) i want to check if the received value has more than three characters. This is where my problem starts, because selecting Dictionary->Compare value won't allow me to compare len() to a number (even though there is a "Greater than" option below). Even the below setup throws a "Type mismatch" error disallowing comparison

I'm not sure that is the intended way :) Please let me know if it's me missing something or is it an actual bug, thanks!messmaker2012-06-21 09:02:35
Posts: 8
Reputation: 666

Post » Thu Jun 21, 2012 2:18 pm

I think you're mis-using the dictionary compare value action.
Instead, use the system Compare two values action to test the length of a value retrieved from the dictionary.

This event sheet shows both how to find the length and a proper use of the dictionary compare value action.

If you want it for some reason: DictionaryCompare.capx

(Another thing to keep in mind is that dictionary keys must be strings, so you may run into type mismatches if not careful.)kittiewan2012-06-21 14:19:17
Posts: 281
Reputation: 12,448

Post » Thu Jun 21, 2012 10:49 pm

Sounds and works like a charm, thanks a lot!
Posts: 8
Reputation: 666

Return to How do I....?

Who is online

Users browsing this forum: hendi544 and 5 guests