Sheerpower Logo E.1  Embedded Cluster Templates
A "cluster template" is a cluster whose primary use is as a reference and not for data storage itself. There may be standard variables that you want multiple clusters to contain. For example, the standard address format which includes address line 1, address line 2, city, state, zip code. This address format will be used for the client, the user, and the company clusters. A separate cluster for these variables can be set up as a TEMPLATE that can then be embedded into other clusters. There will be no data stored in this cluster template.

The example below shows the cluster "address" used as a template by other clusters.
cluster address: addr1$, addr2$, city$, state$, zip$ // cluster template cluster client: client_id$, client_name$, cluster address cluster user: login$, name$, cluster address, age cluster company: company_name$, cluster address client->city$ = 'San Diego'
Cluster templates also can be embedded into other clusters and used as JSON OBJECTS as shown in the example below.
cluster name: first$, last$ cluster multi: ssn$, prefix cluster name, tax, is_okay? add cluster multi multi->ssn$ = '222-33-4444' multi->name->first$ = 'Mister2 "they say"' multi->name->last$ = 'Smith2' multi->tax = 45.678 multi->is_okay? = false
To store data into a cluster variable that is part of a JSON object, the cluster name and the cluster template name must both be specified as shown below.
multi->name->first$ = 'Mister' multi->name->last$ = 'Smith'
Adhoc JSON objects can be created without using embedded cluster templates. When defining the cluster, specify the name of the object when describing the variable. The example below will create an object named "address" that describes the address variables to include.

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.
Wide screen