ghkweon / dwscript

Automatically exported from code.google.com/p/dwscript
0 stars 0 forks source link

No way to enumerate JSONVariant array elements in a FOR loop #459

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
If I have a variable of type JSONVariant, I would expect the following to 
compile:

for var i := 0 to myVar.Length - 1 do

Instead, I get "Syntax Error: Integer expected."  It appears that 
dwsJSONConnector defines the Length method as returning an integer in 
TdwsJSONConnectorType.HasMethod, but this is never actually called during 
compilation, so the expression's type comes out as Variant instead.

Original issue reported on code.google.com by masonwhe...@gmail.com on 29 Mar 2014 at 7:17

GoogleCodeExporter commented 8 years ago
Length is for accessing an hypothetical field named "Length", however there is 
a pseudo-method Length() which will return the number of elements, the () allow 
to differentiate.
There are several other pseudo methods which work in the same way: Low(), 
High() & TypeName(). The other pseudo-methods are less problematic as they 
require at least one parameter.

Original comment by zar...@gmail.com on 29 Mar 2014 at 8:13