Skip to content

Jpx-lang/Jpx-exanple-code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JPX Example Code

This page shows simple examples of JPX syntax including variables, functions, modules, loops, and error handling.


Hello World

Print "Hello World";

Variables

JPX variables can be declared using Global.

Global [name = "John"];
Global [age = 20];

Print "Name : $name";
Print "Age : $age";

Arithmetic Operations

Global [a = 10];
Global [b = 5];

Global [sum = a + b];
Global [sub = a - b];
Global [mul = a * b];
Global [div = a / b];

Print "Sum : $sum";
Print "Sub : $sub";
Print "Mul : $mul";
Print "Div : $div";

Scanner Module (Input)

[Scanner];

name = scanner.text("Enter your name : ");

Print "Hello $name";

File System Module

[Fs];

Fs.create.dir("myfolder");

code = "Hello JPX";

Fs.write("file.txt", code);

Color Module

[Color];

Print color.red + "Hello World";
Print color.green + "Success Message";

Functions

function greet(name) {
    Print "Hello $name";
}

greet("John");

If / Else Statement

Global [age = 18];

if (age >= 18) {
    Print "Access granted";
} else {
    Print "Access denied";
}

While Loop

Global [i = 0];

while (i < 5) {
    Print "Loop $i";
    i = i + 1;
}

Error Handling

try {
    Print "Running program";
} Catch (e) {
    Print "Error occurred";
}

Full Example Script

[Scanner];
[Color];

function greet(name) {
    Print color.green + "Hello $name";
}

username = scanner.text("Enter your name: ");

greet(username);

Learn More

Visit the official repository:

https://github.com/jpx-lang

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages