|
Using Clusters as a programming dictionary |
The code below demonstrates using a Sheerpower cluster as a Data Dictionary.
Program Explanation:
1. Comments:
The comments explain the purpose of the program and highlight that any variable within a cluster can be used as a key to look up values.
2. Cluster Definition:
A cluster named capitals is defined to store country names and their corresponding capital cities. The fields in the cluster are country$ and city$.
3. Adding Data:
The program adds entries to the capitals cluster:
USA with the capital Washington, D.C.Germany with the capital BerlinChina with the capital Beijing4. Searching by Key:
The program searches the capitals cluster for the row where the country$ field matches Germany. If found, it prints the corresponding capital city.
5. Searching by Value:
The program then searches the capitals cluster for the row where the city$ field matches Beijing. If found, it prints the corresponding country name.
|
Hide Description
|
|
|
Enter or modify the code below, and then click on RUN |
|
Looking for the full power of Sheerpower?
Check out the Sheerpower website. Free to download. Free to use. |