Field-Map Scripting

2.5.4 On-Demand scripts

On-Demand script


This kind of a script is not bound to any data fields or events and it is executed manually by a user when needed. Generally, on-demand scripts are used for analysis and data manipulation on plot level, such as detailed data verification, selection of sample trees etc.


Example 1:

The following On-Demand script filters trees marked as vitality sample trees.

begin
  Trees.Filter := 'Vitality_sample_tree=1';
  // Value "1" (a lookup list item ID) stands for "yes" (a lookup list value).
  Trees.Filtered := true;
end.



When the filter is not needed anymore, it should be possible to reset it (by another On-Demand script):

begin
  Trees.Filtered := false;
end.




Example 2:

The following script demonstrates how to traverse all the records in a table ("Trees') and reset all the values of the field "Measurability'.

begin
  Trees.SavePosition;
  Trees.First;

  while not Trees.EOF do
  begin
    Trees.Edit;
    Trees['Measurability'] := 200;
    Trees.Post;
    Trees.Next;
  end;

  Trees.RestorePosition;
end.


See also:                

Field-Map script types overview; On-Validate scripts; On-Change scripts; On-Demand scripts; Layer scripts; Global scripts; Field-Map script types; Writing scripts in Field-Map