News:

Welcome to RetroCoders Community

Main Menu

Recent posts

#11
General Discussion / Re: Forums_Links
Last post by mysoft - Jun 10, 2024, 12:14 PM
i deleted the link... because that was made as a personal attack basically... and we dont need to keep just creating many forums, to a community that is already small..

and ron deletet his archive.org page as well... and who knows what else he deleted...
#12
General Discussion / Re: Forums_Links
Last post by aurel - Jun 05, 2024, 06:28 AM
QuoteNot true...not true ...not true...

github become bull shit with crappy login which require phone number junk.

there is no real Momentum because we use different languages and sharing code

become useless or worthless ...

in fact you cannot find 5 people which use one PL ..nobody seems

interested ...only maybe B+ with endless graphical progies
#13
General Discussion / Forums_Links
Last post by aurel - Jun 05, 2024, 06:14 AM
Yo
ron77 deleted post about his forum ..why i am not sure
https://back-to-basic.freeforums.net/
i have one to called
http://basic4all.epizy.com/index.php
there is also:
https://friends-of-basic.freeforums.net/
and then walter jump with his own strange forum:
https://thejoyfulprogrammer.com/forum/basic/index.php
#14
FreeBasic / myStar what ?
Last post by aurel - Jun 03, 2024, 08:10 AM
...some guy posted this on facebook
without code

#15
C / C++ / Re: C prigramming in Windows X...
Last post by ron77 - May 21, 2024, 05:48 PM
ok here is a tiny GUI (win xp winapi) hebrew chatbot with database file

first save this tiny hebrew database.txt file with ANSI (window 1255) encoding

שלום;שלום! איך אני יכול לעזור לך היום?|מה שלומך?|היי, מה קורה?
מי אתה;אני צ'אטבוט שנוצר כדי לעזור לך.|אני תוכנת צ'אט.
default;אני מצטער אבל אני לא יודע מה לומר

now the chatbot.c code:

#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <locale.h>
#include <wchar.h>

#define MAX_KEYWORDS 100
#define MAX_RESPONSES 10
#define MAX_LINE_LENGTH 256
#define MAX_INPUT_LENGTH 100

typedef struct {
    char keyword[MAX_INPUT_LENGTH];
    char *responses[MAX_RESPONSES];
    int response_count;
} KeywordResponse;

KeywordResponse database[MAX_KEYWORDS];
int keyword_count = 0;

HWND hwndInput;
HWND hwndButton;
HWND hwndOutput;

char *my_strdup(const char *str) {
    size_t len = strlen(str) + 1;
    char *dup = malloc(len);
    if (dup != NULL) {
        memcpy(dup, str, len);
    }
    return dup;
}

void load_database(const char *filename) {
    FILE *file = fopen(filename, "r");
    if (file == NULL) {
        MessageBox(NULL, "Error: Could not open database file.", "Error", MB_ICONERROR | MB_OK);
        exit(1);
    }

    char line[MAX_LINE_LENGTH];
    while (fgets(line, sizeof(line), file) && keyword_count < MAX_KEYWORDS) {
        line[strcspn(line, "\n")] = '\0'; // Remove the newline character if present

        char *keyword = strtok(line, ";");
        char *responses = strtok(NULL, "\n");

        if (keyword && responses) {
            strncpy(database[keyword_count].keyword, keyword, MAX_INPUT_LENGTH);
            char *response = strtok(responses, "|");
            while (response && database[keyword_count].response_count < MAX_RESPONSES) {
                database[keyword_count].responses[database[keyword_count].response_count] = my_strdup(response);
                database[keyword_count].response_count++;
                response = strtok(NULL, "|");
            }
            keyword_count++;
        }
    }

    // Add default reply to the database
    strncpy(database[keyword_count].keyword, "default", MAX_INPUT_LENGTH);
    database[keyword_count].responses[0] = my_strdup("אני לא מבין.");
    database[keyword_count].response_count = 1;

    fclose(file);
}

char *get_response(const char *input) {
    for (int i = 0; i < keyword_count; i++) {
        if (strstr(input, database[i].keyword)) {
            int rand_index = rand() % database[i].response_count;
            return database[i].responses[rand_index];
        }
    }
    return get_response("default"); // If no keyword matches, return the default reply
}


void DisplayOutput(const wchar_t *output) {
    int len = GetWindowTextLengthW(hwndOutput);
    wchar_t *currentText = (wchar_t *)malloc((len + 1) * sizeof(wchar_t));
    GetWindowTextW(hwndOutput, currentText, len + 1);
    
    wchar_t *newText = (wchar_t *)malloc((len + wcslen(output) + 3) * sizeof(wchar_t));
    wsprintfW(newText, L"%s\r\n%s", currentText, output);
    
    SetWindowTextW(hwndOutput, newText);
    
    free(currentText);
    free(newText);
}

// Window procedure
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
    switch (uMsg) {
        case WM_CREATE: {
            // Create input textbox
            hwndInput = CreateWindowW(L"EDIT", L"",
                          WS_VISIBLE | WS_CHILD | WS_BORDER | ES_AUTOHSCROLL,
                          50, 300, 600, 25,
                          hwnd, NULL, NULL, NULL);
            // Create talk button
            hwndButton = CreateWindowW(L"BUTTON", L"דבר",
                          WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
                          670, 300, 80, 25,
                          hwnd, (HMENU)1, NULL, NULL);
            // Create output textbox
            hwndOutput = CreateWindowW(L"EDIT", L"",
                          WS_VISIBLE | WS_CHILD | WS_BORDER | ES_MULTILINE | ES_READONLY | WS_VSCROLL,
                          50, 50, 700, 200,
                          hwnd, NULL, NULL, NULL);
            break;
        }
        case WM_COMMAND:
            if (LOWORD(wParam) == 1) {
                // Get text from input textbox
                wchar_t wbuffer[MAX_INPUT_LENGTH];
                GetWindowTextW(hwndInput, wbuffer, MAX_INPUT_LENGTH);
                
                // Convert wchar_t to char
                char input[MAX_INPUT_LENGTH];
                wcstombs(input, wbuffer, MAX_INPUT_LENGTH);

                // Get response
                char *response = get_response(input);

                // Convert response to wchar_t for display
                wchar_t wresponse[MAX_LINE_LENGTH];
                mbstowcs(wresponse, response, MAX_LINE_LENGTH);

                // Display response and input
                DisplayOutput(wbuffer);
                DisplayOutput(wresponse);

                // Clear input textbox and set focus
                SetWindowTextW(hwndInput, L"");
                SetFocus(hwndInput);
            }
            break;
        case WM_KEYDOWN:
            if (wParam == VK_RETURN) {
                SendMessage(hwnd, WM_COMMAND, 1, 0);
            }
            break;
        case WM_CLOSE:
            DestroyWindow(hwnd);
            break;
        case WM_DESTROY:
            PostQuitMessage(0);
            break;
        default:
            return DefWindowProcW(hwnd, uMsg, wParam, lParam);
    }
    return 0;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
    // Set locale to support Hebrew
    setlocale(LC_ALL, "Hebrew_Israel.1255");

    // Load the database
    load_database("database.txt");

    // Define and register the window class
    const wchar_t CLASS_NAME[] = L"ChatbotWindowClass";
    WNDCLASSW wc = { };
    wc.lpfnWndProc   = WindowProc;
    wc.hInstance     = hInstance;
    wc.lpszClassName = CLASS_NAME;
    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); // Set background to white

    RegisterClassW(&wc);

    // Create the window
    HWND hwnd = CreateWindowExW(
        0,
        CLASS_NAME,
        L"צ'אטבוט",
        WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT, CW_USEDEFAULT, 800, 400,
        NULL,
        NULL,
        hInstance,
        NULL);

    if (hwnd == NULL) {
        return 0;
    }

    // Show the window
    ShowWindow(hwnd, nCmdShow);

    // Message loop
    MSG msg = {0};
    while (GetMessage(&msg, NULL, 0, 0)) {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    // Free allocated memory for responses
    for (int i = 0; i < keyword_count; i++) {
        for (int j = 0; j < database[i].response_count; j++) {
            free(database[i].responses[j]);
        }
    }

    return msg.wParam;
}

#17
C / C++ / Re: C prigramming in Windows X...
Last post by CharlieJV - May 20, 2024, 11:02 AM
I really liked Windows XP, so I find that pretty cool.
#18
C / C++ / C prigramming in Windows XP
Last post by ron77 - May 20, 2024, 09:33 AM
hi all long time not posted...

i have installed windows XP in vertualbox and set up MingW 6 GCC with SDL 1.2 and Bass lib (compatible with win XP)...

here is a few Examples of Programs:



i compile using NotePad++ 6.9 given to me from Mysoft plus i use for images Paint Shop 4 Pro also from Mysoft

here is the SDL 1.2 Mandelbrot set code:

#include <SDL\SDL.h>
#include <windows.h>
#include <math.h>

int WIDTH = 800;
int HEIGHT = 800;

long double min = -2.84;
long double max = 1.0;
long double factor = 1;

int MAX_ITERATIONS = 200;

long double map(long double value, long double in_min, long double in_max, long double out_min, long double out_max) {
    return (value - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

int main(int argc, char* argv[]) {
    SDL_Init(SDL_INIT_VIDEO);
    
    SDL_Surface* screen = SDL_SetVideoMode(1440, 900, 32, SDL_SWSURFACE);
    if (!screen) {
        printf("Unable to set video mode: %s\n", SDL_GetError());
        return 1;
    }
    
    SDL_Event event; // Declare event variable
    int count = 0;
    
    while (1) {
        max -= 0.1 * factor;
        min += 0.15 * factor;
        factor *= 0.9349;
        MAX_ITERATIONS += 5;
        
        if (count > 30) {
            MAX_ITERATIONS *= 1.02;
        }
        
        for (int x = 0; x < WIDTH; x++) {
            for (int y = 0; y < HEIGHT; y++) {
                // Move event handling inside the rendering loop
                if (SDL_PollEvent(&event) && event.type == SDL_QUIT) {
                    SDL_Quit();
                    return 0;
                }
                if (GetKeyState('Q') & 0x8000) {
                    SDL_Quit();
                    return 0;
                }
                
                long double a = map(x, 0, WIDTH, min, max);
                long double b = map(y, 0, HEIGHT, min, max);
                long double ai = a;
                long double bi = b;
                int n = 0;
                
                for (int i = 0; i < MAX_ITERATIONS; i++) {
                    long double a1 = a * a - b * b;
                    long double b1 = 2 * a * b;
                    a = a1 + ai;
                    b = b1 + bi;
                    
                    if ((a + b) > 2) {
                        break;
                    }
                    
                    n++;
                }
                
                int bright = map(n, 0, MAX_ITERATIONS, 0, 255);
                if ((n == MAX_ITERATIONS) || (bright < 20)) {
                    bright = 0;
                }
                
                int red = map(bright * bright, 0, 65025, 0, 255);
                int green = bright;
                int blue = map(sqrt(bright), 0, sqrt(255), 0, 255);
                
                Uint32 color = SDL_MapRGB(screen->format, red, green, blue);
                Uint32* pixels = (Uint32*)screen->pixels;
                pixels[(y * screen->pitch / 4) + x] = color;
            }
        }
        
        SDL_Flip(screen);
        count++;
    }
    
    SDL_Quit();
    return 0;
}

#20
Other Programming Languages / Re: UDF in interpreter
Last post by aurel - May 03, 2024, 08:45 AM
in case someone is interested
https://discord.gg/ANsRUPy