25. Mai 2012

Macros in V12.4

Finally, some macro-bugs of V12 are fixed. method_event=on_open does work, as does SET MACRO PARAMETER(Full method text;$replaceText). Great! But now

macrosV12_folded

some deficiencies get obvious

concerning the concepts behind running 4D-code from macros.

Concerning the method-editor itself:

  1. SET MACRO PARAMETER(Full method text;$replaceText) behaves like pasting text, the complete method is expanded again.
  2. I.e. working in line 878 throughs you back some 800 lines of code, unfoldes everything.
  3. two empty lines on top of the method are added, with every save another two
  4. those empty lines are added, even when no white space is included in the macro like
    <text><method>DBZversions("Sichern";"<method_name/>")</method></text>

The extra empty lines can be overcome by clearing leading empty-lines before inserting $replaceText. I could handle two empty lines at the top, sort of.

In V2004, the macro had to be called manually. That didn't disturb the work with the old method-editors of V11 and V2004, because these did not keep track of the folding status anyway. And calling manually, was done less often.

macrosV12_unfolded

4D method-editor keeping track of folded status is a huge productivity-enhancement! No way of giving up on that feature, neither folding nor syntax-coloring!

If this were my coding, I'd paste the returned method-text as V12 does at first place. Not long after I'd be annoyed and therefor would immediately after the paste run the Rebuild_Folding_Status-service again! Probably an eat-your-own-dogfood-problem.

Help yourself, never wait for a bug-fix – hot or cold! What else could I do to

  • keep the folding state of the method and
  • keep track of the method-version in the comment-area?

Macro-attributes to rescue?

How abouts using the the macro-attribute method_event with attribute-values on_save and on_close*? Only running SET MACRO PARAMETER(Full method text;$replaceText) when closing and only then loosing the folding status. Sounds acceptable, or does it?

  • on_save runs when the method is saved
  • on_close runs as expected on close.
  • Here is the catch: pitifully on_close also runs when changing from Design to Runtime. Changing modes should not trigger an on_close event, triggering on_save is fine.

Helping myself by only updating the method when closing and not with every save is not working.

SET MACRO PARAMETER(Full method text;$replaceText) did not work in 12.0 - 12.3. That was a pity. But now it's worse: back to old editor-behaviour not keeping track of folded states. Terrible! Punishing myself while debugging with unfolding of the current method is a nightmare!

In need for something better

The main reason to use SET MACRO PARAMETER(Full method text;$replaceText) at all is to alter the version-number inside the head-comment area of the method. Which looks like
  // Anwender (OS): O. Zillgen, 29.04.11, 16:54:03
  // vcs_Version=000429
  // Methode: Artikel_Mngr
and is very helpful.

What I really need!

I'd like to "inject" the version-number, changing from 000429 to 000430 in this example after the next save. While we are at it: injecting version date and time would be nice, too.

Any idea, help or workaround appreciated. Thanks!

Related article

* while being at it! That online doc.4d.com is another productivity-killer – mainly when needed, like looking for macro-attributes and -values or some other hidden stuff – the www for wait wait wait is back