'lb3edit.bas - a simple text editor with open, save, and save as features

    nomainwin
    WindowWidth = 320
    WindowHeight = 240
    menu #window, "&File","&Open", [open], "&Save As...", [saveAs], "&Save", [save], | , "E&xit", [quit]
    menu #window, "Edit"
    menu #window, "&Help",  "&About", [about]
    texteditor #window.te 5, 10, 300, 170
    open "Liberty BASIC Edit" for window as #window
    #window.te "!font courier_new 9"
    #window.te "!autoresize"
    #window "trapclose [quit]"
    wait

[open]
    filedialog "Open a txt file", "*.txt", filename$
    if filename$ = "" then wait
    open filename$ for input as #filein
    #window.te "!contents #filein";
    close #filein
    wait

[saveAs]
    filedialog "Save as...", "*.txt", filename$
    if filename$ = "" then wait

[save]
    if filename$ = "" then [SaveAs]
    open filename$ for output as #fileout
    #window.te "!contents? filetext$";
    print #fileout, filetext$;
    close #fileout
    wait

[about]
    notice "lb3edit.bas - a simple texteditor example"
    wait

[quit]
    close #window
    end
