﻿ RECORD FUNCTION PARAMETERS
TYL PROGRAMMING LANGUAGE
▶ RECORD FUNCTION PARAMETERS
Using Records in Functions
Consider this program:
``` location { long 31.50 lat 34.75 } go:  print location  set 85.78 28.35  print location set long lat:  location.long long  location.lat lat ```
location: {
long: 31.5
lat: 34.75
}
location: {
long: 85.78
lat: 28.35
}
In `set` function, `location` record is set by `long` and `lat` parameters.

Passing a key to `reset` function:
``` location { long 31.50 lat 34.75 } go:  print location  reset 'lat'  print location reset key:  location key 0 ```
location: {
long: 31.5
lat: 34.75
}
location: {
long: 31.5
lat: 0
}
In line: `reset 'lat'`, we pass the key to the `reset` function, that will set the value of 'lat' key to: 0.

And to reset all keys of `location` record:
``` location { long 31.50 lat 34.75 } go:  print location  reset location  print location reset rec:  rec.long 0  rec.lat 0 ```
location: {
long: 31.5
lat: 34.75
}
location: {
long: 0
lat: 0
}
In line: `rec.long 0`, `rec` is the function parameter that gets `location` record, and sets `long` key to: 0.

Attention: If a record is unknown, using dot-notation is mandatory!

If we write: `rec long 0`, `rec` will not be considered a record!

And to summerize this chapter, here is a full record parameters functionality:
``` location { long 31.50 lat 34.75 } go:  reset location  set_kv 'long' 100  set_rkv location 'lat' 200  add_key location 'height' 4484  invert  print location reset rec:  rec.long 0  rec.lat 0   set long lat:  location.long long  location.lat lat set_kv key val: location key val set_rkv rec key val: rec.key val add_key rec key val: rec.key val invert:  long 360 - location.long  lat 360 - location.lat  set long lat ```
location: {
long: 260
lat: 160
height: 4484
}
PART 3
PART 5