Developers need to be able to use nulls if using SQL engine and 4DB engine in 4D. As of this writing the concepts of NULL values are very loosely integrated with 4D.
NULL Values in 4D
The NULL values are implemented in the 4D SQL language as well as in the 4D database engine. However, they are not supported in the 4D language. It is nevertheless possible to read and write NULL values in a 4D field using the Is field value Null and SET FIELD VALUE NULL commands.
Never mind the very logic of a null value is to indicate not set. Mapping null values to ‘blank’ values only mucks up the data. Does a widget inventory level of 0 indicate ‘not yet set’ or ‘depleted to zero’? Yes business logic will clear these things up, but integration of null values with the 4D native engine would be better.
// http://doc.4d.com/4Dv11.6/help/command/en/page965.html // This is a useless command, and is only used by the SQL kernal of 4D SET FIELD VALUE NULL([Table_1]Field_1) // having a null keyword would be useful [Table_1]Field_1:=null
For example, you cannot search null values using the standard query window. Also, variables cannot accept null values. Null comparisons are limited to Is field value Null which can only look at fields.
Seems as if 4D is not giving developers all the tools to make a hybrid deployable solution. Its been my experience to code solutions that either go 100% native 4D code or go 100% SQL engine, because integrating both together is a pain.
4D does annoying things like convert null values to blank values when trying to display them in an object, or puts into object property definitions display attributes to control how null values are rendered.
See my comments on float data types.



Use 4D header macro to identify code blocks
June 2, 2011 by James
Standard installation of 4Dv11 comes with a set of macros to use in design mode.
The one I find most useful is the
Headermacro. This macro takes my name, date time stamp, the method name and places it directly into whatever type of method I’m working in.Most analogous to function/class/package documentation blocks in other languages, they are also an excellent starting point for other developers looking at your code. In 4D specifically, header blocks also serve as insurance against a corrupted structure file.
After repairing a corrupted structure file,
orphan method(s)can appear without context. The orphan methods are not linked to the original code, and the type of method (object/form/project) and original method name are lost.Worse, the repair process could have replaced the original code in it’s entirety with a comment “
automatically repaired method“.The
method_nametag of the macro generates the text as shown in the title portion of the method editor. So a project method will renderMethod: Project_Methodwhile form and object methods will renderMethod: Form Method [Table]FormandMethod: Object Method [Table].Form.Objectrespectively.A header documents all the missing information to find the original code location and the confidence to delete or restore the orphan code. Having the headers in place has definitely saved me lots of time analyzing and recovering from a structure corruption.
Example Macro
Note The above macro is formatted for v11. 4D v12 has
//for commenting out linesA tech tip on creating header content automatically.
4D Tech Tip – Header Macro
Share this:
Like this:
Posted in 4D | Tagged 4D, auto-comment, automatically repaired method, clean code, corrupt, macro, method header, orphan method, structure | Leave a Comment »