matriz 8x8

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
jairpinho
Posts: 420
Joined: Mon Jul 18, 2011 5:36 pm
Location: Rio Grande do Sul - Brasil
Contact:

matriz 8x8

Post by jairpinho »

there is a function to add data on a bidirectional array Array (8.8)

ex.
aQuery[1][1] := 10
aQuery[1][2] := 20
aQuery[1][3] := 30
aQuery[1][4] := 40
aQuery[1][5] := 50
aQuery[1][6] := 60
aQuery[1][7] := 70
aQuery[1][8] := 80

aQuery[2][1] := 100
aQuery[2][2] := 200
aQuery[2][3] := 300
aQuery[2][4] := 400
aQuery[2][5] := 500
aQuery[2][6] := 600
aQuery[2][7] := 700
aQuery[2][8] := 800


aQuery[i2] := oRow:FieldGet(i2) ok It works normal

AADD(aQuery[i2], oRow:FieldGet(i2) ) It does not work
Last edited by jairpinho on Mon Apr 24, 2017 5:37 pm, edited 1 time in total.
Jair Pinho
HMG ALTA REVOLUÇÃO xBASE
HMG xBASE REVOLUTION HIGH
http://www.hmgforum.com.br
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: matriz 8x8

Post by mol »

Are you sure that aQuery[12] is array?
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Re: matriz 8x8

Post by Pablo César »

Olá Jair,

AADD(aQuery[I2], oRow:FieldGet(I2) ) está adicionando outro elemento dentro do outro elemento na posição 12 em aQuery[I2].
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
jairpinho
Posts: 420
Joined: Mon Jul 18, 2011 5:36 pm
Location: Rio Grande do Sul - Brasil
Contact:

Re: matriz 8x8

Post by jairpinho »

jairpinho wrote: Mon Apr 24, 2017 5:04 am there is a function to add data on a bidirectional array Array (8.8)

ex.
aQuery[1][1] := 10
aQuery[1][2] := 20
aQuery[1][3] := 30
aQuery[1][4] := 40
aQuery[1][5] := 50
aQuery[1][6] := 60
aQuery[1][7] := 70
aQuery[1][8] := 80

aQuery[2][1] := 100
aQuery[2][2] := 200
aQuery[2][3] := 300
aQuery[2][4] := 400
aQuery[2][5] := 500
aQuery[2][6] := 600
aQuery[2][7] := 700
aQuery[2][8] := 800


aQuery[i2] := oRow:FieldGet(i2) ok It works normal

AADD(aQuery[i2], oRow:FieldGet(i2) ) It does not work
Jair Pinho
HMG ALTA REVOLUÇÃO xBASE
HMG xBASE REVOLUTION HIGH
http://www.hmgforum.com.br
edk
Posts: 909
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: matriz 8x8

Post by edk »

In this case, the array item assigns a new value:

Code: Select all

aQuery[i][i2] := oRow:FieldGet(i2)   ok It works normal
And in this case, you try to add a new array item:

Code: Select all

AADD(aQuery[i][i2], oRow:FieldGet(i2) )    It does not work
If you want to add a new array item I think you should do this:

Code: Select all

AADD(aQuery[i], oRow:FieldGet(i2) )
Ps. For the future, try to use [ code ] tags, because as it is now, [ i ] treat it as italics.
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Re: matriz 8x8

Post by Pablo César »

jairpinho wrote: Mon Apr 24, 2017 5:38 pm
jairpinho wrote: Mon Apr 24, 2017 5:04 am there is a function to add data on a bidirectional array Array (8.8)

ex.

Code: Select all

aQuery[1][1] := 10
aQuery[1][2] := 20
aQuery[1][3] := 30
aQuery[1][4] := 40
aQuery[1][5] := 50
aQuery[1][6] := 60
aQuery[1][7] := 70
aQuery[1][8] := 80

aQuery[2][1] := 100
aQuery[2][2] := 200
aQuery[2][3] := 300
aQuery[2][4] := 400
aQuery[2][5] := 500
aQuery[2][6] := 600
aQuery[2][7] := 700
aQuery[2][8] := 800


aQuery[i][i2] := oRow:FieldGet(i2)   ok It works normal

AADD(aQuery[i][i2], oRow:FieldGet(i2) )    It does not work
Sim. E daí Jair ???

Depois de você ter reditado a sua mensagem, você quer dizer o quê exatamente ?
Screen197.png
Screen197.png (11.8 KiB) Viewed 3449 times
 
Acho muito rude da sua parte não ter respondido a minha explicação.
Mas de qualquer forma o que colega te disse é o mesmo que eu te disse. :mrgreen:
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
jairpinho
Posts: 420
Joined: Mon Jul 18, 2011 5:36 pm
Location: Rio Grande do Sul - Brasil
Contact:

Re: matriz 8x8

Post by jairpinho »

Pablo César wrote: Tue Apr 25, 2017 12:06 am
jairpinho wrote: Mon Apr 24, 2017 5:38 pm
jairpinho wrote: Mon Apr 24, 2017 5:04 am there is a function to add data on a bidirectional array Array (8.8)

ex.

Code: Select all

aQuery[1][1] := 10
aQuery[1][2] := 20
aQuery[1][3] := 30
aQuery[1][4] := 40
aQuery[1][5] := 50
aQuery[1][6] := 60
aQuery[1][7] := 70
aQuery[1][8] := 80

aQuery[2][1] := 100
aQuery[2][2] := 200
aQuery[2][3] := 300
aQuery[2][4] := 400
aQuery[2][5] := 500
aQuery[2][6] := 600
aQuery[2][7] := 700
aQuery[2][8] := 800


aQuery[i][i2] := oRow:FieldGet(i2)   ok It works normal

AADD(aQuery[i][i2], oRow:FieldGet(i2) )    It does not work
Sim. E daí Jair ???

Depois de você ter reditado a sua mensagem, você quer dizer o quê exatamente ?

Screen197.png
 
Acho muito rude da sua parte não ter respondido a minha explicação.
Mas de qualquer forma o que colega te disse é o mesmo que eu te disse. :mrgreen:
Português
Ola Pablo não funciona o array fica vazio tento visualizar ele a cada elemento preenchido via msginfo(aquery[i2]) ou msginfo(aquery[i,i2])
estou executando um for mas porque não funciona assim tentei das duas forma porem não preenche estou tentando visualizar o array inteiro com a função hb_arraygetc(aQuery) em um edit box porem também não consigo diz que esta função não existe tentei outra array2string tambem nao existe não sei qual lib adicionar para encontrar estas função

English
Hello Pablo, it does not work the array is empty, I try to see it with each element filled in via msginfo (aquery [i2]) or msginfo (aquery [i, i2])
I'm running a for but it does not work so I tried both ways but it does not fill I'm trying to visualize the entire array with the function hb_arraygetc (aQuery) in an edit box but also I can not say that this function does not exist I tried another array2string also does not exist I know which lib add to find these function


Code: Select all

AADD(aQuery[i][i2], oRow:FieldGet(i2) ) preenche vazio / Fills empty
AADD(aQuery[i], oRow:FieldGet(i2) )     preenche vazio / Fills empty
Jair Pinho
HMG ALTA REVOLUÇÃO xBASE
HMG xBASE REVOLUTION HIGH
http://www.hmgforum.com.br
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Re: matriz 8x8

Post by Pablo César »

Olha Jair, eu utilizo muito o MsgDebug. É uma mão na roda e muito mais fácil de usar que o MsgInfo porque você não precisa transformar nada.

Você vai ver o conteúdo dos elementos TODOS do seu array. Isso se eles não forem tremendamente grandes, que neste seu caso eu duvido. Mas se você usar, vai saber do que eu e o edk estamos falando.

Outra coisa: o quê significa i2 ? Eu nunca usei assim. Para mim os endereços de vetores bidirecionais são endereçados assim:

[ i, u ] que podem serem varridos por dois laços de repetição um com variável i e o outro com variável u, por exemplo.

Use MsgDebug( aQuery ) ;)
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
edk
Posts: 909
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: matriz 8x8

Post by edk »

I have tested adding array elements in several ways and it works fine:

Code: Select all

aQuery:={}
msgdebug(aQuery)
1.png
1.png (2.75 KiB) Viewed 3411 times

Code: Select all

AADD(aQuery, {1,1})
msgdebug(aQuery)
msgdebug(aQuery[1])
2.png
2.png (3.6 KiB) Viewed 3411 times

Code: Select all

AADD(aQuery, {2})
msgdebug(aQuery)
msgdebug(aQuery[2])
3.png
3.png (3.75 KiB) Viewed 3411 times

Code: Select all

AADD(aQuery[2], 2)
msgdebug(aQuery)
msgdebug(aQuery[2])
4.png
4.png (3.76 KiB) Viewed 3411 times

Code: Select all

AADD(aQuery, {3})
AADD(aQuery[3], {3})
msgdebug(aQuery)
msgdebug(aQuery[3])
5.png
5.png (3.81 KiB) Viewed 3411 times

Code: Select all

AADD(aQuery, 4)
msgdebug(aQuery)
msgdebug(aQuery[4])
6.png
6.png (3.87 KiB) Viewed 3411 times
If you want to add an element to a multidimensional array, then the parent element must also be an array. (See the differences in examples 3.png and 6.png: AADD(aQuery, {2}) vs. AADD(aQuery, 4) )
In the last example, you can't add to the fourth item of the array of the next item., ex. AADD(aQuery[4], 4) occurs error.
jairpinho wrote: Tue Apr 25, 2017 12:52 am

Code: Select all

AADD(aQuery[i][i2], oRow:FieldGet(i2) ) preenche vazio / Fills empty
AADD(aQuery[i], oRow:FieldGet(i2) )     preenche vazio / Fills empty
Maybe before adding an item, try to query its value: MsgDebug(oRow:FieldGet(i2))


Or maybe you are adding another item to the sub-array then it will be the third item?

Code: Select all

AADD(aQuery[2], 20)
msgdebug(aQuery)
msgdebug(aQuery[2])
7.png
7.png (3.78 KiB) Viewed 3400 times
Post Reply