FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para CA-Clipper Presentar un texto especifico
Posts: 109
Joined: Tue Dec 12, 2006 12:39 AM

Presentar un texto especifico

Posted: Mon Nov 19, 2007 11:51 PM

Hola Antonio

Mis buenos deseos para ti y para todos en el foro
Mi cuestión es la siguiente, en un dialogo presento un texto con memoread y funciona muy bien, ¿Como puedo presentar el texto en el sitio o titulo especifico? Si el texto tiene por decir un ejemplo diez títulos se requiere presentar el texto eligiendo cualquier titulo. ¿ Como lo puedo hacer?
Como siempre Antonio expreso mis agradecimientos por tus enseñanzas

Cordialmente

Jairo Barbosa

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Presentar un texto especifico

Posted: Mon Nov 19, 2007 11:59 PM

Jairo,

Puedes buscar el texto que desees con la función At() y luego posicionarte con el método SetPos(). Ejemplo:

nAt = At( "Capitulo 1", oMGet:GetText() )

oMGet:SetPos( nAt )

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 109
Joined: Tue Dec 12, 2006 12:39 AM

Presentar un texto especifico

Posted: Sat Nov 24, 2007 08:38 PM
Antonio Linares wrote:Jairo,

Puedes buscar el texto que desees con la función At() y luego posicionarte con el método SetPos(). Ejemplo:

nAt = At( "Capitulo 1", oMGet:GetText() )

oMGet:SetPos( nAt )

--------------------------------------------------------------------------------
Antonio
he tenido dificultad en hacer funcionar tu sugerencia, talvez si me indicaras un ejemplo te lo agradecere.
El problema basicamente es con GetText(), pero en general no he tenido exito.

Cordialmente

Jairo Barbosa
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Presentar un texto especifico

Posted: Sun Nov 25, 2007 11:57 AM
Jairo,

Bueno ha sido un poco más complicado pero aqui tienes un ejemplo funcionando :-)
test.prg
#include "FiveWin.ch"

function Main()

   local oDlg, oGet, cText := MemoRead( "test.prg" )
   local n := 1, nCRLFs := 0, nAt := At( "DEFINE DIALOG", cText )
   
   while n < nAt
      if SubStr( cText, n++, 2 ) == CRLF
         nCRLFs++
      endif
   end      

   DEFINE DIALOG oDlg SIZE 300, 200

   @ 0, 0 GET oGet VAR cText OF oDlg SIZE 150, 100 MEMO

   oGet:bGotFocus = { || oGet:SetSel( 0, 0 ), oGet:SetPos( nAt - 1 ) }

   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT SkipLines( nCRLFs, oGet, nAt )

return nil

//----------------------------------------------------------------------------//

function SkipLines( nLines, oGet, nAt )

   local n
   
   for n = 1 to nLines
      oGet:PostMsg( WM_VSCROLL, 1 )
   next

return nil      
   
//----------------------------------------------------------------------------//
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 109
Joined: Tue Dec 12, 2006 12:39 AM

Presentar un texto especifico

Posted: Tue Nov 27, 2007 04:30 PM
Antonio Linares wrote:Jairo,

Bueno ha sido un poco más complicado pero aqui tienes un ejemplo funcionando :-)
test.prg
#include "FiveWin.ch"

function Main()

   local oDlg, oGet, cText := MemoRead( "test.prg" )
   local n := 1, nCRLFs := 0, nAt := At( "DEFINE DIALOG", cText )
   
   while n < nAt
      if SubStr( cText, n++, 2 ) == CRLF
         nCRLFs++
      endif
   end      

   DEFINE DIALOG oDlg SIZE 300, 200

   @ 0, 0 GET oGet VAR cText OF oDlg SIZE 150, 100 MEMO

   oGet:bGotFocus = { || oGet:SetSel( 0, 0 ), oGet:SetPos( nAt - 1 ) }

   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT SkipLines( nCRLFs, oGet, nAt )

return nil

//----------------------------------------------------------------------------//

function SkipLines( nLines, oGet, nAt )

   local n
   
   for n = 1 to nLines
      oGet:PostMsg( WM_VSCROLL, 1 )
   next

return nil    

//----------------------------------------------------------------------------//

Antonio

Sencillamente fascinante funciona ok

Muy agradecido

Cordialmente

Jairo Barbosa

Continue the discussion