Conditions in KAGSA

We Have 3 conditions word in kagsa : if, elseif, else. The conditions sentences help to deal with the data and give programming great ease with decision-making conditions writted in this syntax :

condition-name  statements  {
    line of codes..
}

Example

var i = 5;

if i > 7 {
    write 'Number is Big Than 7'
}elseif i > 15 {
    write 'Number is Big Than 15';
}else{
    write 'Number is Small Than 7'
}

// output :
// Number is Small Than 7

Statements

you can use this separators in the statements :
== is equal, Example 5 == 5 = true
!= is not equal, Example 5 != 2 = true
> is big than, Example 5 < 2 = false
< is small than, Example 2 < 10 = true
-> is in, Example 'hi' -> "i am mohammed" = false
>= is big than or equal to, Example 5 >= 2 = true
<= is small than or equal to, Example 3 <= 3 = true
|| or, example (4.0 == 5) || (4.0 == 4) = true
&& and, Example ('h' -> 'hi') && ('p' -> 'mohammed') = false
flase its clear, right? Example 0 == false = true
true its clear too, Example 1 == true = true
and more !!
You can use a functions as a statements too, just make your function return 1 or true for Yes and 0 or false for No, example :

var str = "abcdefgh"
if str.start('abc') {
    // str is started with 'abc'
    write 'string startrd with "abc"'
}else{
    write 'string didn\'t started with "abc"'
}

some times we have to use a function returns with a separator, example :

// i will make a str var wit value : 'mohammed'
// the length of 'mohammed' is 8
var str = 'mohammed'

if str.length() < 5 {
    write 'the length of %{str} is less than 5'
}

else{
    write 'the length of %{str} is more than 5'
}

in this example we use length(str) < 5 as statement, this mean we use (function +separator + int)

How it Works ?

the condition word will read the statement and if statement = true the lines of code will run , example

// the statement is :
// (5 > 3) = (5 is big than 3)
// is 5 big than 3 ??
// YES !!, then the program will print "yes"
if 5 > 3 {
    write 'yes'
}else{
    write 'no'
}





KAGSA Programming Language - www.kagsa.org

Copyright © 2020 iDocs. All Rights Reserved.

Template by HarnishDesign.