4D Blog

Home Product 4D Write Pro – Document Modification Detection

4D Write Pro – Document Modification Detection

October 17, 2022

Product

When a 4D Write Pro document is in edit mode, it’s often helpful to know if it has actually been modified by the end user. Based on this information, actions or interfaces can be adjusted to be more user-friendly.

Starting with 4D v19 R7, this is now easier than ever.

DEMO DATABASE

MODIFIED DOCUMENTS

A document can be modified in different ways. Either:

  • by programming using one of the many commands or
  • by the end-user himself.

A modified document must generally be saved, whether in terms of content (addition, modification, deletion of text, tables, or images…) or appearance (style, margins, orientation, colors…).

In any case, you must be able to offer the possibility to save it via a button or a menu, and in the extreme case where the user would like to leave without having saved it, be able to offer him a catch-up option (“do you want to save…?”).

This is now very quickly done by testing the new document.modified attribute.

The principle of this attribute is straightforward. When the document is created or loaded, its value is set to False. Then, as soon as the document is modified (by programming or user action), the value automatically changes to True.

It becomes straightforward to make the right decisions 🙂

  • Update the interface
	OBJECT SET ENABLED(*; "btnSave";WParea.modified) // true or false
  • Confirm saving
If (Form event code=On Unload)
	If (WParea.modified)
		CONFIRM("Would you like to save the document ?"; "Save"; "Discard")
		If (ok=1)
			// do what you have to do
		End if 
	End if 
End if 

Whether it’s a space deleted or a comma added, a single character bolded or italicized, it will set the document.modified to True. Even in case of an undo, document.modified will remain True.

It is, however, possible to force the value of this attribute by programming, for example, once the document has been saved.

If (WParea.modified)
	// save document
	// (…)
	// then set the status to false
	WParea.modified:=False  // will stay false until next document modification
End if 

 … OR NOT MODIFIED?

Some actions can only change the appearance of the documents without actually changing the document’s content; these are the view properties.

You can change the zoom factor, display or not the horizontal and vertical rulers, choose to show the invisible characters, formulas, headers or footers, etc. None of this will be saved. This means that the document is not modified and, therefore, the document.modified attribute remains False. See the documentation about this new attribute.

Conclusion

This new and straightforward property will quickly detect changes inside a document and perform actions accordingly. Either transparently (making automatic saves when a document remains open, for example) or modifying the interface intelligently according to the circumstances!

Discuss

Tags 4D Write Pro, v19 R7, v20, Word processor

Latest related posts

  • May 20, 2025

    Automatic Refresh of OEM Build Licenses

  • May 16, 2025

    New class to handle incoming TCP connections

  • April 29, 2025

    Discover your AI-powered writing assistant in 4D Write Pro

Roland Lannuzel
Roland Lannuzel
• Product Owner & 4D Expert •After studying electronics, Roland went into industrial IT as a developer and consultant, building solutions for customers with a variety of databases and technologies. In the late 80’s he fell in love with 4D and has used it in writing business applications that include accounting, billing and email systems.Eventually joining the company in 1997, Roland’s valuable contributions include designing specifications, testing tools, demos as well as training and speaking to the 4D community at many conferences. He continues to actively shape the future of 4D by defining new features and database development tools.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • 4D View Pro
  • 4D Write Pro
  • 4D for Mobile
  • Email
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • Qodly Studio
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Google Listbox Logs Mail Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Google Listbox Logs Mail Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor
Subscribe to 4D Newsletter

© 2025 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

Contact us

Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!

* Your privacy is very important to us. Please click here to view our Policy