TYL PROGRAMMING LANGUAGE
▶ RECORDS ASSIGNMENT
Assign Record by Function
Consider this code:
go:
gonebook { }
gonebook book
print gonebook
book: { ISBN '' title '' }
{
 ISBN: ''
 title: ''
}
book is a parameterless function that returns a record, and in the assignment line gonebook book, gonebook is assigned a book record by book function.

To assign a record with data, we modify book function:
go:
gonebook {}
gonebook book '978-3-16-148410-0' 'Gone With The Wind'
print gonebook
book isbn title:
result {}
result <- 'ISBN' isbn
result <- 'title' title
result
{
 ISBN: '978-3-16-148410-0'
 title: 'Gone With The Wind'
}
And a Library example:
library { name 'Puerto Natales Library'}
books
library <- 'books' books
go:
addbook '978-3-16-148410-0' 'Gone With The Wind'
addbook '978-3-16-148410-1' 'Gone With Style'
print library
addbook isbn title:
newbook {}
newbook <- 'ISBN' isbn
newbook <- 'title' title
    library.books <- newbook
{
 name: 'Puerto Natales Library'
 books: [ {
 ISBN: '978-3-16-148410-0'
 title: 'Gone With The Wind'
}, {
 ISBN: '978-3-16-148410-1'
 title: 'Gone With Style'
} ]
}
In the last chapter there was a fix duration example. Now let's print the real number of seconds that passed between two calls to now system function:
starttime endtime { totalsecond 0 }
starttime now
pause 1
endtime now
print startspan starttime.totalsecond
print endspan endtime.totalsecond
print endspan - startspan
127613.2075469
127614.2215487
1.01400180000928
In line 'starttime endtime { totalsecond 0 }', we declared two record variables and assigned them a totalsecond property, thus enabling the static access as done in line print startspan starttime.totalsecond.
The line starttime now assigns starttime by the mapping data of now system function. Upon assignment, totalsecond property is updated.
Measurement of program execution duration can be done by using this type of code.
PART 6
PART 8