Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 3 of 3 total |
Javascript arrays |
Wed, Feb 1 2012 7:17 PM | Permanent Link |
Robert Devine | Hi Tim
I'm trying various ways of accessing array properties in external JS code. If I do the following in JS: this.TestArray = function(){ return [10, 20, 30]; } this.TestArray2 = [4, 5, 6, 7]; and in EWB: TIntegerArray = array of integer; external TDAClient = class public function TestArray: TIntegerArray; property TestArray2: TIntegerArray read; end; 1. TestArray: I can get the length of the array from the EWB code, but if I access any of the members then I get a NaN. 2. TestArray2: If I try and read this property then the EWB code won't compile ("the referenced variable,... TestArray2 does not exist). Any ideas? Thanks again, Bob |
Wed, Feb 1 2012 7:54 PM | Permanent Link |
Robert Devine | I think I'm part of the way there. I used:
external TIntegerList = class public property items[index: Integer]: integer read; default; property length: Integer read; end; property TestArray2: TIntegerList read; I can get the values with this. Investigating other types now... Cheers, Bob On 02/02/2012 00:17, Bob Devine wrote: > Hi Tim > > I'm trying various ways of accessing array properties in external JS > code. If I do the following in JS: > > this.TestArray = function(){ > return [10, 20, 30]; > } > this.TestArray2 = [4, 5, 6, 7]; > > and in EWB: > > TIntegerArray = array of integer; > > external TDAClient = class > public > function TestArray: TIntegerArray; > property TestArray2: TIntegerArray read; > end; > > 1. TestArray: I can get the length of the array from the EWB code, but > if I access any of the members then I get a NaN. > > 2. TestArray2: If I try and read this property then the EWB code won't > compile ("the referenced variable,... TestArray2 does not exist). > > Any ideas? > > Thanks again, Bob |
Fri, Feb 3 2012 8:07 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Bob,
<< I think I'm part of the way there. I used: external TIntegerList = class public property items[index: Integer]: integer read; default; property length: Integer read; end; property TestArray2: TIntegerList read; I can get the values with this. Investigating other types now... >> That is exactly correct. Any psuedo-object in JS that acts like an array, but has properties also, should be treated like an object whose default property is an array property. That's how I handle all of the DOM arrays for node lists, etc. -- Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Friday, September 13, 2024 at 03:42 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |