TYL PROGRAMMING LANGUAGE
▶ BUILD & RUN TYL PROGRAMS
After a program is loaded to launcher, either by clicking directly on the program file in File Explorer, launching it by Tyl Command Line Tool, or even running it as a Tyl process from another Tyl program, it is built and run by Tyl System, thus starting the build & run process.

Let's create a program 'songplayer.standalone.tyl', with the following code and run:
!====  module statements section  =================
!----  sound statements section  -----------------
soundfreq accord { }
notefactor math.power 2 1 / 12
la4pitch 440
la4key 49
! set keyind so that LA4 value will be la4key
keyind 43
addfreq MI4 keyind ++ 1
addfreq FA4 keyind ++ 1
addfreq SOLB4 keyind ++ 1
addfreq SOL4 keyind ++ 1
addfreq LAB4 keyind ++ 1
addfreq LA4 keyind ++ 1
addfreq SIB4 keyind ++ 1
addfreq SI4 keyind ++ 1
addfreq DO5 keyind ++ 1
addfreq REB5 keyind ++ 1
addfreq RE5 keyind ++ 1
addfreq MIB5 keyind ++ 1
addfreq MI5 keyind ++ 1
addfreq FA5 keyind ++ 1
accind 0
AFA accind ++ 1
ADO accind ++ 1
ASOL7 accind ++ 1
AREM accind ++ 1
ALAM accind ++ 1
AMI7 accind ++ 1
fanotes FA4 LA4 DO5 LA4
accord <- AFA fanotes
donotes SOL4 DO5 MI5 DO5
accord <- ADO donotes
sol7notes SOL4 SI4 RE5 FA5
accord <- ASOL7 sol7notes
remnotes FA4 LA4 RE5 LA4
accord <- AREM remnotes
lammnotes LA4 DO5 MI5 DO5
accord <- ALAM lammnotes
mi7notes MI4 LAB4 SI4 RE5
accord <- AMI7 mi7notes
!----  sound statements section end  -----------------
tempo 320
song { }
elritmoaccords ALAM AREM ALAM AMI7, ADO ASOL7 AFA AMI7
song <- 'El Ritmo' elritmoaccords
elcarreteroaccords AMI7 AFA AMI7 AFA, AMI7 AFA AMI7 AFA, AREM AFA AREM AMI7, AREM AFA ADO AMI7
song <- 'El Carretero' elcarreteroaccords
!====  module functions section  =================
go:
 ! if TESTMODE is TRUE, the system plays only one
 ! note and prints a message in the result box.
 ! to enable regular activity, set TESTMODE to
 ! FALSE (TESTMODE \f)
TESTMODE \t
TESTMODE ?
  print 'Test Mode!'+ newline + newline + 'playing middle LA note'
  playkey LA4
  \
  playrepeated 'El Ritmo' 2
  playrepeated 'El Carretero' 1
^
playrepeated name num: i num ~ playsong name
!----  sound functions section  -----------------
addfreq num: soundfreq <- num math.ceil la4pitch * math.power notefactor num - la4key
playkey num: beep ( soundfreq num ) tempo
playsong name:
print 'Playing song `' + name + '`'
accords song name
accords acckey ~
  notes accord acckey
  notes note ~ playkey note
^
!----  sound functions section end  -----------------
Upon running the program, build & run process were executed, where system functionalities like beep were activated, and user interface activities like print were executed.

Tyl Application Running Modes
Foreground Application
application is run in Tyl Launcher, and all its activities are handled
Background Application
application is run by Tyl Launcher, but the user interface is not shown and all user interface activities are disabled
Fast Application
same as background application, and additionally all system interactivity is also disabled
While debugging or if user interface activity is needed, Tyl Launcher window is shown and you can run the application in it. This type of running an application will be described as running the application in the foreground.

If the application does not have any user interface activity, or if we decide to disregard these activities, it can be run as a background application, and will execute all activities except user interface activities.

If we can run the application in the background, decide to disregard or do not need to pause program running, and exit means stopping the application, then we can run it as fast application.

We can not use Tyl Launcher window to run an application in the background and fast modes. The way to do this is by using the Tyl Command Line Tool or creating an appropriate executable program and running it.

Usually, it takes multiple times of debugging and running to bring a code to a stable running state. So, let's tackle the system with some errors:
.
T Y L  S Y S T E M  2.2 

Wednesday, 13 October 2021
6:05:48 PM

While compiling the program, an error
occurred with the following details:

invalid statement!

statement: .
Obviously, the system does not reconize the text '.' as a valid programmatic code, and an error message is shown in the run box.

This type of error is called compile time error, where in the build stage, the system can't interpret a section of a code. In these cases it sets the color of build indicator to red, and shows the error message.

In cases where you want to verify that the code can be built successfuly click build, and the system will build the code. If built successfully, build indicator will have its ok color, and run indicator color will be blank.

Let's try running this code:
print 1 / 1
! initiating a runtime error
print 1 / 0
1

T Y L  S Y S T E M  2.2 

Wednesday, 13 October 2021
6:13:21 PM

While running the program, an error
occurred with the following details:

division by zero!
After a successful build comes run stage where the system runs the code. The above code is composed of two statements that are executed successively, and in the second statement a division by zero error occurs. We can see that the error message comes after a successful execution of the first statement.

This type of error is called runtime error, whereupon run indicator color will be set to red, and an error message will be appended to the text in the run box.