Página 1 de 1

GET com array

Enviado: 24 Nov 2012 23:02
por JoséQuintas
Tentei fazer GETS com array mas trava tudo.
Tem como fazer isto em hwgui?

FOR nCont = 1 TO 10
@ lin, col GET mVar[nCont]
NEXT

GET com array

Enviado: 25 Nov 2012 11:49
por esbasso
TEORICAMENTE tem de funcionar.
Trava em que sentido?

Se puder postar o código todo do DIALOG

GET com array

Enviado: 26 Nov 2012 04:35
por JoséQuintas
Peguei o exemplo da hwgui e ajustei.
Aqui o código que funciona e o que não funciona.
Não funciona em hwgui significa que funciona em console.
Mas em hwgui, isso faz o programa travar e precisa ser fechado no windows.

Código: Selecionar todos

//   @ 20,  5 + 35 GET ee[1] PICTURE "XXXXXXXXXXXXXXX" SIZE 260, 26
//   @ 20,  5 + 65 GET ee[2] PICTURE "XXXXXXXXXXXXXXX" SIZE 260, 26
//   @ 20,  5 + 95 GET ee[3] PICTURE "XXXXXXXXXXXXXXX" SIZE 260, 26
//   @ 20,  5 +125 GET ee[4] PICTURE "XXXXXXXXXXXXXXX" SIZE 260, 26
//   @ 20,  5 +155 GET ee[5] PICTURE "XXXXXXXXXXXXXXX" SIZE 260, 26
   FOR nCont = 1 TO 5
      @ 20, 5 + 5 + nCont*30 GET ee[nCont] PICTURE "XXXXXXXXXXXXXXXXXXXXXX" SIZE 260,26
   NEXT

GET com array

Enviado: 26 Nov 2012 08:32
por esbasso
Realmente deste forma não funciona .

Deste forma funciona.

Código: Selecionar todos

Function GetAarray

 Local odlg, nCont
 LOCAL oG := {,,,,}
 Private Ee := Array( 5 ), cCont

 Afill( eE, SPACE(20) )
 Afill( oG, Nil )

 INIT DIALOG oDlg TITLE "Form1"     ;
    AT 0, 0 SIZE 510,356 CLIPPER  ;
     STYLE WS_POPUP+WS_CAPTION+WS_SYSMENU+WS_SIZEBOX+DS_CENTER +WS_VSCROLL
  
  FOR nCont := 1 TO 5
      cCont := alltrim(str(ncont,2))
	     @ 20, 5 + 5 + nCont*30 GET oG[ nCont ] VAR &("Ee[ &cCont ]") PICTURE "XXXXXXXXXXXXXXXXXXXXXX" SIZE 260,26
  NEXT
  ACTIVATE DIALOG oDlg
  
  RETURN NIL

GET com array

Enviado: 26 Nov 2012 10:22
por JoséQuintas
Tentei definir algo pelo #command pra facilitar,
e usar um default oVar[Len(GetList)]
Mas não foi.

Assim vai complicando mas funciona:

Código: Selecionar todos

   FOR nCont := 1 TO 5
      cCont := alltrim(str(ncont,2))
      @ 20, 5 + 5 + nCont*30 GET oG[ nCont ] VAR &("Ee[ &cCont ]") PICTURE "XXXXXXXXXXXXXXXXXXXXXX" SIZE &( "Len( ee[ &cCont ] ) * 13"),26
   NEXT
O chato é que tudo que tem nessa linha faz parte da Getlist. Dá até a impressão que as GUIs estão no caminho errado.
Mas isso vou deixar pro bate-papo, pra não fugir do assunto deste tópico.

GET com array

Enviado: 26 Nov 2012 10:35
por esbasso
simplificando um pouquinho

Código: Selecionar todos

@ 20, 5 + 5 + nCont*30 GET oG[ nCont ] VAR Ee[ &cCont ] PICTURE "XXXXXXXXXXXXXXXXXXXXXX" SIZE 260,26
O problema é no indice do Array que não pode ser passado como uma simples variavel.

GET com array

Enviado: 26 Nov 2012 12:29
por JoséQuintas
Assim deu certo também, qualquer variável para o GET.
Valeu, já dá pra brincar um pouco.

Código: Selecionar todos

FUNCTION GetAarray
   LOCAL odlg, nCont, xDummy, lResult := .f.
   MEMVAR Ee, cCont
   PRIVATE Ee := Array( 5 ), cCont

   AFill( eE, SPACE(20) )

   INIT DIALOG oDlg TITLE "Form1" AT 0, 0 SIZE 510,356 CLIPPER STYLE WS_POPUP+WS_CAPTION+WS_SYSMENU+WS_SIZEBOX+DS_CENTER +WS_VSCROLL
  
   FOR nCont := 1 TO 5
      cCont := AllTrim(Str(nCont,2))
      @ 20, 5 + 5 + nCont*30 GET xDummy VAR Ee[ &cCont ] PICTURE "XXXXXXXXXXXXXXXXXXXXXX" SIZE Len( ee[ &cCont ] ) * 13,26
   NEXT
   @  20,250  BUTTON "Ok" SIZE 100, 32 ON CLICK {||lResult:=.T.,EndDialog()}
   @ 180,250 BUTTON "Cancel" ID IDCANCEL SIZE 100, 32
   ACTIVATE DIALOG oDlg
   IF lResult
      MsgInfo( ee[1] + chr(10) + chr(13) + ee[2] + chr(10) + chr(13) + ee[3] + chr(10) + chr(13) + ee[4] + chr(10) + chr(13) + ee[5] + chr(10) + chr(13), "Results:" )
   ENDIF
   RETURN NIL