# ACPL Tutorial This tutorial will help you learn ACPL. ACPL is a compiled programming language made by **[@RJmsG](https://github.com/RJmsG)** on GitHub, which stands for **A**xe's **C**omplicated **P**rogramming **L**anguage. They originally wanted to name it ASPL (**A**xe's **S**imple **P**rogramming **L**anguage), but the name ACPL stuck. ## Getting Started To get started with ACPL, you will need a compiler. For this tutorial, we will use TSCPL (**T**ype**S**cript **C**ompiled **P**rogramming **L**anguage), which compiles ACPL files to TypeScript. To install TSCPL, make sure you have npm installed. After you have verified you have npm installed, run the following command in your terminal: ```bash npm install -g tscpl ``` Now that you're done installing TSCPL, you need to create a `main.acpl` file in the folder you installed TSCPL in. ## Printing to Console To print to the console, just use this syntax: ``` outln "Hello world!" ``` Save this to your `main.acpl` file you created earlier, and run the following command, which we'll also use to compile ACPL files later in this tutorial: ```bash npx tscpl main.acpl --run ``` If it outputs `Hello world!` in the end, congradulations! You have compiled your first ACPL program! ## Variables Now that you have learned how to print to the console, let's learn about variables! Variables are used for storing importatnt data that you want to retrieve later in a script. ### Strings To save a string as a variable, use this syntax: ``` str string "Hello world!" ``` ### Numbers To save a number as a variable, use this syntax: ``` int number 0 ``` ### Decimal To save a decimal as a variable, use this syntax: ``` dec decimal 0.1 ``` Save this to your `main.acpl` file, and compile it. ## Printing Variables to Console You might realize that you can't print a variable with `outln`, this is where `outs` and `outi` comes in! ### Printing a String Variable To print a string variable, use this syntax: ``` str string "Hello world!" outs string ``` ### Printing a Number or a Decimal Variable In TSCPL, numbers and decimals are treated the same way, meaning that both numbers and decimals would have the `number` type. To print a number or a decimal variable, use this syntax: ``` # Printing a number int number 0 outi number # Printing a decimal dec decimal 0.1 outi decimal ``` ## Comments Let's say you need to describe a specific line of code that you want it to be seen on the code side, this is where comments come in! To make a comment, use this syntax: ``` # This is a comment! The user running the code won't see this, but you can see this if you are directly viewing the ACPL file! outln "Bet you didn't see what was above me!" ``` ## Importing a ACPL file Importing a ACPL file is very easy, however, to use this syntax, you have to mark a ACPL file as a module first: ``` module func print_hello_world : outln "Hello world!" ; ``` When TSCPL notices the first line has a `module` statement, it will mark all of it's functions, unless if a function starts with a underscore, as exportable, letting the compiled code import the compiled module! Save the code above as `hello_world.acpl`, and use the following syntax for your `main.acpl` file: ``` import hello_world.acpl print_hello_world ``` Compile `main.acpl`, and once it's finished compiling, you'll notice that two files have been compiled, your main ACPL file, and your "Hello world!" ACPL file. When TSCPL runs the compiled code, you should see it print "Hello world!" to the console. ## Functions Let's say you have some code that you want to run over and over again. Instead of doing this: ``` str name "John Doe" outs name str name "Jane Doe" outs name # And so on... ``` ...You can use a function! ``` func print_name name : outs name ; print_name "John Doe" print_name "Jane Doe" ``` Much more smaller! ## Exit codes :::warning This is not a standard ACPL statement. Only TSCPL can run this statement. ::: Does your code have to fail when, for example, when a condition is not met? You might need a exit code! To use exit codes, use this syntax: ``` # A exit code with 0 (success) exit 0 ``` ``` # A exit code with 1 (failure) exit 1 ``` ## Conclusion Congradulations! You now know how to write a program in ACPL!