Page 1 of 1

Some basic help with dictionaries

Posted: Mon Aug 14, 2006 10:59 pm
by Yukiko
I am ashamed to admit that I have never worked with dictionaries (the software kind ofcourse), atleast that I know of.

Can I have an example of how one builds a dictionary and how the elements in the dictionary are addressed/accessed?

Thanks.

Posted: Tue Aug 15, 2006 3:47 am
by Austin
Think of it like an array, but the index can be anything.

http://poldoc.fem.tu-ilmenau.de/pol096/ ... Dictionary


Example:

Code: Select all

var my_var := dictionary;
my_var["kiko"] := "Learning Dicts.";
my_var[mobile_ref] := my_var["Kiko"];
You can check the existance of something with
if ( dictionary.Exists(key) ) or if ( dictionary[key] )

Associative arrays is another way to describe them.

Posted: Tue Aug 15, 2006 2:05 pm
by Yukiko
Thanks Austin.

I have been familiar with various structured data types having programmed in everything from TRSDOS BASIC to Pascal and Delphi but for some reason (perhaps age? Nah! not that!) I just have trouble grasping dictionaries.