How agar works
Write agar, a condition in brackets and a block in curly braces. The braces are required even for one line. The brackets are recommended — they make the condition's start and end obvious.
The condition does not have to be a real sahi/galat: galat, khali, 0 and the empty string count as false, everything else (including an empty list) counts as true.
Comparisons use ==, !=, <, >, <= and >=, and can be combined with &&, || and !. == is strict, so a number never equals text.
Syntax
agar (condition) {
// runs when condition is truthy
}Runnable example
Same idea in JavaScript and Python
let balance = 250;
const price = 199;
if (balance >= price) {
console.log("Order ho gaya!");
balance = balance - price;
}balance = 250
price = 199
if balance >= price:
print("Order ho gaya!")
balance = balance - priceCommon mistakes
Using = instead of ==
A single = stores a value; it does not compare. Inside a condition always use == to ask "is it equal?".
rakho x = 3;
agar (x = 5) { bol("paanch"); }rakho x = 3;
agar (x == 5) { bol("paanch"); } warna { bol("paanch nahi"); }Comparing text with a number
"5" == 5 is galat because the types differ. Input from pucho() is always text — convert it with sankhya() first.
agar ("5" == 5) { bol("barabar"); }agar (sankhya("5") == 5) { bol("barabar"); }Leaving out the braces
Unlike some languages, AltFLang always needs { } after the condition.
agar (sahi) bol("hi");agar (sahi) { bol("hi"); }agar: frequently asked questions
How do I write if-else in Hindi programming with AltFLang?
Use agar for if and warna for else: agar (marks >= 33) { bol("Pass"); } warna { bol("Fail"); }. For more branches, chain warna agar.
Are the brackets around the condition required?
The curly braces around the block are required. The round brackets around the condition are optional in the current parser, but writing them is strongly recommended for readability.