Test if object is a 4D Write Pro object

What is the best way (v17) to test if an object is a 4D Write object?

Maybe you could try to read a “must-exist” property, if it’s missing it’s not a write pro object.

Another lack is : how test if the 4D Write Pro object body part is empty ?

		$wp:=WP New
		$wp_body:=WP Get body($wp)
		$wp_text:=WP Get text($wp_body;wk expressions as source)
		If (Length($wp_text)<=0)
			ALERT("Body is empty !")
		End if 


Is there a reason why testing on empty string for WP Get text would not work?
I noticed inline images come as a space and a table as a bunch of returns and tabs. This might be OK to consider the body as not empty if it only contains an image or a (not filled) table.
Unless a body only having white space characters should be considered as empty?


Yes, but why not a command for that ?
Each developper should have this same method in each database to make this simple (but necessary) test…

This command can have some optional parameters (k really empty, k text empty, etc.)

But what if another non Write Pro object also has that very same must-exist property?

You may use a combination of properties (author+pageOrientation+title+company+notes, for example), it seems less likely.
Poor idea, I agree.

You can try using the command WP GET ATTRIBUTES to obtain the version value. If the object is not a true 4D Write Pro document, it should throw an error.

ON ERR CALL ("errCall")
WP GET ATTRIBUTES ($wpObject;wk version;$version_r)
1 Like

you’re right of course, this is just a very simple answer that everybody can inspired about :wink: