Some basic help with dictionaries

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
Yukiko
Distro Developer
Posts: 2826
Joined: Thu Feb 02, 2006 1:41 pm

Some basic help with dictionaries

Post 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.
User avatar
Austin
Former Developer
Posts: 621
Joined: Wed Jan 25, 2006 2:30 am

Post 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.
Yukiko
Distro Developer
Posts: 2826
Joined: Thu Feb 02, 2006 1:41 pm

Post 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.
Post Reply