Error Sample c:\fwh\samples\dlgfind.prg

Error Sample c:\fwh\samples\dlgfind.prg

Postby Jimmy » Tue Mar 28, 2023 4:10 pm

hi,

i try to use Sample but it crash ... :(

Error description: Error BASE/3012 Argument error: NUMTOHEX
Args:
[ 1] = U
[ 2] = N 6

Stack Calls
===========
Called from: => NUMTOHEX( 0 )
Called from: .\source\function\VALBLANK.PRG => FW_CLRTOHTML( 318 )
Called from: .\source\classes\DIALOG.PRG => TDLGFIND:HTML( 421 )
Called from: .\source\classes\DIALOG.PRG => TDLGFIND:INITIATE( 955 )
Called from: .\source\classes\DLGFIND.PRG => TDLGFIND:NEW( 48 )
Called from: .\source\classes\DLGFIND.PRG => DLGFINDTEXT( 65 )
Called from: dlgfind.prg => MAIN( 13 )

p.s. it does show Dialog so i saw it before crash
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Error Sample c:\fwh\samples\dlgfind.prg

Postby karinha » Tue Mar 28, 2023 6:39 pm

Look, c:\fwh..\samples\fivedit.prg

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7826
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Error Sample c:\fwh\samples\dlgfind.prg

Postby Jimmy » Mon Apr 03, 2023 8:42 am

hi,

here working CODE
Code: Select all  Expand view
// Class TDlgFind test
#include "FiveWin.ch"

function Main()
   local oWnd, oGet, cMemo := "This is a test in GET"
   local bSearch, cFind := "test"                      // add this

   DEFINE WINDOW oWnd

   @ 2, 2 GET oGet VAR cMemo SIZE 200, 25

   oWnd:lHtml := .F.                                   // add this
   bSearch := {|| FindTXTProc( oGet, cFind, cMemo ) }  // add this
   DlgFindText( cFind, oGet, bSearch )                 // NEED 3rd Parameter

   ACTIVATE WINDOW oWnd CENTER

return nil


Code: Select all  Expand view
PROCEDURE FindTXTProc( oGet, cFind , cMemo )
LOCAL nPosi
STATIC nStartReplace := 1

   nPosi := hb_at( UPPER( cFind ), UPPER( cMemo ), nStartReplace )
   IF nPosi > 0
      // must setfocus else NO Color
      oGet:Setfocus()
      oGet:SetSel( nPosi - 1, nPosi + LEN( cFind ) - 1 )

      // for next Position
      nStartReplace := nPosi + 1
   ELSE
      MsgInfo("no found")
   ENDIF

RETURN
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Error Sample c:\fwh\samples\dlgfind.prg

Postby karinha » Mon Apr 03, 2023 10:37 am

Code: Select all  Expand view

// C:\FWH...\SAMPLES\DLGFIND2.PRG Para FWH22.06 o Superior. By Jimmy.

// Class TDlgFind test
#Include "FiveWin.ch"

FUNCTION Main()

   LOCAL oWnd, oGet, cMemo := "This is a test in GET"
   LOCAL bSearch, cFind := "test"         // add this

   DEFINE WINDOW oWnd

   @ 2, 2 GET oGet VAR cMemo SIZE 200, 25

   // oWnd:lHtml := .F.                                   // add this
   #IF ( FW_VersionNo >= 22060)
      tWindow():lHtml := .F. // FALSE
   #ENDIF

   bSearch := {|| FindTXTProc( oGet, cFind, cMemo ) }  // add this

   DlgFindText( cFind, oGet, bSearch )                 // NEED 3rd Parameter

   ACTIVATE WINDOW oWnd CENTERED

RETURN NIL

PROCEDURE FindTXTProc( oGet, cFind, cMemo )

   LOCAL nPosi

   STATIC nStartReplace := 1

   #ifdef __XHARBOUR__  // xHarbour

      nPosi := At( Upper( cFind ), Upper( cMemo ), nStartReplace )

   #else

      nPosi := hb_At( Upper( cFind ), Upper( cMemo ), nStartReplace )

   #endif

   IF nPosi > 0

      // must setfocus else NO Color
      oGet:Setfocus()
      oGet:SetSel( nPosi - 1, nPosi + Len( cFind ) - 1 )

      // for next Position
      nStartReplace := nPosi + 1

   ELSE

      MsgInfo( "no found" )

   ENDIF

RETURN NIL

// FIN / END
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7826
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 86 guests