ActiveX - Templates


Daisy Charts are often generated from templates either directly loaded into the program or selected with MenuGetTemplate.


Examples of LoadTemplate were shown in Drawing a Daisy Chart and Printing a Daisy Chart.

The actual code snippet is repeated :-

  Dim wrkError As String
  Dim wrkTemplate as String
  ...
  wrkTemplate = ...
  If (Daisy.LoadTemplate(wrkTemplate, True, wrkError) = False) Then
      Daisy.MessageError wrkError
      Exit Sub
  End If
  ...

This will load the template and draw a chart.

MenuGetTemplate just calls the dialog box and then draws the chart, if a template is selected.


Template Modification

In many cases the template is not to be used as is, but only after a small modification. A selection might be changed for example.

Daisy has several methods that can be used to copy and modify templates before they are loaded and used to draw charts.

It is recommended that you create a simple template with all of the mapping fields, aggregations and general settings, but no select, marks or aliases etc. This basic template would then be cloned, renamed and such things as title, select, aliases and marks would then be added before load it into Daisy.

It is not recommended that mapping fields and aggregations are added to the template as these have a large number of parameters. However simple modifications can be made using FileWriteProfileString.


The code snippet below shows the cloning of a template to a temporary file and the changing of the select.

  Dim wrkError As String
  Dim wrkTemplate as String
  Dim wrkNewTemplate as String
  ...
  wrkTemplate = ...
  wrkNewTemplate = Daisy.CloneTemplate(wrkTemplate, "", "New Name", _
      "", wrkError)
  If (wrkNewTemplate = "") Then
      Daisy.MessageError wrkError
      Exit Sub
  End If
  if (Daisy.SetTemplateSelect(wrkNewTemplate, "Value", "10000", _
          "30000") = False) Then
      Daisy.MessageError wrkError
      Exit Sub
  End If
  If (Daisy.LoadTemplate(wrkNewTemplate, True, wrkError) = False) Then
      Daisy.MessageError wrkError
      Exit Sub
  End If
  ...
  If (Daisy.FileKill(wrkNewTemplate,wrkError) = False) Then
      Daisy.MessageError wrkError
      Exit Sub
  End If

Note :-

  1. CloneTemplate creates a new template from the one defined.

    The method returns the path of the new template and this is blank if the clone was unsuccesful.

  2. SetTemplateSelect is then used to enter the select. Note that this method has several optional arguments.

  3. LoadTemplate is then used to load the template.

  4. After the template has been loaded, FileKill can be used to remove temporary files from the disc