Files
FoxLang/demo.fox
T

75 lines
1.8 KiB
Plaintext

// Демонстрация всех возможностей FoxLang 4.1.0
using net;
print("=== FoxLang 4.1.0 Demo ===");
// Новые типы данных
float pi = 3.14159;
bool systemActive = true;
bool debugMode = false;
print("Pi value: " + pi);
print("System active: " + systemActive);
print("Debug mode: " + debugMode);
// Логические операции
if (systemActive && !debugMode) {
print("Production mode enabled");
}
if (pi > 3.0 || debugMode) {
print("Math constants loaded");
}
// Сетевые функции
print("Testing network functions...");
string apiResponse = http_get("https://jsonplaceholder.typicode.com/posts/1");
print("API Response: " + apiResponse);
string postResult = http_post("https://httpbin.org/post", "test=data");
print("POST Result: " + postResult);
// TCP операции
int tcpSock = tcp_socket();
print("TCP Socket ID: " + tcpSock);
bool connected = tcp_connect(tcpSock, "example.com", 80);
if (connected) {
print("TCP connection established");
int sent = tcp_send(tcpSock, "GET / HTTP/1.1\r\nHost: example.com\r\n\r\n");
print("Sent " + sent + " bytes");
string response = tcp_receive(tcpSock, 1024);
print("Received: " + response);
tcp_close(tcpSock);
print("Connection closed");
}
// UDP операции
int udpSock = udp_socket();
int udpSent = udp_send(udpSock, "8.8.8.8", 53, "DNS query");
print("UDP sent " + udpSent + " bytes to DNS server");
string udpResp = udp_receive(udpSock, 512);
print("UDP response: " + udpResp);
// Массивы и циклы
array numbers 5;
int i = 0;
while (i < 5) {
set(numbers, i, i * i);
i++;
}
print("Array contents:");
i = 0;
while (i < 5) {
string value = get(numbers, i);
print("numbers[" + i + "] = " + value);
i++;
}
print("=== Demo completed ===");
fox();