LiveCode for FM ManualStatus IndicatorsHow do I generate a progress bar in a calculation field?

How do I generate a progress bar in a calculation field?

Calculation Fields

Calculation fields in FileMaker allow you to calculate a field value based on the value of other fields in the table. LiveCode for FM is very easy to use to return any type of field value including binary values for container fields. We can easily export images from objects on LiveCode stacks and return them so that we can have a dynamically updating calculation field. This example uses LCExec, however, it would be easier to develop more interesting data visualisations using custom components.

Create a table with a `Value` number field and a `Progress` calculation field then open the `Field Options` dialog via the `Options...` button.

Field Options

Set the `Calculation result is` option button to `Container` and set the calculation to the following script then click on the `Storage Options...` button.

LCExec ( 
  "create invisible stack \"progress\";
  set the defaultStack to \"progress\";
  create scrollbar \"progress\";
  set the style of scrollbar \"progress\" to \"progress\";
  set the endValue of scrollbar \"progress\" to 100;
  set the thumbPosition of scrollbar \"progress\" to fmParam(1);
  set the width of scrollbar \"progress\" to 200;
  put \"binary\" into tData[\"type\"];
  put \"PNGf\" into tData[\"main\"];
  put 200 into tData[\"width\"];
  put the height of scrollbar \"progress\" into tData[\"height\"]
  export snapshot from scrollbar \"progress\" to tData[\"value\"][\"PNGf\"] as PNG;
  delete stack \"progress\";
  return tData"
; Value )
Click to copy

Check the `Do not store calculation results -- recalculate when needed` option to avoid saving the image to disk.

Testing

Add the value and progress fields to a layout. In the layout below I have set the progress field to `Minimal Container` style and disabled entry so if the user clicks on it the field will not be selected.

0 Comments

Add your comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.