Hi Karl,
FFF wrote:Karl-Heinz,
with this:
VAR aDouble2 := <OBJECT>{ -23 , 276.45}
i think, you FORCE the compiler to treat the numbers as OBJECT, i.e. you "forbid" it to be "clever" and deduct the type.
Yes, that´s what i wanted
[...]
VAR aDouble2 := <OBJECT>{ -23 , 276.45}
the first Element holds an int, while the second element holds a float, Without to convert aDouble2[1] to a float the program crashes.
[...]
To round things off, i added another array, a <double> array,
Code: Select all
FUNCTION DoConsole2() AS VOID
LOCAL fTotal AS double
VAR aDouble := <OBJECT>{0.00,276.45,276.45}
VAR aDouble2 := <OBJECT>{-23,276.45}
VAR aDouble3 := <DOUBLE>{123 ,-1276.45}
Console.WriteLine("{0,12:###,##0.00}" + "{1,12:###,##0.00}" + "{2,20:###,###,##0.00}" , aDouble)
fTotal += (double) aDouble [ 3 ]
aDouble [ 1 ] := (double) -1223.56
aDouble [ 2 ] := (double) 122
aDouble [ 3 ] := (double) aDouble [ 1 ] + (double) aDouble [ 2 ]
Console.WriteLine("{0,12:###,##0.00}" + "{1,12:###,##0.00}" + "{2,20:###,###,##0.00}" , aDouble)
fTotal += (double) aDouble [ 3 ]
// aDouble [ 1 ] := (double) aDouble2 [ 1 ] // this fails because aDouble2[1] holds an none float -> -23
// aDouble [ 2 ] := (double) aDouble2 [ 2 ] // this would work, because aDouble2[1] holds already a float -> 276.45
aDouble [ 1 ] := Convert.ToDouble ( aDouble2 [ 1 ] )
aDouble [ 2 ] := Convert.ToDouble ( aDouble2 [ 2 ] )
aDouble [ 3 ] := (double) aDouble [ 1 ] + (double) aDouble [ 2 ]
Console.WriteLine("{0,12:###,##0.00}" + "{1,12:###,##0.00}" + "{2,20:###,###,##0.00}" , aDouble)
fTotal += (double) aDouble [ 3 ]
aDouble [ 1 ] := aDouble3 [ 1 ] // <DOUBLE> array - no cast or convert necessary > 123
aDouble [ 2 ] := aDouble3 [ 2 ] // <DOUBLE> array - no cast or convert necessary > -1276.45
aDouble [ 3 ] := (double) aDouble [ 1 ] + (double) aDouble [ 2 ]
Console.WriteLine("{0,12:###,##0.00}" + "{1,12:###,##0.00}" + "{2,20:###,###,##0.00}" , aDouble)
fTotal += (double) aDouble [ 3 ]
// 12 + 12 == 24
Console.WriteLine(space ( 24 ) + repl ( "-" , 20 ) )
// 12 + 12 + 20 == 44
Console.WriteLine("{0,44:###,###,##0.00}" , fTotal )
RETURN
regards
Karl-Heinz