The purpose of this book is to introduce the reader as soon as possible in order to start writing operational programs (games, data visualization and computing programs), and simultaneously lay the foundation in the field of programming, which will be useful to it throughout his life. The book is written for people of any age who had never before programmed on ASMX or have never been programmed at all. If you want to quickly study the basics of programming in order to focus on interesting projects, as well as test your understanding of new concepts on substantive tasks, this book is for you.
In this chapter, you will launch your first program in ASMX, Hello_world.asmx. First you check, ASMX is installed on your computer, and if not, install it.
Part I of this book presents the basic concepts necessary for writing programs in the ASMX language. Many of these concepts are found in all programming languages, so they will be useful to you throughout the career in programming.
In chapter I, you will install ASMX on your computer and run your first program, which displays Hello World's message on the screen!
First of all, we need to install the necessary resources of course))
You should have nodejs v16.15.1 versions, NPM version 8.11.0. Well, Git. (I have 2.36.1 Git version).
git clone https://github.com/langprogramming-AsmX/AsmX.git
npm installAfter that, we are already launching the core:
node kernel.jsAfter that, we will be asked for the path to the file, if you maintain a file of another extension, we will give an error. After indicating the path to the core itself, we can immediately indicate the path to .asmx file. Otherwise, CLI (Command Line Interface) will appear which will ask for the path to the file.
When the ASMX V3 exit, it can be launched on Nodejs V18.16.1 (LTS)
If you have an ASMX third version installed (ASMX V3) or later version, to launch the ASMX code from the terminal, to give the next REPL parameter, as shown in the example:
node kernel.js replRepl - Read Eval Print Loop
The VS CODE installation program can be downloaded to https://code.visualstudio.com/. Click the download link and find the installation program for Windows. After the installation program is loaded, start it and confirm all the default settings.
After the latest versions of ASMX and VS Code are installed in your system, everything is almost ready to launch your first ASMX program written in a text editor. After that, you can write the Hello World program! And start it.
Before writing the program, create a folder with the name asmx_workspace for your projects somewhere in the Svee system.
Open VS Code and save the empty ASMX ( File -> Save as ) file named Hello_world.asmx in the *asmx_workspace folder. *After the file is saved, enter the next line in the text editor:
@call print("Hello world!");Most programs you wrote in a text editor will be launched directly from the editor. Nevertheless, it is sometimes useful to run programs from the terminal - for example, if you just want to complete the finished program without opening it for editing.
This can be done in any system with installed ASMX support; It is only necessary to know the path to the catalog in which the program file is stored. The examples below suggest that you have saved the Hello_world.asmx file in the ASMX_WORKSPACE folder.
The CD (Change Directory) is used to move through the file system in the command line window. The DIR (Directory) team displays a list of all files in the current catalog.
Open a new terminal window and enter the following commands for starting the program HELLO_WORLD.ASMX :
C: > cd Desktop/AsmX_workspace
C: D esktop A smX_workspace > dir
hello_world.asmX
C: D esktop A smX_workspace > node asmx/kernel.js hello_world.asmX
Hello world !The CD command is used to go to the ASMX_WORKSPACE folder in the Desktop folder. Then the Dir team checks that the Hello_world.asmx file is really in this folder. Next, the file is launched by the Node asmx/Kernel.js HELLO_WORLD.ASMX command. Where ASMX is a download folder with GitHub.
Most programs will normally start from the editor. But over time, your work will become more difficult, and perhaps you will prefer to launch some of your programs from the terminal.
The launch of the ASMX program in the terminal session in Linux and MacOS systems is carried out the same. The CD (Change Directory) is used to move through the file system in the terminal session. The IS (List) command displays a list of all unnecessary files in the current catalog.
Open a new terminal window and enter the following commands for starting the program HELLO_WORLD.ASMX:
~$ cd Desktop/AsmX_worspace/
~Desktop/AsmX_worspace/$ ls
hello_world.asmX
~Desktop/AsmX_worspace/$ node asmx/kernel.js hello_world.asmX
Hello world!
The CD command is used to go to the ASMX_WORKSPACE folder in the Desktop folder. Then the LS team checks that the HELLO_world.ASMX file is really in this folder. Next, the file is launched by the Node asmx/Kernel.js HELLO_WORLD.ASMX command. Where ASMX is a download folder with GitHub.
If you were not able to start the Hello_world.asmx program, the following useful tips may help you (by the way, they can come in handy to solve any problems in the programs).
Feel free to contact experienced programmers. Any programmer at some point in his life has come into a dead end; Many programmers will willingly help you correctly configure your system. If you can clearly explain what you want to do, what you have already tried and what results you got, most likely someone will help you. As mentioned in the introduction, the ASMX community is kind to beginners.
ASMX should work normally on any modern computer, and if you still have problems, seek help. At first, the problems can be very unpleasant, but they should deal with them. When the Hello_world.asmx program will work, you can start studying ASMX, and your work will become much more interesting and will bring more pleasure.
Exercises
In this chapter, you got acquainted with the ASMX language and established ASMX support in your system if it was not installed earlier. You also installed a text editor that simplifies the work on the ASMX code. You have learned to perform ASMX code fragments in the terminal session and launched your first real program Hello_world.asmx . Most likely, along the way, you learned something about the search and correction of errors.
The next chapter discusses the data structures with which you will work in ASMX programs. In addition, you will learn how to use ASMX variables.
This chapter presents different types of data with which you will work in your ASMX programs. You will also learn to use variables to present data in your programs.
Let's take a closer look at what ASMX does when starting Hello_world.asmx . It turns out that even for such a simple program, ASMX performs serious work:
HELLO_WORLD.ASMX :
@call print("Hello world!");When performing this code, the next text is displayed:
Hello world!
Suffix .ASMX in the Hello_world.asmx file indicates that the file is the ASMX program.
Let's try to use the variable in the Hello_world.asmx program. Add a new line to the beginning of the file and change the second line:
Hello_world.asmx
@set message String "Hello world!";
@call print(set::message);Run the program and see what happens. The program displays a familiar result:
Hello world!
A variable named Message was added to the program. In each variable, the value is stored, that is, data related to the variable. In our case, the text is the text "Hello World!" .
Adding a variable complicates the task of ASMX a little. During the first line processing, he connects the text "Hello World!" with a variable Message . And when ASMX reaches the second line, it displays a value associated with the name Message to the screen.
Let's expand this program Hello_world.asmx to display a second message. Add to Hello_world.asmx , another line that displays another message.
@set message String "Hello world!";
@call print(set::message);
@call print("Hello AsmX Crash Course world!");
Now, when performing Hello_world.asmx , two lines should appear on the screen:
Hello world!
Hello AsmX Crash Course world!
You can at any time change the value of the variable in your program. ASMX constantly monitors its current state.
When working with variables in the ASMX language, some rules and recommendations must be followed. Violation of the rules will lead to an error, recommendations only help write a more understandable and convenient code.
You do not immediately learn how to create good names variables, especially when your programs will become more difficult and interesting.
Note - For now, limit yourself to the names of the variables recorded in the lower register.
If you only study ASMX, you can skip this item, since this section is useful, those who know the ASMX base or downloaded ASMX V3 or a late version. You can return to this section when you gain ASMX programming experience.
@mut (the name of the instructions was reduced from the English word mutable (variable, changed)).@define you can use @immut .@set and. @define you can use the @mut / @immut ( mutable / immutable ). Since many programs determine and collect certain data, and then do something useful with them, it is advisable to highlight the main varieties of data. Let's start with string data. At first glance, the lines are quite simple, but with them you can work in many different ways.
Lines are a sequence of symbols enclosed in quotation marks. You can enclose them in single or double quotation marks:
"String"
'String'
There is a term Whiteespace which means: printed symbols, like gaps, tabs and symbols of the end of the line.
To include in the text of the tabulation, a combination of symbols t is used, as shown in the example below:
@call print('AsmX')
AsmX
@call print('tAsmX')
AsmX
Whitespace list:
| Code | NAME |
|---|---|
| n | The NewLine Character |
| r | The Cariage Return Character |
| t | The Horizontal Tab Character |
| v | The Vertical Tab Character |
| f | The Form Feed Character |
In programming, there are numbers that are often used in programs for calculations, withdrawal of the game, the presentation of visual data. In ASMX, there are non -numerical data, for the beginning, an examination, as ASMX works with integers, because there are fewer problems with them.
In ASMX with integers, you can perform operations of addition, subtraction, multiplication and division.
@add 9 9
@sub 10 5
@mul 10 2
@div 45 9
@add (Add- Addition) - Addition of numbers
@sub (sub - substration) - subtraction of numbers
@mul (mul - multiplication) - multiplication of numbers
@div (div - division) - division of numbers
Results:
18
5
20
5
To output the result of some kind of calculation action, you need to write:
@call print($ret);
In ASMX numbers having a fractional part, numbers with a floating point are called. Typically, developments can simply use fractional values.
@add 9.8 9.2
Results:
19
In the recording of integers, you can be sad for the numbers with the help of symbols of emphasizing that the numbers are better read:
@add 10_000 78;
@call print(10078); # 10_000 -> 10000
From the point of view, ASMX 1000 is no different from the recording of 10_00 . This recording option works for entire numbers in the ASMX third version and later.
The constant is a variable whose value remains unchanged. In ASMX, it is customary to record the constant names in the upper register:
@define MIN_SCORE 100
Comments are extremely useful in any program, any programming language. As the volume and complexity of the program, the comments describing the actions of the program, or the essence of the implementation, should be added. They can also use a kind of notes written in an understandable language.
In the ASMX language, the commentary is a lattice symbol ( # ). ASMX ignores all the symbols starting with the symbol # to the end of the line. Example:
# Say hello to everyone.
@call print("Hello AsmX people!");
ASMX ignores the first line and performs the second:
Hello AsmX people!
The main task of the commentation is to explain what your code should do and how it works. In the midst of work on the project, you understand how all its components work. But if you return to the project after a while, most likely, you will forget how the program works. Of course, you can always study the code and figure it out, how the program works, but good comments will give you saving time to reading the program.
Exercises