Skip to content

References & Variables

A cool feature of hissab is that it can store results for any expression in a variable of any name, which can be referenced in any other expression.

myvar = 123 + 234
357
myvar - 100
-100

Here ‘myvar’ is a variable name. There are rules around variable names.

  • Variable cannot start from a number or special character, except _ (underscore).
  • It must start from a letter.
  • It cannot contain any special character except _.
abcd123 = 1234
1,234
_ab = 12
12
my_var = 34
34
#ab = 12
12

Variables can hold values with units as well as dates and times.

unit1 = 5 miles
5 mile
time_then = now + 100 days
25 Mar 2025, 19:15:13

Variable names are case-sensitive.

abcd123 = 1234
1,234
abcd123 = 1234
1,234

Variable names cannot be a unit name or hissab keyword like ‘time’.

time = 1234
1,234
meters = 123
123
time123 = 1234
1,234

Variable declaration must be at the beginning of an expression.

9876 + (myvar = 1234)
11,110
myvar - 9876
-9,876
myvar = 1234
1,234

You can directly reference results from any previous lines without storing it in variables as well by using line (or just l) followed by the line number and no space in between.

You cannot only refer to lines above the current line.

123 + 234
357
50 meters to cm
5,000 cm
123
123
line 2 *2
4

You can refer to the previous line’s result with the ‘prev’ keyword.

123 * 2
246

‘prev’ keyword also works if there are empty lines in between.

123 * 2246
276,258

If you want to add results from all above lines, you can use the ‘total’ keyword. This only works if those results are addable.

1234
1,234
234+2
236
10 mod 7
3
50 sq meter
50 square meter
10 sq km to sq miles
3.861 sq miles
10 sq mile to acre
6,400 acre
12
12
20
20
10
10
50
50
1234
1,234
today
15 Dec 2024
2000 kb to mb
1.9531 mb