Trust ID PBCEX logo 300x102

Does the new designer support scripts?

7 years 8 months ago
Rutger Koperdraad
Platinum Boarder
Platinum Boarder
Posts: 1566
More
Topic Author
Does the new designer support scripts? #2175
A customer came up with the following questions:
  1. Does the new designer support scripts like in the old designer with Delphi? I thought you mentioned Python, or is Python only in the Front end ?
  2. I also assumes card templates with scripts embedded wont migrate.

Well, good news for everybody who that liked the scripting feature in the old designer! The new designer does support scripts. As scripting language it uses IronPython, which is the .NET implementation of the well-known scripting language Python.

If you select an object in the new designer, open the properties window and look into the content tab, you see an expression box. Here you can type any Python expression. After pressing enter or leaving the expression box, CardExchange detects whether you used any new variables in your script and, if so, it prompts for default values.

A very simple expressions would be just a single variable name. This name will appear in the mappings window and can be mapped to a database field or whatever type of data you want to use. Concatenation can easily be done with the '+' sign, for example FirstName + ' ' + LastName.

You can look up your variables in the Variables tab of the Properties window. Here, you can delete the, if they are not used anymore and change the default value. If the variable is used to represent an image, you can click the Image button with of it to select a default image.

Expressions can not only be used for the content of an object (text or image), but for any property of an object, via the Expressions tab (you need the Ultimate edition for that). Please, note that the visibility property expects one of these values: 'Visible', 'Hidden', 'Collapsed'. Hidden and collapsed are equivalent in most cases, but might be different for complex constructs.

The Python language is extensively documented on http://docs.python.org/ . Specific extensions for IronPython are documented on http://ironpython.net/ . IronPython allows for calling .NET assemblies from withing Python functions.

In the Functions tab of the Properties window it is possible to define Python functions and global variables. If you want to get an idea of what is possible, just migrate an old design to version 7. You will see that the migrated template contains a bunch of functions that are the Python implementation of the most functions that were available in the old designer.

That also answers the second questions: yes, you can migrate templates with scripts. Very complex scripts might require some additional modifications, especially if you were using statements after the value in the old designer (like [<Age>; if <Age> < 18 then Memo1.Color := clRed else Memo1.Color := clBlack]).

If this super flexible scripting implementation using a public langauge that is publicly available documentation leaves any desires unsatisfied, please, reply to this post.

regards,
Rutger.

Rutger Koperdraad
Senior Software Engineer

"A reasonable man adapts himself to the world. The unreasonable man persists in trying to adapt the world to himself. All progress, therefore, depends on the unreasonable man." (Bernard Shaw)
×

Notice

The forum is in read only mode.