© Tyl Software Foundation 2019-2021
▶ ACCESS & EDIT RECORDS
Adding/Removing Record Keys
To add a static record key to a record:
country { name 'Palau' }
location { long 135 lat 7.5 }
country <- 'location' location
print country.location
{
long: 135
lat: 7.5
}
long: 135
lat: 7.5
}
In line
To add a dynamic record key to a record:
country <- 'location' location
, we added an already declared
location
record as the initial value of country.location
property.
To add a dynamic record key to a record:
country { name 'Palau' }
country <- location { long 135 lat 7.5 }
print country 'location'
{
long: 135
lat: 7.5
}
long: 135
lat: 7.5
}
In line
country <- location { long 135 lat 7.5 }
, an inline declared location
record will be used as country location
property data, meaning that the
property name will be 'location', and the value will be location
mapping
data.
Editing Record Keys
Consider this code:
country { name 'Palau' }
! adding static and dynamic record keys to country record
staticloc { long 135 lat 7.5 }
country <- 'staticloc' staticloc
country <- dynamicloc { long 135 lat 7.5 }
print country
print
! editing staticloc property
print 'set staticloc long value to: ' + country.staticloc 'long' 'X'
print 'removed staticloc lat property: ' + country.staticloc 'lat' ->
! editing dynamicloc property
temp { long 0 }
temp country 'dynamicloc'
print 'set dynamicloc long value to: ' + temp.long 'Y'
print 'set dynamicloc long value (dynamic access) to: ' + temp 'long' 'Y'
print 'removed temp lat property: ' + temp 'lat' ->
country 'dynamicloc' temp
print
print country
{
name: 'Palau'
staticloc: {
long: 135
lat: 7.5
}
dynamicloc: {
long: 135
lat: 7.5
}
}
set staticloc long value to: X
removed staticloc lat property: 7.5
set dynamicloc long value to: Y
set dynamicloc long value (dynamic access) to: Y
removed temp lat property: 7.5
{
name: 'Palau'
staticloc: {
long: 'X'
}
dynamicloc: {
long: 'Y'
lat: 7.5
}
}
name: 'Palau'
staticloc: {
long: 135
lat: 7.5
}
dynamicloc: {
long: 135
lat: 7.5
}
}
set staticloc long value to: X
removed staticloc lat property: 7.5
set dynamicloc long value to: Y
set dynamicloc long value (dynamic access) to: Y
removed temp lat property: 7.5
{
name: 'Palau'
staticloc: {
long: 'X'
}
dynamicloc: {
long: 'Y'
lat: 7.5
}
}
country.staticloc
record was added statically, therefore it can
be accessed and edited directly.
Editing
country dynamicloc
record key is done by assigning it to a temporary
temp
record variable, editing it, and then assigning back to
country dynamicloc
key.
In line
country 'dynamicloc' temp
, temp
record is assigned to
country dynamicloc
record, but as seen in the results, though temp lat
key was removed, it still exists in country dynamicloc
. This is because
the assignment is a merger between the mapping data of the records.