How to save back the value of an object in BarTender to a file using the new Form Actions?
Although there might be different ways to approach it, here is an example to get you started:
1. Create a Named Data Source and link it to the object whose value you want to save back, for example 'serial' in this case:
If you need further information on how to create Named Data Sources you can find it here:
2. Create an object on the Form and link the Named Data Source to it, so that the value entered on the form is used by all the objects linked to that Named Data Source (there could be more than one):
Further information on Forms can be found here:
3. On the Form properties (you need to make sure the whole form is selected), click on the Actions button:
This will open the screen for creating and customizing the actions that will take place after a certain event on the Form has happened.
4. On the Validate Data event add a Write File action:
5. To save the value of the object on the form (in this example, the value of the Named Data Source 'serial'):
- Use a Variable Source
- Set the variable to %serial% (this you variable you can insert easily by clicking on the 'Insert Variable' icon on the bar)
- Define the path and name of the file that is going to be generated
- Make sure that the option 'Append to file if it already exists' is selected (so that the new values for the object are saved in the same file (and not overwritten nor copied across different files)
The result should be similar to this here below:
Now, the above would create in a TXT file all the values entered on the Form for that 'serial' object but, it would insert them concatenated, as we have not defined any kind of separation.
In order to do that, we can simply:
- Change the source value to 'Embedded Template'
- On the value insert:
- The variable name (making use as well of the 'Insert variable' option)
- A break line (enter key) so that each time a new value is inserted a break line is inserted below it (this way you would have a column of values on your Excel file)
** Note that in this example I am using a break line but you could insert any other kind of separator after the variable (for example a comma delimited file that could be imported into Excel)
The result should be similar to this: