' Multi-step wizard with Next/Back/Cancel buttons (console simulation)
#COMPILE EXE
#DIM ALL

CONST MAX_STEPS = 5
CONST ID_NEXT = 1000
CONST ID_BACK = 1001
CONST ID_CANCEL = 1002
CONST ID_FINISH = 1003

DECLARE FUNCTION MessageBox LIB "USER32.DLL" ALIAS "MessageBoxA" (BYVAL hWnd AS LONG, BYVAL lpText AS ASCIIZ, BYVAL lpCaption AS ASCIIZ, BYVAL uType AS LONG) AS LONG
DECLARE FUNCTION SetWindowText LIB "USER32.DLL" ALIAS "SetWindowTextA" (BYVAL hWnd AS LONG, BYVAL lpString AS ASCIIZ) AS LONG
DECLARE FUNCTION GetDlgItem LIB "USER32.DLL" (BYVAL hDlg AS LONG, BYVAL nIDDlgItem AS LONG) AS LONG
DECLARE FUNCTION EnableWindow LIB "USER32.DLL" (BYVAL hWnd AS LONG, BYVAL bEnable AS LONG) AS LONG

SUB InitWizard(BYREF stepNum AS LONG, BYREF uname AS STRING, BYREF mail AS STRING, BYREF projType AS LONG, BYREF feats AS LONG, BYREF outDir AS STRING, BYREF confirmed AS LONG)
    stepNum = 1
    uname = ""
    mail = ""
    projType = 0
    feats = 0
    outDir = "C:\Projects"
    confirmed = 0
END SUB

FUNCTION CanGoNext(BYVAL stepNum AS LONG, BYVAL uname AS STRING, BYVAL mail AS STRING) AS LONG
    IF stepNum = 1 AND LEN(uname) = 0 THEN
        FUNCTION = 0
        EXIT FUNCTION
    END IF
    IF stepNum = 2 AND LEN(mail) = 0 THEN
        FUNCTION = 0
        EXIT FUNCTION
    END IF
    FUNCTION = 1
END FUNCTION

SUB ShowStep(BYVAL stepNum AS LONG, BYVAL uname AS STRING, BYVAL mail AS STRING, BYVAL projType AS LONG, BYVAL feats AS LONG, BYVAL outDir AS STRING)
    PRINT ""
    PRINT "=== Step "; stepNum; " of 5 ==="
    IF stepNum = 1 THEN
        PRINT "Welcome to the Project Wizard!"
        PRINT "This wizard helps you create a new project."
        IF LEN(uname) > 0 THEN PRINT "Name: "; uname
        IF LEN(uname) = 0 THEN PRINT "Name: (not set)"
    ELSEIF stepNum = 2 THEN
        PRINT "Contact Information"
        IF LEN(mail) > 0 THEN PRINT "Email: "; mail
        IF LEN(mail) = 0 THEN PRINT "Email: (not set)"
    ELSEIF stepNum = 3 THEN
        PRINT "Project Type"
        PRINT "Type: "
        IF projType = 0 THEN PRINT "Console Application"
        IF projType = 1 THEN PRINT "GUI Application"
        IF projType = 2 THEN PRINT "Library"
        IF projType = 3 THEN PRINT "Web Service"
    ELSEIF stepNum = 4 THEN
        PRINT "Features"
        PRINT "Include:"
        PRINT "  [x] Unit Tests"
        IF feats AND 1 THEN PRINT "  [x] Documentation"
        IF feats AND 2 THEN PRINT "  [x] Samples"
        IF feats AND 4 THEN PRINT "  [x] CI Pipeline"
        PRINT "  Output: "; outDir
    ELSEIF stepNum = 5 THEN
        PRINT "Confirmation"
        PRINT "Name: "; uname
        PRINT "Email: "; mail
        PRINT "Project type: "; projType
        PRINT "Output: "; outDir
        PRINT ""
        PRINT "Press Finish to create the project."
    END IF
    PRINT "Buttons: ["
    IF stepNum > 1 THEN PRINT "Back"
    IF stepNum < 5 THEN PRINT "Next"
    IF stepNum = 5 THEN PRINT "Finish"
    PRINT "] [Cancel]"
END SUB

SUB RunWizard()
    LOCAL stepNum AS LONG
    LOCAL uname AS STRING
    LOCAL mail AS STRING
    LOCAL projType AS LONG
    LOCAL feats AS LONG
    LOCAL outDir AS STRING
    LOCAL confirmed AS LONG
    InitWizard(stepNum, uname, mail, projType, feats, outDir, confirmed)
    uname = "MyProject"
    mail = "user@example.com"
    projType = 1
    feats = 3
    confirmed = 1
    LOCAL i AS LONG
    FOR i = 1 TO 5
        stepNum = i
        ShowStep(stepNum, uname, mail, projType, feats, outDir)
        IF i < 5 THEN
            PRINT "Moving to step "; i + 1
        END IF
    NEXT i
    PRINT ""
    PRINT "Wizard completed!"
    PRINT "Project '"; uname; "' created successfully."
END SUB

SUB TestNavigation()
    PRINT "Navigation test:"
    LOCAL stepNum AS LONG
    LOCAL uname AS STRING
    LOCAL mail AS STRING
    LOCAL projType AS LONG
    LOCAL feats AS LONG
    LOCAL outDir AS STRING
    LOCAL confirmed AS LONG
    InitWizard(stepNum, uname, mail, projType, feats, outDir, confirmed)
    ShowStep(stepNum, uname, mail, projType, feats, outDir)
    stepNum = 2
    PRINT "Moving to step "; stepNum
    uname = "Test"
    ShowStep(stepNum, uname, mail, projType, feats, outDir)
    stepNum = 1
    ShowStep(stepNum, uname, mail, projType, feats, outDir)
END SUB

SUB ValidationScenarios()
    PRINT "Validation scenarios:"
    LOCAL stepNum AS LONG
    LOCAL uname AS STRING
    LOCAL mail AS STRING
    LOCAL projType AS LONG
    LOCAL feats AS LONG
    LOCAL outDir AS STRING
    LOCAL confirmed AS LONG
    InitWizard(stepNum, uname, mail, projType, feats, outDir, confirmed)
    PRINT "  Step 1, name empty: CanGoNext="; CanGoNext(stepNum, uname, mail)
    uname = "ProjectX"
    PRINT "  Step 1, name set: CanGoNext="; CanGoNext(stepNum, uname, mail)
    stepNum = 2
    PRINT "  Step 2, email empty: CanGoNext="; CanGoNext(stepNum, uname, mail)
    mail = "a@b.com"
    PRINT "  Step 2, email set: CanGoNext="; CanGoNext(stepNum, uname, mail)
END SUB

FUNCTION PBMAIN() AS LONG
    PRINT "=== Wizard Dialog Demo ==="
    PRINT "Win32: Dialog with Next/Back/Cancel buttons"
    PRINT ""
    TestNavigation()
    PRINT ""
    ValidationScenarios()
    PRINT ""
    RunWizard()
    PRINT ""
    PRINT "=== End Wizard Demo ==="
    FUNCTION = 0
END FUNCTION