Page 1 of 1

Presentar un texto especifico

PostPosted: Mon Nov 19, 2007 11:51 pm
by jaba
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

PostPosted: Mon Nov 19, 2007 11:59 pm
by Antonio Linares
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 )

PostPosted: Sat Nov 24, 2007 8:38 pm
by jaba
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

PostPosted: Sun Nov 25, 2007 11:57 am
by Antonio Linares
Jairo,

Bueno ha sido un poco más complicado pero aqui tienes un ejemplo funcionando :-)
test.prg
Code: Select all  Expand view
#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     
   
//----------------------------------------------------------------------------//

PostPosted: Tue Nov 27, 2007 4:30 pm
by jaba
Antonio Linares wrote:Jairo,

Bueno ha sido un poco más complicado pero aqui tienes un ejemplo funcionando :-)
test.prg
Code: Select all  Expand view
#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