Howdy,

Here's your v4 tip for the day:

NEW ARRAY APPENDING SYNTAX
--------------------------
One of the coolest new additions to the language is the new syntax for appending elements to an array. All you do is specify an empty index, like this:

  array longint($types; 0)
  $types{} := 7

This syntax is (to my eyes) much clearer than:

  append to array($types; 7)

Basically, what happens internally is an element is appended to the array and the index is set to the new last element of the array.

What makes this syntax really cool is that it can be used anywhere you can use an element, including as a reference method parameter or as the target of a command parameter. For example, you can do stuff like this:

  array longint($types; 0)
  $table := table(->[vendors])

  for ($field; 1; count fields($table))
     get field properties($table; $field; $types{})
  end for

At the end of this code, $types is nicely filled with [vendors] field types.

Have fun!

Regards,

   Aparajita
   Victory-Heart Productions
   www.aparajitaworld.com

   "If you dare to fail, you are bound to succeed."
   - Sri Chinmoy   |   www.srichinmoylibrary.com

_______________________________________________
Active4D-dev mailing list
[email protected]
http://mailman.aparajitaworld.com/mailman/listinfo/active4d-dev
Archives: http://mailman.aparajitaworld.com/archive/active4d-dev/

Reply via email to