Jump to content
Fivewin Brasil

GET não aceita digitação....


fluna

Recommended Posts

#include "FiveWin.ch"
//----------------------------------------------------------------------------//
Function Main()
   local oDlg, oRich
   Define font ofnt name "Lucida Console" size 0,-12
   vTab:={" "}
   vGet:={}
   ctxt:=MemoRead( "Teste.txt" )
   For x=1 to mLcount(cTxt,95)
       cFrase:=MemoLine(cTxt,95,x)
       aadd(vtab,cFrase)
   Next

   DEFINE DIALOG oDlg from 1,1 to 40,100
   lin:=1
   For i=1 to Len( vtab )
       nLin:=lin*9.0
       @ nlin,10 say vtab of odlg font oFnt  pixel
       cTxt:=vtab
       For x=1 to len( cTxt )
           If substr(ctxt,x,1)="["
              wtxt:=substr(ctxt,x)
              nPos:=at("]",wtxt)
              nTam:=iif(nPos>0,nPos-2,0)
              cVar:=iif(nTam>0,substr(ctxt,x+1,nTam)," ")
              If nTam > 0
                 aadd(vGet,{ nlin-2 , (x*3.5)+8.4 , cVar } )
               Endif
           Endif
       Next
       lin+=.9
   Next
   aadd(vGet,{ NIL , NIL , NIL} )
   For i=1 to Len( vGet )-1
       @ vGet[i,1],vGet[i,2] get oGet Var vGet[i,3] of odlg  pixel noborder // size len(vGet[i,3])*4,8
   Next
   ACTIVATE DIALOG oDlg CENTERED
   Return NIL

 

 

Exemplo do texto:

 

 

  Este é um texto onde as posições do get dentro dele

  são flutuantes, dependendo de onde estiver um

  colchete [                  ] estilo o bom e velho

  cliper.


   Teste1 [             ]

   Teste2 [    ] e [     ] ou [                      ]


   teste3 [                                          ]

   teste4 [ ],[ ],[ ],[ ],[ ],[ ],[ ]
 

Link to comment
Share on other sites

***** PERDÃO, ERRO NO CÓDIGO ANTERIOR ****

código correto:

#include "FiveWin.ch"
//----------------------------------------------------------------------------//
Function Main()
   local oDlg, oRich
   Define font ofnt name "Lucida Console" size 0,-12
   vTab:={" "}
   vGet:={}
   ctxt:=MemoRead( "Teste.txt" )
   For x=1 to mLcount(cTxt,95)
       cFrase:=MemoLine(cTxt,95,x)
       aadd(vtab,cFrase)
   Next

   DEFINE DIALOG oDlg from 1,1 to 40,100
   lin:=1
   For i=1 to Len( vtab )
       nLin:=lin*9.0
       @ nlin,10 say vtab[ i ] of odlg font oFnt  pixel
       cTxt:=vtab[ i ]
       For x=1 to len( cTxt )
           If substr(ctxt,x,1)="["
              wtxt:=substr(ctxt,x)
              nPos:=at("]",wtxt)
              nTam:=iif(nPos>0,nPos-2,0)
              cVar:=iif(nTam>0,substr(ctxt,x+1,nTam)," ")
              If nTam > 0
                 aadd(vGet,{ nlin-2 , (x*3.5)+8.4 , cVar } )
               Endif
           Endif
       Next
       lin+=.9
   Next
   aadd(vGet,{ NIL , NIL , NIL} )
   For i=1 to Len( vGet )-1
       @ vGet[i,1],vGet[i,2] get oGet Var vGet[i,3] of odlg  pixel noborder // size len(vGet[i,3])*4,8
   Next
   ACTIVATE DIALOG oDlg CENTERED
   Return NIL

 

Link to comment
Share on other sites

Application
===========
   Path and name: C:\FWH1701\samples\fluna.exe (32 bits)
   Size: 3,430,400 bytes
   Compiler version: xHarbour 1.2.3 Intl. (SimpLex) (Build 20170215)
   FiveWin  version: FWHX 17.01
   C compiler version: Borland/Embarcadero C++ 7.2 (32-bit)
   Windows version: 6.1, Build 7601 Service Pack 1

   Time from start: 0 hours 0 mins 2 secs 
   Error occurred at: 02/05/18, 16:57:18
   Error description: Error BASE/1110  Argument error: SUBSTR
   Args:
     [   1] = A   { ... } length: 2
     [   2] = N   1
     [   3] = N   1

Stack Calls
===========
   Called from:  => SUBSTR( 0 )
   Called from: fluna.prg => MAIN( 31 )

           If substr(ctxt,x,1)="["

Link to comment
Share on other sites

Pronto... Agora está funcionando, mas da uma acertada nas variaveis, as declare para que o código fique limpo... Somente a vGet que é necessário que seja PRIVATE ok?

Ajuste as demais coisas, não tive como fazer isso agora... Gostei desta funcionalidade, muito pratico para criar formularios de forma rápida, da até pro usuário criar... Muito bom

 

#include "FiveWin.ch"
//----------------------------------------------------------------------------//
Function u_Teste()
   local oDlg, oRich
   Local bBlock
   Private vGet
   
   Define font ofnt name "Lucida Console" size 0,-12
   vTab:={" "}
   vGet:={}
   ctxt:=MemoRead( "g:\Teste.txt" )
   For x=1 to mLcount(cTxt,95)
       cFrase:=MemoLine(cTxt,95,x)
       aadd(vtab,cFrase)
   Next

   DEFINE DIALOG oDlg from 1,1 to 40,100
   lin:=1
   For i=1 to Len( vtab )
       nLin:=lin*9.0
       @ nlin,10 say vtab[ i ] of odlg font oFnt  pixel
       cTxt:=vtab[ i ]
       For x=1 to len( cTxt )
           If substr(ctxt,x,1)="["
              wtxt:=substr(ctxt,x)
              nPos:=at("]",wtxt)
              nTam:=iif(nPos>0,nPos-2,0)
              cVar:=iif(nTam>0,substr(ctxt,x+1,nTam)," ")
              If nTam > 0
                 aadd(vGet,{ nlin-2 , (x*3.5)+8.4 , cVar } )
               Endif
           Endif
       Next
       lin+=.9
   Next
   aadd(vGet,{ NIL , NIL , NIL} )
   For i=1 to Len( vGet )-1
//       @ vGet[i,1],vGet[i,2] get oGet Var vGet[i,3] of odlg  pixel noborder // size len(vGet[i,3])*4,8

//New( nRow, nCol, bSetGet, oWnd, nWidth, nHeight, cPict, bValid,;
//               nClrFore, nClrBack, oFont, lDesign, oCursor, lPixel,;
//               cMsg, lUpdate, bWhen, lCenter, lRight, bChanged,;
//               lReadOnly, lPassword, lNoBorder, nHelpId,;
//               lSpinner, bUp, bDown, bMin, bMax, bAction, cBmpName, cVarName,;
//               cCueText, cVarName ) CONSTRUCTOR


//      bBlock := "{|u| If(PCount()==0,"+cVar+","+cVar+":=u)}"
      bBlock := "{|u| If(PCount()==0,vGet["+Str(i,3)+",3], vGet["+Str(i,3)+",3]:=u)}"
      bBlock := &bBlock
      oGet := TGet():New(vGet[i,1],vGet[i,2],bBlock,oDlg,/*nWidth*/,/*10*/,/*cPict*/,/*bvalid*/, , , , , , .t., , , /*bWhen*/, ,  , , , , .t., )
   Next
   ACTIVATE DIALOG oDlg CENTERED
   Return NIL

 

 

 

Link to comment
Share on other sites

 

Application
===========
   Path and name: C:\FWH1701\samples\fluna.exe (32 bits)
   Size: 3,430,400 bytes
   Compiler version: xHarbour 1.2.3 Intl. (SimpLex) (Build 20170215)
   FiveWin  version: FWHX 17.01
   C compiler version: Borland/Embarcadero C++ 7.2 (32-bit)
   Windows version: 6.1, Build 7601 Service Pack 1

   Time from start: 0 hours 0 mins 2 secs 
   Error occurred at: 02/05/18, 16:57:18
   Error description: Error BASE/1110  Argument error: SUBSTR
   Args:
     [   1] = A   { ... } length: 2
     [   2] = N   1
     [   3] = N   1

Stack Calls
===========
   Called from:  => SUBSTR( 0 )
   Called from: fluna.prg => MAIN( 31 )

 


           If substr(ctxt,x,1)="["

 

 

 

 

 

Application
===========
   Path and name: C:\FWH1701\samples\fluna.exe (32 bits)
   Size: 3,430,400 bytes
   Compiler version: xHarbour 1.2.3 Intl. (SimpLex) (Build 20170215)
   FiveWin  version: FWHX 17.01
   C compiler version: Borland/Embarcadero C++ 7.2 (32-bit)
   Windows version: 6.1, Build 7601 Service Pack 1

   Time from start: 0 hours 0 mins 2 secs 
   Error occurred at: 02/05/18, 16:57:18
   Error description: Error BASE/1110  Argument error: SUBSTR
   Args:
     [   1] = A   { ... } length: 2
     [   2] = N   1
     [   3] = N   1

Stack Calls
===========
   Called from:  => SUBSTR( 0 )
   Called from: fluna.prg => MAIN( 31 )

 


           If substr(ctxt,x,1)="["

 

 

Você não criou o arquivo texto, veja no post dele o exemplo que ele colocou para criar...

 

Link to comment
Share on other sites

Thanks Emotta, agora funcionou. Explique, para que isso seria util?


#include "FiveWin.ch"
	MEMVAR vGet
	Function u_Teste()
	   local oDlg, oRich, oFnt, oGet, nLin, cVar, I, nTam, Lin
   Local bBlock, VTAB,  CTXT, X, CFRASE, WTT, NPOS, WTXT
	   Define font ofnt name "Lucida Console" size 0,-12
	   vTab := { " " }
   vGet := {}
	   ctxt:=MemoRead( ".\Teste.txt" )
	   For x=1 to mLcount(cTxt,95)
	      cFrase:=MemoLine(cTxt,95,x)
	      aadd(vtab,cFrase)
	   Next
	   DEFINE DIALOG oDlg from 1,1 to 40,100
	   lin:=1
	   For i=1 to Len( vtab )
	       nLin:=lin*9.0
	       @ nlin,10 say vtab[ i ] of odlg font oFnt  pixel
	       cTxt:=vtab[ i ]
	       For x=1 to len( cTxt )
	           If substr(ctxt,x,1)="["
	              wtxt:=substr(ctxt,x)
	              nPos:=at("]",wtxt)
	              nTam:=iif(nPos>0,nPos-2,0)
	              cVar:=iif(nTam>0,substr(ctxt,x+1,nTam)," ")
	              If nTam > 0
	                 aadd(vGet,{ nlin-2 , (x*3.5)+8.4 , cVar } )
	               Endif
	           Endif
	       Next
	       lin+=.9
	   Next
	   aadd(vGet,{ NIL , NIL , NIL} )
	   For i=1 to Len( vGet )-1
	      // @ vGet[i,1],vGet[i,2] get oGet Var vGet[i,3] of odlg  pixel noborder // size len(vGet[i,3])*4,8
	      // New( nRow, nCol, bSetGet, oWnd, nWidth, nHeight, cPict, bValid,;
      //      nClrFore, nClrBack, oFont, lDesign, oCursor, lPixel,;
      //      cMsg, lUpdate, bWhen, lCenter, lRight, bChanged,;
      //      lReadOnly, lPassword, lNoBorder, nHelpId,;
      //      lSpinner, bUp, bDown, bMin, bMax, bAction, cBmpName, cVarName,;
      //      cCueText, cVarName ) CONSTRUCTOR
	
      // bBlock := "{|u| If(PCount()==0,"+cVar+","+cVar+":=u)}"
      bBlock := "{|u| If(PCount()==0,vGet["+Str(i,3)+",3], vGet["+Str(i,3)+",3]:=u)}"
      bBlock := &bBlock
      oGet := TGet():New(vGet[i,1],vGet[i,2],bBlock,oDlg,/*nWidth*/,/*10*/,/*cPict*/,/*bvalid*/, , , , , , .t., , , /*bWhen*/, ,  , , , , .t., )
	   Next
	   ACTIVATE DIALOG oDlg CENTERED
	   oFnt:End()
	Return Nil


 

Link to comment
Share on other sites

 

Thanks Emotta, agora funcionou. Explique, para que isso seria util?

 


#include "FiveWin.ch"
	MEMVAR vGet
	Function u_Teste()
	   local oDlg, oRich, oFnt, oGet, nLin, cVar, I, nTam, Lin
   Local bBlock, VTAB,  CTXT, X, CFRASE, WTT, NPOS, WTXT
	   Define font ofnt name "Lucida Console" size 0,-12
	   vTab := { " " }
   vGet := {}
	   ctxt:=MemoRead( ".\Teste.txt" )
	   For x=1 to mLcount(cTxt,95)
	      cFrase:=MemoLine(cTxt,95,x)
	      aadd(vtab,cFrase)
	   Next
	   DEFINE DIALOG oDlg from 1,1 to 40,100
	   lin:=1
	   For i=1 to Len( vtab )
	       nLin:=lin*9.0
	       @ nlin,10 say vtab[ i ] of odlg font oFnt  pixel
	       cTxt:=vtab[ i ]
	       For x=1 to len( cTxt )
	           If substr(ctxt,x,1)="["
	              wtxt:=substr(ctxt,x)
	              nPos:=at("]",wtxt)
	              nTam:=iif(nPos>0,nPos-2,0)
	              cVar:=iif(nTam>0,substr(ctxt,x+1,nTam)," ")
	              If nTam > 0
	                 aadd(vGet,{ nlin-2 , (x*3.5)+8.4 , cVar } )
	               Endif
	           Endif
	       Next
	       lin+=.9
	   Next
	   aadd(vGet,{ NIL , NIL , NIL} )
	   For i=1 to Len( vGet )-1
	      // @ vGet[i,1],vGet[i,2] get oGet Var vGet[i,3] of odlg  pixel noborder // size len(vGet[i,3])*4,8
	      // New( nRow, nCol, bSetGet, oWnd, nWidth, nHeight, cPict, bValid,;
      //      nClrFore, nClrBack, oFont, lDesign, oCursor, lPixel,;
      //      cMsg, lUpdate, bWhen, lCenter, lRight, bChanged,;
      //      lReadOnly, lPassword, lNoBorder, nHelpId,;
      //      lSpinner, bUp, bDown, bMin, bMax, bAction, cBmpName, cVarName,;
      //      cCueText, cVarName ) CONSTRUCTOR
	
      // bBlock := "{|u| If(PCount()==0,"+cVar+","+cVar+":=u)}"
      bBlock := "{|u| If(PCount()==0,vGet["+Str(i,3)+",3], vGet["+Str(i,3)+",3]:=u)}"
      bBlock := &bBlock
      oGet := TGet():New(vGet[i,1],vGet[i,2],bBlock,oDlg,/*nWidth*/,/*10*/,/*cPict*/,/*bvalid*/, , , , , , .t., , , /*bWhen*/, ,  , , , , .t., )
	   Next
	   ACTIVATE DIALOG oDlg CENTERED
	   oFnt:End()
	Return Nil


 

Bom, acredito que quem pode explicar é quem teve a idéia mas eu achei interessante pois você pode criar uma espécie de formulario e deixar aberto ao usuário personalizar...

 

Eu não tenho nenhum caso prático para o momento mas vou deixar guardado se algum dia for necessário.

 

Através de um simples arquivo texto vc pode indicar os campos para se preencher e com algumas alterações pode até criar um cadastro personalizado...

 

Uma idéia que me surgiu agora é que você pode ter em seu sistema um cadastro com os campos que vc cria no seu código porem uma parte complementar onde o usuário pode ter mais informações que sejam relevantes a ele. Ele apenas altera o arquivo texto e tem disponivel novas informações no cadastro sem alterar o código fonte.

Como em meu sistema uso o conceito de dicionario de dados pra mim isso não é necessário mas pra quem cria formularios com campos direto no código pode ser uma opção a mais para flexibilizar seu sistema sem necessidade de alterar o código padrão.

Essa é uma idéia mas o FLUNA poderia explicar melhor o pq inventou isso...

Link to comment
Share on other sites

É para um sistema se laboratório, onde os exames são criados pelo próprio usuário em duas fases:   Uma: ele cria o texto exame já prontinho, com todo o texto que "der na telha", e define qual parte do texto será preechido, ainda na fase da configuração do exame, ele seta as referencias para cada ponto de digitação; Uma vez terminada a configuração, esse dado são guardasos em um .INI com o mesmo nome do formulário;  Depois, quando for digitar um exame, seleciona o formulário e preenche; na digitação, os sistema vai no ini e "pesquisa" as referencias para o get preenchido.  (temos cerca de 1300 exames, telas genéricas para eles não funcionam, então, transfir para o operador fazer a tela a seu gosto hehehehe. (eles adoraram a idéia)  Inicialmente pensei em usar o TextEdit (rtf), mas deparei-me com com várias dificuldades... (tipo desligar o insert antes de entrar no texto, fazer com que o cursor não "invada" a palavra ao lado... etc.  -Abraços a todos que ajudaram.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...