文本表单上的每个项都具有已修正数据标记,此标记是一个状态值,它指示是否认为用户自上次显示表单后更改了表单项。
项的已修正数据标记与项的 modified 属性不同,后者是在程序中设置的并且预设已修正数据标记的值,如后文所述。
用户通过在项中输入字符或通过删除字符来设置已修正数据标记。在提交表单之前,已修正数据标记保持已设置状态,即使用户将字段内容恢复为最初显示的值亦如此。
由于错误而重新显示表单时,表单仍处理同一个 converse 语句。因此,当重新显示表单时,在执行 converse 时被修改的任何字段都将已修正数据标记设置为 yes。例如,如果将数据输入到带有验证器函数的字段中,则该函数可以调用 ConverseLib.validationFailed 函数来设置错误消息并导致重新显示表单。在这种情况下,由于字段的已修正数据标记仍设置为 yes,所以,当操作键被按下时,验证器函数将再次执行。
set 语句影响 modified 属性的值,但不影响已修正数据标记的当前设置。if item modified 类型的测试基于上次将表单数据返回至程序时正在起作用的已修正数据标记值。如果在逻辑第一次显示表单之前尝试测试项的已修正数据标记,则在运行时会发生错误。
以下逻辑显示了各种测试的结果:
// tests false because a converse statement // was not run for the form if (form01 is modified) ; end // causes a run-time error because a converse // statement was not run for the form if (item01 is modified) ; end // assume that the user modifies both items converse form01; // tests true if (item01 is modified) ; end // tests true if (item02 is modified) ; end // sets the modified property to no // at the next converse statement for the form set item01 initialAttributes; // sets the modified property to yes // at the next converse statement for the form set item02 initialAttributes; // tests true // (the previous set statement takes effect only // at the next converse statement for the form if (item01 is modified) ; end // assume that the user does not modify either item converse form01; // tests false because the program set the modified // data tag to no, and the user entered no data if (item01 is modified) ; end // tests true because the program set the modified // data tag to yes if (item02 is modified) ; end // assume that the user does not modify either item converse form01; // tests false if (item01 is modified) ; end // tests false because the presentation was not // the first, and the program did not reset the // item properties to their initial values if (item02 is modified) ; end