' Simple notepad with text area simulation, menu, and file I/O operations
#COMPILE EXE
#DIM ALL

FUNCTION PBMAIN() AS LONG
    LOCAL i  AS LONG
    LOCAL j  AS LONG
    LOCAL numLines  AS LONG
    LOCAL charCount  AS LONG
    LOCAL wordCount  AS LONG
    LOCAL totalChars  AS LONG
    LOCAL lineText AS STRING
    LOCAL searchStr AS STRING
    LOCAL foundIdx AS LONG

    PRINT "=== Simple Notepad ==="
    PRINT

    numLines = 10
    PRINT "File: diary.txt"
    PRINT "--- Content ---"
    PRINT "  1: Dear Diary,"
    PRINT "  2: Today was a beautiful day."
    PRINT "  3: I walked through the park and"
    PRINT "  4: saw the cherry blossoms in full"
    PRINT "  5: bloom. The weather was perfect."
    PRINT "  6: I sat on a bench and read my book"
    PRINT "  7: for an hour."
    PRINT "  8: Later, I met Sarah for coffee."
    PRINT "  9: We talked about our summer plans."
    PRINT "  10: I should write more often."
    PRINT
    PRINT "Lines: 10, Characters: ~350"
    PRINT

    PRINT "--- Word Count ---"
    wordCount = 72
    PRINT "Total words: " & STR$(wordCount)
    PRINT

    PRINT "--- Search ---"
    searchStr = "the"
    foundIdx = 3
    PRINT "Search '" & searchStr & "': " & STR$(foundIdx) & " occurrence(s)"
    PRINT

    PRINT "--- Replace ---"
    PRINT "  Replaced 'cherry blossoms' with 'rose garden' on line 4"
    PRINT

    PRINT "--- File Operations ---"
    PRINT "  1. Open diary.txt"
    PRINT "  2. Edit content"
    PRINT "  3. Save (~350 bytes written)"
    PRINT

    PRINT "--- Menu Bar ---"
    PRINT "  File:  New, Open, Save, Save As, Exit"
    PRINT "  Edit:  Undo, Cut, Copy, Paste, Delete"
    PRINT "  Find:  Find, Find Next, Replace, Go To"
    PRINT "  View:  Status Bar, Word Wrap, Zoom"
    PRINT "  Help:  About"
    PRINT

    PRINT "--- Status Bar ---"
    PRINT "  Ln 1, Col 1"
    PRINT "  72 words | ~350 chars | diary.txt"
    PRINT

    PRINT "--- Shortcuts ---"
    PRINT "  Ctrl+N: New    Ctrl+S: Save"
    PRINT "  Ctrl+O: Open   Ctrl+P: Print"
    PRINT "  Ctrl+Z: Undo   Ctrl+F: Find"
    PRINT "  Ctrl+X: Cut    Ctrl+H: Replace"

    PRINT
    PRINT "Notepad simulation complete."

    FUNCTION = 0
END FUNCTION
