encoding from array

encoding from array

Postby Silvio.Falconi » Fri Feb 26, 2016 12:19 pm

I must take the numbers at n position of plinestring array

for z= 1 or 2 or 3 it run ok
for z= 4 make error ( return the wrong numbers) why ?


Code: Select all  Expand view


#include "fivewin.ch"

function test()
Local aline[3]
Local nposition[5]
Local nLine
Local nNumbers [5]
Local plinestring[4]
local z,k,n
local nCol

aline[1]:= {1,3,6,7,1}
aline[2]:= {3,1,6,1,9}
aline[3]:= {9,3,1,7,9}

plinestring[1]:="bbbbb"
plinestring[2]:="aaaaa"
plinestring[3]:="ccccc"
plinestring[4]:="abcba"


z:=4

       nposition[1]:= substr(plinestring[z],1,1)
       nposition[2]:= substr(plinestring[z],2,1)
       nposition[3]:= substr(plinestring[z],3,1)
       nposition[4]:= substr(plinestring[z],4,1)
       nposition[5]:= substr(plinestring[z],5,1)


    //  xbrowser  nposition

For k= 1 to 5   // numeri
       For n= 1 to 5  //position
           nCol:= k
     If nposition[n]= "a"
          nline:= 1
       elseif nposition[n]= "b"
          nline:= 2
       elseif nposition[n]= "c"
          nline:= 3
       endif



   nNumbers[k]:=  aline[nline] [nCol]

next
nCol:= 0
nline:= 0
next


  xbrowser  nNumbers

  return nil


if z= 1 return 3,1,6,1,9 ok
if z= 2 return 1,3,6,7,1 ok
if z= c return 9,3,1,7,9 ok
if z= 4 return 99999 bad why ? ( it must return me 11111)
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7047
Joined: Thu Oct 18, 2012 7:17 pm

Re: encoding from array

Postby James Bott » Fri Feb 26, 2016 3:07 pm

Silvio,

I don't see the problem you are seeing. When I run it I get 1,3,6,7,1 not 9,9,9,9,9.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: encoding from array

Postby Silvio.Falconi » Sat Feb 27, 2016 9:12 am

sorry ,
also 1,3,6,7,1 is bad

if the z= 4 must return me 11111
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7047
Joined: Thu Oct 18, 2012 7:17 pm

Re: encoding from array

Postby Silvio.Falconi » Sat Feb 27, 2016 9:28 am

perhaps I found the error

For k= 1 to 5 // numeri

If nposition[k]= alltrim("a")
nline:= 1
elseif nposition[k]= alltrim("b")
nline:= 2
elseif nposition[k]= alltrim("c")
nline:= 3
endif


nNumbers[k]:= aline[nline][k]

next k


nopw seem to run ok
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7047
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 50 guests