TYL PROGRAMMING LANGUAGE
▶ RECORDS ACCESS & EDIT
Accessing Records
Throughout this chapter we'll use the product record:
product { cat 'Electrical' name 'LED Light Bulb' }
Records are accessed in the dot-notation style:
product.name
But if the record is already declared, the dot can be omitted:
product name
In line: product name, we access the name property of product record, without the dot-notation.
This enables us to use a scalar variable or even a whole statement for the record key:
print product 'cat'
Electrical
product cat value was printed.

Or using dynamic scalar:
key 'cat'
print product key
What if we add name scalar:
print product name
name 'cat'
print product name
LED Light Bulb
LED Light Bulb
In this case, Tyl searches for key: 'name', in product keys. If found, key is: 'name', otherwise, it searches for a name variable. If found, uses its value as key. Then it searches in product for key, and if exists, returns its value. So to access keys by variable, make sure that the variable name doesn't coincide with actual key of the record.

As a good practice, use dot-notation access for known record key.

One case that it isn't possible to use dot-notation, is when record key contains space characters:
shape { 'shape name' Circle 'shape area' 986.96 }
print shape 'shape name'
Circle
An example of a system record is the now system function:
print now
now: {
 year: 2020
 month: 8
 day: 9
 hour: 11
 minute: 52
 second: 33
 millisecond: 371
 totalseconds: 129153.3710013
 weekday: 0
 yearday: 222
 fulldate: '2020-08-09 11:52:33.371'
 }
So to print the real number of seconds that passed between two calls to now function, we would write:
start_time now
pause 1
end_time now

print start_span start_time.totalseconds
print end_span end_time.totalseconds
print end_span - start_span
127613.2075469
127614.2215487
1.01400180000928
PART 1
PART 3