1. nudhi_ask - User Input
Description: This function prompts the user for input and stores the input into a variable.
Syntax:
nudhi_ask "prompt" variable_name
Parameters:
"prompt": A string (with spaces if needed) that is shown to the user.variable_name: The name of the variable where the user input will be stored.
Example:
nudhi_ask "Enter your name: " username
This example will prompt the user to enter their name and store the value in the variable username.
2. nudhi_say - Output a Variable or Message
Description: This function prints a string or the value of a variable to the console.
Syntax:
nudhi_say "message"
nudhi_say variable_name
Parameters:
"message": A string (in quotes) that will be printed to the console.variable_name: A variable name (without quotes) whose value will be printed.
Example 1 (Message):
nudhi_say "Hello, World!"
This will print Hello, World! to the console.
Example 2 (Variable):
nudhi_say result
This will print the value of the result variable.
3. nudhi_do - Execute a System Command
Description: This function runs a system command (e.g., shell commands) on the operating system.
Syntax:
nudhi_do "command"
Parameters:
"command": A system command enclosed in double quotes that will be executed.
Example:
nudhi_do "echo Hello from Nudhi Lang"
This will execute the shell command to print Hello from Nudhi Lang to the console.
4. nudhi_die - Exit the Program
Description: This function immediately exits the Nudhi Lang program.
Syntax:
nudhi_die
Example:
nudhi_die
This will stop the program and exit the interpreter.
5. Variable Assignment and Math Operations
Description: Variables in Nudhi Lang can be assigned values, and basic math operations can be performed. Currently supported math operations are addition (+), subtraction (-), multiplication (*), and division (/).
Syntax:
variable_name = expression
Parameters:
variable_name: The name of the variable where the result of the expression will be stored.expression: A math expression involving numbers or variables (e.g.,num1 + num2).
Example 1:
result = num1 + num2
This example will add the values of num1 and num2 and store the result in result.
Example 2:
area = width * height
This will multiply the values of width and height and store the result in area.
6. Error Handling
Description: If an error occurs (e.g., missing variables or incorrect syntax), Nudhi Lang will print an appropriate error message.
Common Errors:
- Missing quotes:
Error: Prompt must be enclosed in double quotes - Undefined variable:
Error: Variable 'var_name' not found - Invalid variable assignment:
Error: Invalid variable assignment