Skip to content
English

The command line

The algorizm command

Command What it does
algorizm starts the interactive mode
algorizm dastur.alg runs a program
algorizm dastur.alg bir ikki runs a program and passes it the words that follow
algorizm --versiya prints the version
algorizm --yordam prints a short description of the command

Running a program

A program is a UTF-8 text file with the extension .alg. It is compiled and run in one step; no other files are created.

algorizm salom.alg

The words after the file name are available to the program as the list tizim.argumentlar:

import tizim

chiqar(tizim.argumentlar)
chiqar(tizim.versiya, tizim.muhit("YOQ_OZGARUVCHI"))
Output
[]
0.1.0 bo'sh

When the program ends, the command returns an exit code to the system:

Code Meaning
0 the program ended normally
1 the program was stopped by an error
2 the program file could not be opened
other the number given to tizim.chiqish(kod)

Ordinary output goes to standard output, and error messages go to standard error, so they can be redirected separately.

The interactive mode

Started without a file name, algorizm reads one line at a time and runs it at once. The value of an expression is printed without chiqar.

>>> narx = 12000
>>> narx * 3
36000
>>> "salom".katta()
"SALOM"
>>> har i ichida oraliq(3):
...     chiqar(i)
...
0
1
2
  • >>> means Algorizm is waiting for a new statement, and ... means it is waiting for the rest of a block.
  • A block is finished with an empty line.
  • Variables and functions stay defined until you leave.
  • After an error, the interactive mode simply goes on.
  • yordam shows what is built in, and yordam(x) describes one function, module or value.
  • chiqish leaves the interactive mode.

Input and output of text

Program files, files read with the fayl module, and the output of a program are all UTF-8. On Windows, Algorizm sets up the terminal itself so that Uzbek, Cyrillic and other letters are shown and read correctly.

Editors

Any text editor can be used to write Algorizm programs. Two settings make it more comfortable: let the Tab key insert four spaces, and save files as UTF-8. Because the syntax is close to Python, choosing Python colouring for .alg files gives a reasonable picture of strings, numbers and comments.