FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Error Sample c:\fwh\samples\dlgfind.prg
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM

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

Posted: Tue Mar 28, 2023 04: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
Posts: 8523
Joined: Tue Dec 20, 2005 07:36 PM

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

Posted: Tue Mar 28, 2023 06:39 PM

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

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM

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

Posted: Mon Apr 03, 2023 08:42 AM
hi,

here working CODE
Code (fw): Select all Collapse
// 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 (fw): Select all Collapse
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
Posts: 8523
Joined: Tue Dec 20, 2005 07:36 PM

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

Posted: Mon Apr 03, 2023 10:37 AM
Code (fw): Select all Collapse
// 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

Continue the discussion