HASANBLY

Hasanbly is basic scripting language made by C++. It interprets and runs your codes easily.

Github Link v1.7 is current version. [v0.0 made on 05.10.2022]





GET STARTED

Download After download the hsnc and main.hsn file, in command promp:
1 hsnc main.hsn

command will be run your code.










COMMANDS










EXIT



Functionality:

Kills program.

Parameter Count:

0

Parameters:

NULL

Notes

There must be an EXIT command at the end of the code.


Usage:

1 EXIT;

Output:






//



Functionality:

Disable entire line.

Parameter Count:

0

Parameters:

NULL

Notes:

You can not use in the line. There must be at the begin of the line.


Usage:

1 //<passive command;
2 EXIT;

Output:






<



Functionality:

Prints texts.

Parameter Count:

1

Parameters:

1- Pure text and/or variable (str | int | dbl).

Notes:

If you put ^ before any char, the char is written directly.
Can not use escape chars in the command.


Usage:

1 <Hello, World!;
2 EXIT;

Output:

Hello, World!





<<



Functionality:

Prints texts with new line.

Parameter Count:

1

Parameters:

1- Pure text and/or variable (str | int | dbl).

Notes:

If you put ^ before any char, the char is written directly.
Can not use escape chars in the command.


Usage:

1 <<Hello, World!;
2 EXIT;

Output:

Hello, World!






DEF



Functionality:

Defines variable.

Parameter Count:

3

Parameters:

1- Pure text for type (str | int | dbl)
2- Pure text/number for name.
3- Pure text/number for value.

Notes:

Even you don't want initialize the variable value, you have to put = char and for int and double variables, you have to assign them.
Valid escape chars (\n \t \r \v \0 \' \" \\ \? \a \b \f) are usable in string variables.
For calling variable, use this template $:type:name_


Usage:

1 DEF:str:langName=Hasanbly;
2 <Language Name is: $:str:langName_;
3 EXIT;

Output:

Hasanbly





>



Functionality:

Gets input from user.

Parameter Count:

1

Parameters:

1- Variable (str | int | dbl).

Notes:

Program will error if user writes different type.


Usage:

1 DEF:str:name=;
2 >$:str:name_;
3 <<$:str:name_;
4 EXIT;

Output:

Hasan Efe Aksoy





M



Functionality:

Calculates math operations.

Parameter Count:

3

Parameters:

1- Operation (+ | - | * | / | % | .SIN | .COS | .TAN | .COT | .SEC| .CSC | [there are arcs ".ATAN"..., hyperbolics ".TANH"..., arc hyperbolics ".ATANH"... trigonometrical processes too] | .ABS | .SQRT | .POW | .LN | .LOG | .EXP | .ROUND | .CEIL | .FLOOR | .FACT | .PERM | .COMB | .DEG2RAD | .RAD2DEG)
2- Variable
3- Variable

Notes:

The operation is like that : [var1 = var1 * var2]. Example for .SIN : [var1 = sin(var2)]
= operaton can convert variable types.
In trigonometrical operations, you have to use double variables
For more detail, in main.cpp file after at 660. line, there is M commands and valid variable types.


Usage:

1 DEF:dbl:number1=10;
2 DEF:int:number2=30;
3 M* $:dbl:number1_ $:int:number2_;
4 <<$:dbl:number1_;
5 EXIT;

Output:

300.00





GOTO



Functionality:

Goes to line.

Parameter Count:

1

Parameters:

1- Pure integer number.

Notes:

You can use for loops.


Usage:

1 <Oo;
2 GOTO 1;
3 EXIT;

Output:

OoOoOoOoOoOoOoOoOoOo...





IF



Functionality:

Controls condition and decides to pass or skip.

Parameter Count:

4

Parameters:

1- Condition (== | << | <= | >> | >= | !=)
2- Variable
3- Variable
4- Pure integer number

Notes:

If condition is like box office checkpoint. If the condition is true, you can pass; else you going to selected line which is written at ELSE= part.
If you used same variable types, you can use == or !=. Other conditions you can use double-int/int-double combinations.
The lines which is in the if condition, puts Tab char (ex. 4 spaces) is preffered style.
You can make a loop with IF and GOTO commands.


Usage:

1 DEF:int:num1=10;
2 DEF:dbl:num2=20;
3 IF== $:int:num1_ $:dbl:num2_ ELSE=5;
4     <yes;
5 <no;
6 EXIT;

Output:

no





INC



Functionality:

Add 1 to integer or double variable.

Parameter Count:

1

Parameters:

1- Variable (int | dbl)

Notes:

INC command is easy way of using M+ command. And you can use it at loops.


Usage:

1 DEF:int:number=10;
2 <<$:int:number_;
3 INC $:int:number_;
4 <<$:int:number_;
5 EXIT;

Output:

10
11





DEC



Functionality:

Subrtact 1 to integer or double variable.

Parameter Count:

1

Parameters:

1- Variable (int | dbl)

Notes:

DEC command is easy way of using M- command. And you can use it at loops.


Usage:

1 DEF:int:number=10;
2 <<$:int:number_;
3 DEC $:int:number_;
4 <<$:int:number_;
5 EXIT;

Output:

10
9





NULL



Functionality:

Resets the variable value.

Parameter Count:

1

Parameters:

1- Variable (str | int | dbl)

Notes:

string's null is "", integer's null is 0, double's null is 0.0


Usage:

1 DEF:dbl:number=100;
2 NULL $:dbl:number_;
3 <<$:dbl:number_;
4 EXIT;

Output:

0.00





FREE



Functionality:

Deletes the variable from memory.

Parameter Count:

1

Parameters:

1- Variable (str | int | dbl)

Notes:

In the loops if there is DEF or DEFEL command, you need FREE or FREEEL command. Because program can't create a variable with the same name.


Usage:

1 DEF:str:text=Hi!\nHow are you today?\n;
2 <$:str:text_;
3 FREE $:str:text_;
4 <$:str:text_;
5 EXIT;

Output:

Hi!
How are you today?
ERROR





INDEX



Functionality:

Copy char from selected index of second parameter and set value to third parameter.

Parameter Count:

3

Parameters:

1- Pure integer or variable (int)
2- Variable (str)
3- Variable (str)

Notes:

You can get element of string. Index must be an integer and must be in the [] operator.


Usage:

1 DEF:str:text=Hasanbly;
2 DEF:str:ind=;
3 DEF:int:index=2;
4 INDEX[$:int:index_] $:str:text_ $:str:ind_;
5 <<$:str:ind_;
6 EXIT;

Output:

s





SLEEP



Functionality:

Causes the main process to wait for a desired amount of time.

Parameter Count:

1

Parameters:

1- Pure integer or variable (int)

Notes:

Time type is milliseconds.


Usage:

1 SLEEP 1000;
2 <<This message is printed after 1 second.;
3 EXIT;

Output:

This message is printed after 1 second.





RAND



Functionality:

Returns random integer number.

Parameter Count:

3

Parameters:

1- Variable (int)
2- Variable (int)
3- Variable (int)

Notes:

First parameter is result. Second one is minimum value, third one is maximum value of the range.
(Min and max is included.)
If you want to get double number, you can write bigger numbers and divide by 10th powers.


Usage:

1 DEF:int:destination=0;
2 DEF:int:min=1;
3 DEF:int:max=10;
4 RAND $:int:destination_ $:int:min_ $:int:max_;
5 <<$:int:destination_;
6 EXIT;

Output:

10





STRLEN



Functionality:

Returns the string's length.

Parameter Count:

2

Parameters:

1- Variable (str)
2- Variable (int)

Notes:

First parameter is text. Second parameter is length of the text.


Usage:

1 DEF:str:text=Hello;
2 DEF:int:len=0;
3 STRLEN $:str:text_ $:int:len_;
4 <<$:int:len_;
5 EXIT;

Output:

5





CLEAR



Functionality:

Clears the console.

Parameter Count:

0

Parameters:

NULL

Notes:

Can be used to clear the console and clear an animation to be played on the console.


Usage:

1 <<There is some strings.;
2 CLEAR;
3 <<Hello!;
4 EXIT;

Output:

Hello!





OSNAME



Functionality:

Returns your current operating system (OS) name.

Parameter Count:

1

Parameters:

1- Variable (str)

Notes:

OSNAME command has not define at building time, so it returns current OS name.
You can understand the which language are you using from batch or bash at TERMINAL command.


Usage:

1 DEF:str:myOSname=;
2 OSNAME $:str:myOSname_;
3 <<$:str:myOSname_;
4 EXIT;

Output:

Windows





REPLACE



Functionality:

Change the selected char to any string.

Parameter Count:

3

Parameters:

1- Pure integer or variable (int)
2- Variable (str)
3- Variable (str)

Notes:

Write the index in brackets. Second parameter is main text. Third parameter is new string instead of the char.
You don't have to replace just one char, any string can be used.


Usage:

1 DEF:str:text=HELLO;
2 DEF:str:newWord=hi;
3 REPLACE[3] $:str:text_ $:str:newWord_;
4 <<$:str:text_;
5 EXIT;

Output:

HELhiO





TERMINAL



Functionality:

Runs bash and batch codes.

Parameter Count:

1

Parameters:

1- Variable (str)

Notes:

If you write wrong command or get some errors, the program stops.


Usage:

1 // example for Windows
2 DEF:str:command=dir;
3 // example for UNIX types
4 // DEF:str:command=ls;
5 TERMINAL $:str:command_;
6 EXIT;

Output:

[<your current folder contents>]





TIME



Functionality:

Returns the current time.

Parameter Count:

2

Parameters:

1- Time type (.SECONDS | .MINUTES | .HOURS)
2- Variable (int)

Notes:

You can use for control to commands according to the time.


Usage:

1 DEF:int:time=0;
2 TIME.SECONDS $:int:time_;
3 <<$:int:time_;
4 EXIT;

Output:

41





CLAMP



Functionality:

Clamps the number between a range to other range.

Parameter Count:

5

Parameters:

1- Variable (dbl)
2- Variable (dbl)
3- Variable (dbl)
4- Variable (dbl)
5- Variable (dbl)

Notes:

First parameter is main number and program assigns result to first parameter.
Second: minimum of first range.
Third: maximum of first range.
Fourth: minimum of last range.
Fifth: maximum of last range.


Usage:

1 DEF:dbl:value=2;
2 DEF:dbl:a=0;
3 DEF:dbl:b=10;
4 DEF:dbl:c=0;
5 DEF:dbl:d=100;
6 CLAMP $:dbl:value_ $:dbl:a_ $:dbl:b_ $:dbl:c_ $:dbl:d_;
7 <<$:dbl:value_;
8 EXIT;

Output:

20





ADDESCAPE



Functionality:

Add an escape char to a string.

Parameter Count:

2

Parameters:

1- Escape char (\n \t \r \v \0 \' \" \\ \? \a \b \f)
2- Variable (str)

Notes:

Adds to the end of the value and assigns to same variable.


Usage:

1 DEF:str:myStr=hello;
2 ADDESCAPE\n $:str:myStr_;
3 <<$:str:myStr_;
4 EXIT;

Output:

hello






OPENFILE



Functionality:

Opens file to given path or name.

Parameter Count:

1

Parameters:

1- Variable (str)

Notes:

IMPORTANT: Valid chars are English chars.
If file is already exist, it's content will be deleted.


Usage:

1 DEF:str:fileName=myfile.txt;
2 OPENFILE $:str:fileName_;
3 EXIT;

Output:






DELETEFILE



Functionality:

Deletes the file.

Parameter Count:

1

Parameters:

1- Variable (str)

Notes:

IMPORTANT: Valid chars are English chars.
If file is not exist, the program stops.


Usage:

1 DEF:str:fileName=myfile.txt;
2 OPENFILE $:str:fileName_;
3 EXIT;

Output:






READFILE



Functionality:

Reads the file.

Parameter Count:

2

Parameters:

1- Variable (str)
2- Variable (str)

Notes:

IMPORTANT: Valid chars are English chars.
If file is not exist, the program stops.
Second parameter is content of file.


Usage:

1 DEF:str:fileName=myfile.txt;
2 DEF:str:contentOfFile=;
3 READFILE $:str:fileName_ $:str:contentOfFile_;
4 <$:str:contentOfFile_;
5 EXIT;

Output:

Hello! I am content of file :)





OVERWRITEFILE



Functionality:

Overwrites to the file.

Parameter Count:

2

Parameters:

1- Variable (str)
2- Variable (str)

Notes:

IMPORTANT: Valid chars are English chars.
If file is not exist, the program stops.
Second parameter is new content of file.
Deletes the current content and assings new.


Usage:

1 DEF:str:fileName=myfile.txt;
2 DEF:str:newContent=Hello.\nThe new content is here.;
3 OVERWRITEFILE $:str:fileName_ $:str:newContent_;
4 EXIT;

Output:






APPENDWRITEFILE



Functionality:

Appends the content to the file.

Parameter Count:

2

Parameters:

1- Variable (str)
2- Variable (str)

Notes:

IMPORTANT: Valid chars are English chars.
If file is not exist, the program stops.
Second parameter is new content of file.
Saves the current content and adds new.


Usage:

1 DEF:str:fileName=myfile.txt;
2 DEF:str:content=\nHello.\nAppended content here;
3 APPENDWRITEFILE $:str:fileName_ $:str:content_;
4 EXIT;

Output:






DEFEL



Functionality:

Defines multiple variables at once.

Parameter Count:

2

Parameters:

1- Pure integer or variable (int)
2- Pure text for variable name (str | int | dbl)

Notes:

DEFEL is DEF for multiple elements.
Hasanbly has not the lists but the DEFEL command adds number (index) at the end of the variable name. And it can be made lists.
For example when the command is (DEFEL[3] $:dbl:aksoy_;), the created variables are ($:dbl:aksoy0_, $:dbl:aksoy1_, $:dbl:aksoy2_).
Now you can accessing the indexes of the list.
Initialize values are the null values of variable types.
Indexes are between from (0) to (n-1).


Usage:

1 DEFEL[3] $:int:var_;
2 // Same as
3 // DEF:int:var0=0;
4 // DEF:int:var1=0;
5 // DEF:int:var2=0;
6 // But can not be used variables for how many times you want to create at DEF
7 <<This is 1st element of var list= $:int:var0_;
8 <<This is 2nd element of var list= $:int:var1_;
9 <<This is 3rd element of var list= $:int:var2_;
10 EXIT;

Output:

This is 1st element of var list= 0
This is 2nd element of var list= 0
This is 3rd element of var list= 0





FREEEL



Functionality:

Deletes multiple variables from memory at once.

Parameter Count:

2

Parameters:

1- Pure integer or variable (int)
2- Pure text for variable name (str | int | dbl)

Notes:

FREEEL is FREE for multiple elements.
When you used DEFEL command or used DEF command like DEFEL, you can delete variable quick.
The first parameter says, you want to delete which element of your list.


Usage:

1 DEFEL[2] $:int:var_;
2 <<$:int:var0_;
3 <<$:int:var1_;
4 FREEEL[1] $:int:var_;
5 // Same as
6 // FREE $:int:var0_;
7 // But can not be used variables for indexes at FREE
8 <<$:int:var1_;
9 EXIT;

Output:

0
0
ERROR





SETEL



Functionality:

Assigns a value to the selected index of the variable with indexes at the end.

Parameter Count:

3

Parameters:

1- Pure integer or variable (int)
2- Variable (str | int | dbl)
3- Variable (str | int | dbl) [same type with second one]

Notes:

SETEL is M= for multiple elements.
You can access the valid index of list and assign value quick.
The first parameter is index of second parameter.


Usage:

1 DEF:int:new=10;
2 DEFEL[4] $:int:var_;
3 SETEL[0] $:int:var_ $:int:new_;
4 // Same as
5 // M= $:int:var0_ $:int:new_;
6 // But can not be used variables for indexes at M=
7 <<$:int:var0_;
8 EXIT;

Output:

10





GETEL



Functionality:

Gets a value to the selected index of the variable with indexes at the end.

Parameter Count:

3

Parameters:

1- Pure integer or variable (int)
2- Variable (str | int | dbl)
3- Variable (str | int | dbl) [same type with second one]

Notes:

SETEL is M= for multiple elements.
You can access the valid index of list and assign value quick.
The first parameter is index of second parameter.


Usage:

1 DEF:int:other=50;
2 DEFEL[2] $:int:var_;
3 GETEL[0] $:int:var_ $:int:other_;
4 // Same as
5 // M= $:int:other_ $:int:var0_;
6 // But can not be used variables for indexes at M=
7 <<$:int:other_;
8 EXIT;

Output:

0