You may have seen this error message or it variations while compiling your snippets in EventIDE. Or, you will probably see it soon. What is it about? In this post I will explain why this error appears and how to get rid of it.
In the present version of EventIDE a modern programming language, C#, is used for snippet coding. Nowadays, C# is successor of C and C++ in professional programming community. Similar to C++ and other, C# is statically-typed language. It means that you have to define explicitly a type for each of your variables (and you can not change it afterwards). There any many types in C# that you can flexibly choose, for example one of 9 different types just the integer numbers. Knowing in advance what type is a variable helps compiler to generate a fast code and efficiently manage a memory. This is why the statically typed languages are popular among professionals.
In other hand, statically typed languages are less comfortable in use. You always have to remember what variables types you introduced and manage type conversions if necessary (for example, when different numerical types are met in the same expression). If you do it wrong, you get an error message similar to one in the header of this post. Then you need to take care of type conversion.
There are several methods for type conversion in C#:
This is the easiest one, since C# compiler makes all job itself. Your types are converted automatically in the following cases:
if a conversion cannot be made without a risk of losing information, the compiler requires that you perform an explicit conversion. It could be done either by type cast or by a set of converting functions of the system Convert class:
Explicit conversions are recommended in the most of the cases but they are unsafe, since can cause runtime exceptions if the converted value does not fall in the proper range. Use them carefully.
Conversions of EventIDE proxy variables
- ulong(unsigned long integer) type for timing properties, like Duration, Trigger Time and so on.
- floattype for coordinates and sizes in visual degrees
- intfor position/sizes in pixels
- doubletype for ratios, parameters and range properties, like a contrast ratio or playback position
- byte type for a single color channel