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
B
4
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
B
29
S
11
G
12
Posts: 281
Reputation: 11,868

Post » Thu Jun 21, 2012 10:49 pm

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


Return to How do I....?

Who is online

Users browsing this forum: Rezzon71, tarek2 and 22 guests