Introduction of Generic in CRMScript

Hi all,

In the next release of SuperOffice CRM, we are planning to introduce a new feature in CRMScript: Generic. This is a new variable type which is the base type of all other types. Any variable can be upcasted to a Generic, and we then have some methods you can use to ask what type a Generic really is, support for downcasting to a basic type (String, Integer, etc), and some other stuff.

The reason for this is the desire to be able to iterate variables, specifically struct members, in a loop instead of having to hardcode each one of them. Say for instance you have a struct Building with variables name, location, floors, hasJanitor, etc. The variables would be of different types (String, Integer, Bool). Traditionally you would have to hardcode getting and setting these variables. With different methods accessing this struct, such as serializing or database-CRUD'ing, you would get blocks of code repeating the same variables names multiple places. This implementation is prone to typing-errors, and is also cumbersome when e.g. adding new variables to the struct. With our new support for Generic, you can get a list of all the variables in a struct, and access them all in a programmed loop instead. Since any variable can be upcasted to a Generic, it will also now be possible to create functions accepting Generic as parameter, and then call the function for any variable of any type.

The new functionality introduces a new variable type: "Generic". This becomes a reserved word. If you have scripts already using this word (same casing), they will have to be rewritten before upgrading. I hope and believe this should be no-one.

Furthermore, we are introducing functions which allow you to get any run-time variable by its name, lookup what type and array dimensions it has, downcast it to a basic type, and conversion to/from a string.

This is just an early notice, specifically to warn about "Generic" becoming a reserved keyword. If there are many of you who believe you have used this word, we might have to choose another. We will post more details about this functionality when it gets released.

Sverre

RE: Introduction of Generic in CRMScript

Much love!

Looking forward to it! Don't think we've ever used "Generic", so no problems here.

Av: Frode Lillerud 21. aug 2019

RE: Introduction of Generic in CRMScript

Seems like a nice feature. 

I'll have to stop using Generic as variable names :p

Av: Simen Mostuen Iversen 21. aug 2019