FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour xBrowse + TDolphin EDIT_GET_LISTBOX
Posts: 437
Joined: Fri Oct 07, 2005 12:56 PM
xBrowse + TDolphin EDIT_GET_LISTBOX
Posted: Sat Mar 09, 2013 08:28 AM

Hi ,

Want to do column editing with listbox . Values in array ~ 800 ...
So I tried that :
WITH OBJECT oCol
:bEditValue := { || oQry:preke }
:nEditType := if( lEdt, EDIT_GET_LISTBOX, EDIT_NONE )
:aEditListTxt := aMod
END

Sorry , but trying to open listbox , app hangs ... How can this be solved ?

Fwh 11.11 , Harbour 3.1 MinGW

Rimantas U.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse + TDolphin EDIT_GET_LISTBOX
Posted: Sat Mar 09, 2013 01:11 PM

You may use EDIT_LISTBOX for smaller arrays.
For the kind of arrays having 800 elements etc you may better use an external function to select with EDIT_BUTTON functionality.

Regards



G. N. Rao.

Hyderabad, India
Posts: 437
Joined: Fri Oct 07, 2005 12:56 PM
Re: xBrowse + TDolphin EDIT_GET_LISTBOX
Posted: Sat Mar 09, 2013 02:18 PM
nageswaragunupudi wrote:You may use EDIT_LISTBOX for smaller arrays.
For the kind of arrays having 800 elements etc you may better use an external function to select with EDIT_BUTTON functionality.


OK , understand ... Thanks !
Rimantas U.
Posts: 437
Joined: Fri Oct 07, 2005 12:56 PM
Re: xBrowse + TDolphin EDIT_GET_LISTBOX
Posted: Sat Mar 09, 2013 05:01 PM
Rimantas wrote:
nageswaragunupudi wrote:You may use EDIT_LISTBOX for smaller arrays.
For the kind of arrays having 800 elements etc you may better use an external function to select with EDIT_BUTTON functionality.


OK , understand ... Thanks !


Changed EDIT_LISTBOX with EDIT_BUTTON ...
Code (fw): Select all Collapse
WITH OBJECT oCol
   :bEditValue      := { || oQry:preke }
   :nEditType       := if( lEdt, EDIT_BUTTON, EDIT_NONE )
   :bEditBlock      := { | nRow, nCol, oCol | oCol:Value := brw_arr( "Choose!", { "Item", "Item name" }, aMod, oWnd ) } // mine function of array , which will return value 
   :bOnPostEdit     := { | oCol, xVal, nKey | if( nKey == VK_RETURN .and. ascan( aMod, { |x| x[ 1 ] == xVal } ) <> 0, ( oQry:FieldPut( oCol:cExpr, xVal ), oQry:Save() ), ) } // 104 line 
END


Now building app. I'm getting error : uzs.prg(104) Error E0005 Outer codeblock variable 'XVAL' is out of reach . The same xVal in other bOnPostEdit works without problem . :bOnPostEdit := { | oCol, xVal, nKey | if( nKey == VK_RETURN, ( oQry:FieldPut( oCol:cExpr, xVal ), oQry:Save() ), ) }

To what that related ?
Rimantas U.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse + TDolphin EDIT_GET_LISTBOX
Posted: Sat Mar 09, 2013 05:33 PM
Error E0005 Outer codeblock variable 'XVAL' is out of reach

Yes.
We can not use the parameter of the main codeblock inside another codeblock used within the main codeblock.

We need to create a function for that.
Regards



G. N. Rao.

Hyderabad, India
Posts: 437
Joined: Fri Oct 07, 2005 12:56 PM
Re: xBrowse + TDolphin EDIT_GET_LISTBOX
Posted: Sat Mar 09, 2013 08:21 PM
nageswaragunupudi wrote:
Error E0005 Outer codeblock variable 'XVAL' is out of reach

Yes.
We can not use the parameter of the main codeblock inside another codeblock used within the main codeblock.

We need to create a function for that.



Thanks , Rao ! Understand ...
Rimantas U.
Posts: 437
Joined: Fri Oct 07, 2005 12:56 PM
Re: xBrowse + TDolphin EDIT_GET_LISTBOX
Posted: Sun Mar 10, 2013 08:39 AM
Rimantas wrote:
nageswaragunupudi wrote:
Error E0005 Outer codeblock variable 'XVAL' is out of reach

Yes.
We can not use the parameter of the main codeblock inside another codeblock used within the main codeblock.

We need to create a function for that.


Thanks , Rao ! Understand ...


Hello Rao ! Can you help also ? I redid this place with EDIT_GET_BUTTON :

Code (fw): Select all Collapse
WITH OBJECT oCol
   :bEditValue      := { || oQry:preke }
   :nEditType       := if( lEdt, EDIT_GET_BUTTON, EDIT_NONE )
   :bEditBlock      := { | nRow, nCol, oCol | uVal := brw_arr( "Choose!", { "Model", "Description" }, aMod, oCol:Value ), ;
   if( !empty( uVal ) .and. uVal <> oCol:Value, oQry:FieldPut( oCol:cExpr, uVal ), ) }
   :bOnPostEdit     := { | oCol, xVal, nKey | if( mod_pas( aMod, xVal ), ( oQry:FieldPut( oCol:cExpr, xVal ), oQry:Save() ), ) } 
END


Edit block get new value , which return from mine function brw_arr() . But it not run bOnPostEdit . I must to press Enter if want to save . How to run bOnPostEdit after when bEditBlock get new value ?
Rimantas U.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse + TDolphin EDIT_GET_LISTBOX
Posted: Sun Mar 10, 2013 12:20 PM
Code (fw): Select all Collapse
WITH OBJECT oCol
   :bEditValue      := { || oQry:preke }
   :bEditWhen       := { || lEdt }
   :nEditType       := EDIT_GET_BUTTON
   :bEditBlock      := { | nRow, nCol, oCol | brw_arr( "Choose!", { "Model", "Description" }, aMod, oCol:Value )
   :bOnPostEdit     := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:preke := xVal, oQry:Save() ) ) }
END


The function brw_arr(...) should return
- the selected Model code if the user selects a model
- or should return NIL if the user aborts the selection.

If bEditBlock returns NIL, xbrowse does not take any action.
If bEditBlock returns a Non Nil value, xbrowse evaluates bOnPostEdit with the retuned value.
Regards



G. N. Rao.

Hyderabad, India
Posts: 437
Joined: Fri Oct 07, 2005 12:56 PM
Re: xBrowse + TDolphin EDIT_GET_LISTBOX
Posted: Sun Mar 10, 2013 12:41 PM
nageswaragunupudi wrote:
Code (fw): Select all Collapse
WITH OBJECT oCol
   :bEditValue      := { || oQry:preke }
   :bEditWhen       := { || lEdt }
   :nEditType       := EDIT_GET_BUTTON
   :bEditBlock      := { | nRow, nCol, oCol | brw_arr( "Choose!", { "Model", "Description" }, aMod, oCol:Value )
   :bOnPostEdit     := { | oCol, xVal, nKey | If( nKey == VK_ESCAPE,,( oQry:preke := xVal, oQry:Save() ) ) }
END


The function brw_arr(...) should return
- the selected Model code if the user selects a model
- or should return NIL if the user aborts the selection.

If bEditBlock returns NIL, xbrowse does not take any action.
If bEditBlock returns a Non Nil value, xbrowse evaluates bOnPostEdit with the retuned value.


Works very fine now ! Many thanks to you, Rao ! :-)
Rimantas U.

Continue the discussion