Finding the caption of a Hash

Finding the caption of a Hash

Postby Marc Venken » Fri Apr 01, 2022 9: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.04 with Harbour
User avatar
Marc Venken
 
Posts: 1434
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Finding the caption of a Hash

Postby Detlef » Fri Apr 01, 2022 1: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
User avatar
Detlef
 
Posts: 209
Joined: Mon Feb 07, 2022 9:54 pm

Re: Finding the caption of a Hash

Postby Marc Venken » Fri Apr 01, 2022 1: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.04 with Harbour
User avatar
Marc Venken
 
Posts: 1434
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Finding the caption of a Hash

Postby Maurizio » Fri Apr 01, 2022 3: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
User avatar
Maurizio
 
Posts: 824
Joined: Mon Oct 10, 2005 1:29 pm

Re: Finding the caption of a Hash

Postby Otto » Fri Apr 01, 2022 4: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


Image



Best regard,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: Finding the caption of a Hash

Postby Otto » Fri Apr 01, 2022 5: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: Select all  Expand view


// 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
Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: Finding the caption of a Hash

Postby Marc Venken » Sun Apr 03, 2022 6: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.04 with Harbour
User avatar
Marc Venken
 
Posts: 1434
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

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