From: Zex on 26 Jan 2010 06:15 I made two-dimensional array. This is my code: LOCAL aMedia AS ARRAY LOCAL dwLen AS DWORD LOCAL n := 1 AS DWORD aMedia := {} AAdd (aMedia,{"100","Text0"}) AAdd (aMedia,{"101","Text1"}) AAdd (aMedia,{"102","Text2"}) AAdd (aMedia,{"103","Text3"}) // here is the rest of the code......... AAdd (aMedia,{"113","Text13"}) AAdd (aMedia,{"114","Text14"}) AAdd (aMedia,{"115","Text15"}) dwLen := ALen(aMedia) // result for dwLen is 16, it is true FOR n := 1 UPTO dwLen ? aMedia [n][1], aMedia [n][2] n++ NEXT The result is: 100,Text0 102,Text2 104,Text4 106,Text6 108,Text8 ........ but it should be: 100,Text0 101,Text1 102,Text2 103,Text3 104,Text4 ...... What I did wrong? Zeljko.
From: Alessandro Antonangeli on 26 Jan 2010 06:25 Il Tue, 26 Jan 2010 03:15:18 -0800, Zex ha scritto: > I made two-dimensional array. This is my code: > > LOCAL aMedia AS ARRAY > > LOCAL dwLen AS DWORD > LOCAL n := 1 AS DWORD > > aMedia := {} > AAdd (aMedia,{"100","Text0"}) > AAdd (aMedia,{"101","Text1"}) > AAdd (aMedia,{"102","Text2"}) > AAdd (aMedia,{"103","Text3"}) > // here is the rest of the code......... AAdd > (aMedia,{"113","Text13"}) > AAdd (aMedia,{"114","Text14"}) > AAdd (aMedia,{"115","Text15"}) > > > dwLen := ALen(aMedia) > > // result for dwLen is 16, it is true > > FOR n := 1 UPTO dwLen > ? aMedia [n][1], aMedia [n][2] > n++ > NEXT > > The result is: > 100,Text0 > 102,Text2 > 104,Text4 > 106,Text6 > 108,Text8 > ....... > but it should be: > 100,Text0 > 101,Text1 > 102,Text2 > 103,Text3 > 104,Text4 > ..... > > What I did wrong? > > Zeljko. You put n++ inside a for next: remove it -- Ciao, Alessandro
From: Klaus on 26 Jan 2010 06:26 Hi Zeljko, nothing ;) FOR n := 1 UPTO dwLen ? aMedia [n][1], aMedia [n][2] NEXT and all is Ok regards Klaus On 26 Jan., 12:15, Zex <xvzel...(a)gmail.com> wrote: > I made two-dimensional array. This is my code: > > LOCAL aMedia AS ARRAY > > LOCAL dwLen AS DWORD > LOCAL n := 1 AS DWORD > > aMedia := {} > AAdd (aMedia,{"100","Text0"}) > AAdd (aMedia,{"101","Text1"}) > AAdd (aMedia,{"102","Text2"}) > AAdd (aMedia,{"103","Text3"}) > // here is the rest of the code......... > AAdd (aMedia,{"113","Text13"}) > AAdd (aMedia,{"114","Text14"}) > AAdd (aMedia,{"115","Text15"}) > > dwLen := ALen(aMedia) > > // result for dwLen is 16, it is true > > FOR n := 1 UPTO dwLen > ? aMedia [n][1], aMedia [n][2] > n++ > NEXT > > The result is: > 100,Text0 > 102,Text2 > 104,Text4 > 106,Text6 > 108,Text8 > ....... > but it should be: > 100,Text0 > 101,Text1 > 102,Text2 > 103,Text3 > 104,Text4 > ..... > > What I did wrong? > > Zeljko.
From: Karl Faller on 26 Jan 2010 06:34 Remove the n++ - the For loop increments n by itself ;-) Karl
From: Zex on 26 Jan 2010 07:11 On Jan 26, 12:34 pm, Karl Faller <k.faller_withoutth...(a)onlinehome.de> wrote: > Remove the n++ - the For loop increments n by itself ;-) > > Karl You are right. Thank you all. Zeljko
|
Pages: 1 Prev: "Inserting" into a font? Next: Application Code Error causing Access Violation HELP!!!! |