MODIFIED
Jump to navigation
Jump to search
![]() |
![]() |
![]() |
![]() |
Description
- Returns a string either "true" or "false" indicating whether any data in the text window or text-editor has been changed by the user.
Syntax
- #handle "!modified? answer$"
- #handle.ext "!modified? answer$"
Hints
- Using Modified? This command is often used before closing a text window or text-editor in order to warn the user if the text has changed in any way. This can give the user an opportunity to save the data before closing the window. The procedure can be included just before the window is closed as an automatic safeguard against losing unsaved data.
- Programmed changes. Writing text programmatically does not change modified flag. The "!CLS" command resets modified flag to false. (Manually deleting all text does set flag to true).
- There is no way to reset modified flag to false while keeping cursor position
- (you can keep the text by sequence...
#h.text "!contents? save$" #h.text "!cls" #h.text "!contents save$"
but cursor position will be lost).
Example
nomainwin WindowWidth=300 WindowHeight=300 statictext #h.st1 "Enter contact data", 10, 15, 200, 20 texteditor #h.text 10, 35, 260, 150 button #h.btn "Close", [mainExit], UL, 10, 200 open "" for window as #h #h "trapclose [quit]" ' 'print some sample text to the texteditor window ' #h.text "This is the original contents of the data file. ";chr$(13);_ "Close window without changing text.";chr$(13);_ "Then change text and close window to see ";chr$(13);_ "the difference." wait [mainExit] 'check if text has changed... #h.text, "!modified? modify$" If modify$ = "true" then Confirm "The contents have changed. Save before closing?"; answer$ If answer$ = "yes" then [save] End if 'program ends here if text is unchanged or if 'user decides not to save changes. close #h end [save] confirm "Contents saved. Close now?"; yn$ if yn$= "yes" then [quit] wait [quit] close #h end
Useful Procedures
' Place a useful function or sub using this keyword here