FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Finding the caption of a Hash
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Finding the caption of a Hash
Posted: Fri Apr 01, 2022 09:46 AM

I can't find the caption of the hash. I mean that I want the

PROMPT "Offerte'" .... // hard coded
tobe
PROMPT hApi["OFFERTE"]:caption // or :key or

I can't find the correct METHOD to find the titel OFFERTE

@ nPos,20 CHECKBOX oCheckbox[1] VAR hApi["OFFERTE"] PROMPT "Offertes" SIZE 80,15 PIXEL OF oDlg

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 218
Joined: Mon Feb 07, 2022 09:54 PM
Re: Finding the caption of a Hash
Posted: Fri Apr 01, 2022 01:06 PM

Hi Marc,
I think hApi["OFFERTE"] gets the logical value of the checkbox object and the caption should be oCheckbox[1]:cCaption.

Regards, Detlef

Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: Finding the caption of a Hash
Posted: Fri Apr 01, 2022 01:29 PM

The caption will be the value I put afther the PROMPT, but that way the value is not the label of the HASH

I know that the keys are searchable with

cZoek = "OFFERTE"
if hb_HHasKey( hData, cZoek )

hApi["OFFERTE"]:cCaption is also giving the error.

Normaly I put a Xbrowser as debugger, but also Xbrowse is only giving : Key and Value

I suppose now that there are no more methos in the Hash. HB_Hash is harbour, so not a source of FW.

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM
Re: Finding the caption of a Hash
Posted: Fri Apr 01, 2022 03:21 PM

I use this function

//-------------------------------------------------------------------------------------------
Function HB_HasTrovato(hVars,xKey,lValore,lUpper)
Local lReturn := .f.
DEFAULT lValore := .f.
DEFAULT lUpper := .t.

IF lUpper
xKey := upper(xKey)
endif

IF HB_ISHASH(hVars) .and. HHasKey( hVars , xKey )
IF lValore
IF VALTYPE(hVars[xKey]) == 'N' .AND. hVars[xKey] > 0
lReturn := .t.
ELSEIF VALTYPE(hVars[xKey]) == 'C' .and. ! empty(hVars[xKey])
lReturn := .t.
ELSEIF VALTYPE(hVars[xKey]) == 'D'

   ELSEIF VALTYPE(hVars[xKey]) == 'L'


   ENDIF  
ELSE 
   lReturn := .t.

ENDIF

ENDIF

Return lReturn

Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: Finding the caption of a Hash
Posted: Fri Apr 01, 2022 04:59 PM
Marc,

A hash table is built from key/value pairs.

Here is a link to the manual: https://harbour.github.io/doc/

Bookmark:
https://winhotel.space/modharbour/modharbouronline.prg






Best regard,
Otto
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: Finding the caption of a Hash
Posted: Fri Apr 01, 2022 05:21 PM
Hello Marc,
testing Checkbox I noticed that on Change is not evaluated when you create the checkbox.
You have to evaluate from ON INIT of the ACTIVATE WINDOW.

Best regards,
Otto

Code (fw): Select all Collapse
// A simple test with a checkbox

#include "FiveWin.ch"

static oWnd

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

function Main()

   local lValue := .t., oChk
    
    
    
   DEFINE WINDOW oWnd TITLE "Testing CheckBox ON CHANGE clause"

    @ 3,3 ;
    CHECKBOX oChk ;
         VAR lValue ;
      PROMPT "&ClickMe" ;
        SIZE 100, 20 ;
          OF oWnd ;
       COLOR "W+/B" ;
   ON CHANGE (  iif( oChk:lchecked=.T.,oChk:SetText( "New Text" ), oChk:SetText( "&ClickMe" ) )  )

   ACTIVATE WINDOW oWnd  ON INIT (  iif( oChk:lchecked=.T.,oChk:SetText( "New Text" ), oChk:SetText( "&ClickMe" ) )  )

return nil

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



PS: Editing with AUTOCODE
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: Finding the caption of a Hash
Posted: Sun Apr 03, 2022 06:23 PM

Looking at the functions this code is working

@ nPos,20 CHECKBOX oCheckbox[1] VAR hApi["OFFERTE"] PROMPT hb_HKeyAt( hApi, hb_HPos( hApi, "OFFERTE" ) ) SIZE 80,15 PIXEL OF oDlg

Now I can change the hardcode text with random fields.

Thanks

Marc Venken

Using: FWH 23.08 with Harbour

Continue the discussion