|Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread|
|Messages 1 to 6 of 6 total|
|Problem with array constants|
|Fri, May 25 2018 3:02 AM||Permanent Link|
// This compiles...
array1 : array of string = ['11', '22'];
array2 : array of string = ['11', '2'];
array3 : array of string = ['1', '22'];
// ...but on this I get a compiler error:
array4 : array of string = ['1', '2'];
// [Error] Main.wbs (11,30): Expected array of String but instead found
|Fri, May 25 2018 4:04 AM||Permanent Link|
Michael Dreher wrote:
> ['1', '2'];
Just a ponder - is it thinking those are both chars? The other examples have more than one character each.
|Fri, May 25 2018 5:08 AM||Permanent Link|
"Matthew Jones" wrote:
// Just a ponder - is it thinking those are both chars? The other
// examples have more than one character each.
That also came to my mind. But chars are assignable to strings.
I just did another test, int vs. float:
arr1 : array of double = [1.1, 2.2];
arr2 : array of double = [1, 2];
// [Error] Unit1.wbs (32,28): Expected array of Double but instead found
arr3: array of double = [1, 2.2];
// [Error] Unit1.wbs (34,31): Expected integer, variant, or enumeration but instead found 2.2
arr4: array of double = [2.2, 1];
Seems the order of elements also has an effect.
|Fri, May 25 2018 10:48 AM||Permanent Link|
On 5/25/2018 3:02 AM, Michael Dreher wrote:
> array4 : array of string = ['1', '2'];
Casting issue. Try
array4 : array of string = [String('1'),String('2')];
|Mon, May 28 2018 2:10 AM||Permanent Link|
// Casting issue. Try...
Thanks for the hint. It seems sufficient to just cast the first array element.
|Tue, May 29 2018 1:53 PM||Permanent Link|
Tim Young [Elevate Software]
Elevate Software, Inc.
<< // [Error] Main.wbs (11,30): Expected array of String but instead found >>
I think that Matthew is correct and the compiler thinks that the array elements are characters, not strings. As far assignability is concerned, yes, characters are normally assignable to strings. However, EWB expects arrays to be consistently characters or strings because it reserves the right to optimize these in its runtime so that they are not just big arrays of "variants".
I'll have a fix for this in the next build 15.