xBrowse setPos(n,n) error

Post Reply
User avatar
Rick Lipkin
Posts: 2668
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

xBrowse setPos(n,n) error

Post by Rick Lipkin »

I a have an xBrowse listbox where I am calculating a column to go as in this code to replace the GoToCol(n) using oBrow:SetPos(1,47) where I want the cursor to go to the first row then 47th column and I get the following error .. using fwh 910 ..

Any Ideas ??

Rick Lipkin

Code: Select all | Expand



SELECT 1
SET ORDER to TAG VNUMBER
GO TOP

xALIAS := ALIAS()
MSGINFO( nCOL )

DEFINE FONT oFont NAME GetSysFont() SIZE 0,-10

DEFINE WINDOW oWNDCHILD MDICHILD      ;
       FROM 1,1 to 33,100             ;
       MENU BuildMenu()               ;
       of oWNDMDI                     ;
       NOSYSMENU                      ;
       NOZOOM                         ;
       NOMINIMIZE                     ;
       TITLE "Reservation Information"

   DEFINE DIALOG oEMP RESOURCE "RESBROW" of oWNDCHILD

   oEmp:SetFont( oFont )

   REDEFINE XBROWSE oBrow ID 111 OF oEMP ALIAS xAlias ;
      AUTOSORT AUTOCOLS FOOTERS FASTEDIT LINES CELL
   
    oBROW:nFREEZE := 5
    oBROW:SetPos(1, 47)   <-- error here

    oEMP:oClient := oBrow


   REDEFINE SAY oMOTORPOOL var cMOTORPOOL ID 114 of oEMP
   REDEFINE SAY oMOTOR var xMOTOR ID 113 of oEMP
   REDEFINE SAY oDATE1 var dDATE1 ID 119 of oEMP
   REDEFINE SAY oDATE2 var dDATE2 ID 120 of oEMP

   REDEFINE BUTTON oBTN1 ID 112 of oEMP    ;    // details
       ACTION ( _PtrpBrow( CTOD("00/00/00"), A->VNUMBER, A->LICENSE ),;
                _ReFrsh( A->VNUMBER, dDATE1 ), ;
                dbSelectArea( 1 ),;
                oBROW:UpStable(),;
                oBROW:REFRESH(), SysReFresh(),;
                oBROW:SetFocus() )

   REDEFINE BUTTON oBTN2 ID 117 of oEMP    ;    // add reservation
       ACTION ( _PtrpBrow( CTOD("00/00/00"), A->VNUMBER, A->LICENSE ),;
                _ReFrsh( A->VNUMBER, dDATE1 ), ;
                dbSelectArea( 1 ),;
                oBROW:REFRESH(), SysReFresh(),;
                oBROW:SetFocus() )

   REDEFINE BUTTON oBTN3 ID 115 of oEMP    ;    // quit
       ACTION ( dbCloseAll(), ;
                FERASE( xVOL+"\DBTMP\"+SITEDBF+".DBF" ),;
                FERASE( xVOL+"
\DBTMP\"+SITEDBF+".CDX" ),;
                oWNDCHILD:END(), _CleanUP() )

   REDEFINE BUTTON oBTN4 ID 116 of oEMP   ;     // change motorpool
       ACTION ( _Chgmtrpool( "
BOGUS", dDATE1 ),;
                dbSelectArea( 1 ),;
                oBROW:REFRESH(.T.), SysReFresh(),;
                oBROW:SetFocus()  )

   REDEFINE BUTTON oBTN5 ID 118 of oEMP   ;     // refresh
       ACTION ( _ReFrsh( A->VNUMBER, dDATE1 ), ;
                dbSelectArea( 1 ),;
                oBROW:REFRESH(.T.), SysReFresh(),;
                oBROW:SetFocus()  )

ACTIVATE DIALOG oEMP NOWAIT    ;
    ON INIT ( oEMP:Move( 0, 0 ),;
              IF( (xSUPER = 'Y'.or. xMGR = 'Y'), ,oBTN4:HIDE() )) // , ;
                * oBROW:SetPos(1, 47) )
               * oBROW:GoToCol(nCOL) )

ACTIVATE WINDOW oWNDCHILD ;
         ON INIT ( oWndChild:SetSize( oEMP:nWIDTH,oEMP:nHEIGHT, .T. )) ;
         VALID ( IIF( !lOK, CloseRes(.T.), .F. ))

RETURN( NIL )


Code: Select all | Expand


Application
===========
   Path and name: C:\FOX\DHEC\VEHFWH\veh32.Exe (32 bits)
   Size: 3,359,744 bytes
   Time from start: 0 hours 0 mins 16 secs
   Error occurred at: 06/30/2010, 10:50:14
   Error description: Error BASE/1111  Argument error: LEN
   Args:
     [   1] = U  

Stack Calls
===========
   Called from:  => LEN(0)
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:LASTDISPLAYPOS(1793)
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:SETPOS(2819)
   Called from: RESBROW.PRG => _RESBROW(227)
   Called from: TRIPMENU.PRG => (b)_TRIPMENU(32)
   Called from: .\source\classes\BUTTON.PRG => TBUTTON:CLICK(176)
   Called from: .\source\classes\CONTROL.PRG => TBUTTON:HANDLEEVENT(1427)
   Called from: .\source\classes\WINDOW.PRG => _FWH(3347)
   Called from:  => SENDMESSAGE(0)
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:COMMAND(407)
   Called from:  => TWINDOW:HANDLEEVENT(0)
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:HANDLEEVENT(928)
   Called from: .\source\classes\WINDOW.PRG => _FWH(3347)
   Called from:  => WINRUN(0)
   Called from: .\source\classes\WINDOW.PRG => TMDIFRAME:ACTIVATE(966)
   Called from: MAIN.PRG => MAIN(379)
 
User avatar
ukoenig
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: xBrowse setPos(n,n) error

Post by ukoenig »

Hello Rick,

Setting the Focus to a defined Cell ( Row = 5 / Col = 2 ),
I use :

oLbx:nRowSel := 5
oLbx:nColSel := 2

----------------------------------------

oLbx := TXBrowse():New( oDlg )
oLbx:nMarqueeStyle := MARQSTYLE_HIGHLCELL
...
...
oLbx:nRowSel := 5
oLbx:nColSel := 2


oLbx70:SetPos(5, 2) // Error !!!

Application
===========
Path and name: E:\T_T_XBRW\backgrd.exe (32 bits)
Size: 1,916,928 bytes
Time from start: 0 hours 0 mins 0 secs
Error occurred at: 06/30/10, 21:41:17
Error description: Error BASE/1111 Argument error: LEN
Args:
[ 1] = U

Stack Calls
===========
Called from: => LEN(0)
Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:LASTDISPLAYPOS(1892)
Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:SETPOS(2883)
Called from: .\backgrd.PRG => MAIN(129)


oLbx:CreateFromResource( 110 )
...
...

Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: xBrowse setPos(n,n) error

Post by nageswaragunupudi »

1. SetPos(..) should be used in ON INIT clause.
2. oLbx:nRowSel := 5
oLbx:nColSel := 2
also works in many cases.

There is no Upstable method in xbrowse and it is not necessary. oBrw:Refresh() is enough.
Regards

G. N. Rao.
Hyderabad, India
User avatar
Rick Lipkin
Posts: 2668
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: xBrowse setPos(n,n) error

Post by Rick Lipkin »

Rao

I took out the upstable .. I am trying to migrate hernans browse to xbrowse .. in the screen shots . June 27th is the day that should show up after the 5th column which is frozen :

Image

This is the xbrowse with this code :

Code: Select all | Expand


ACTIVATE DIALOG oEMP NOWAIT    ;
    ON INIT ( oEMP:Move( 0, 0 ), oBrow:nColSel:= nCOL,oBrow:SetFocus(),; //   oBrow:SetPos( 1, nCOL ),;
              IF( (xSUPER = 'Y'.or. xMGR = 'Y'), ,oBTN4:HIDE() ))
 


Image

As you can see .. Jun 27th is more off to the right and barely visable .. I will try soem of the suggestions to get the column to line up correctly. nCOL is 47 in both cases.

Rick
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: xBrowse setPos(n,n) error

Post by nageswaragunupudi »

SetPos works for visible number of column.
nColSel works if the column is already visible.

Since your browse is very large, best thing to do is to oBrw:GoRight() 46 times.

We can have a general function for this.

Code: Select all | Expand

function XbrGoToCol( oBrw, nCol )

   local n

   nCol := Max( nCol, Len( oBrw:aCols ) )
   for n := 2 to nCol
      oBrw:GoRight()
   next

return nil
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: xBrowse setPos(n,n) error

Post by nageswaragunupudi »

I understand that you want to show the 47th column as the first column after the freeze.
We can try this:

Code: Select all | Expand

function XbrGoToCol( oBrw, nCol )

   oBrw:GoRightMost()
   do while oBrw:SelectedCol():nCreationOrder > nCol
      oBrw:GoLeft()
   enddo


return nil
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
Rick Lipkin
Posts: 2668
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: xBrowse setPos(n,n) error

Post by Rick Lipkin »

Rao

I modified your code and got the colummn to show up in the right place, but the cursor os off 3 columns to the right.

Rick Lipkin

Code: Select all | Expand


//-------------------------------
function XbrGoToCol( oBrw, nCol1 )

   local n

  * nCol1 := Max( nCol1, Len( oBrw:aCols ) )
   msginfo( Ncol1 )

   for n := 0 to nCol1
        oBrw:GoRight()
   next

return nil
 



Image
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: xBrowse setPos(n,n) error

Post by nageswaragunupudi »

Mr Rick
Please try the code in my last post
Regards

G. N. Rao.
Hyderabad, India
User avatar
Rick Lipkin
Posts: 2668
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: xBrowse setPos(n,n) error

Post by Rick Lipkin »

Rao

Your last post gave this result :

Code: Select all | Expand


//--------------------------------------
function XbrGoToCol( oBrw, nCol1 )

   oBrw:GoRightMost()
   do while oBrw:SelectedCol():nCreationOrder > nCol1
      oBrw:GoLeft()
   enddo


return nil
 


Image

The modified second verson got the correct column but the cursor went to the wrong cell ..

Code: Select all | Expand


//-------------------------------
function XbrGoToCol( oBrw, nCol1 )

   local n

  * nCol1 := Max( nCol1, Len( oBrw:aCols ) )
  * msginfo( Ncol1 )

   for n := 0 to nCol1
        oBrw:GoRight()
   next

return nil
 


Image
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: xBrowse setPos(n,n) error

Post by nageswaragunupudi »

Mr Rick
Please try this:

Code: Select all | Expand

function XbrGoToCol( oBrw, nCol1 )

   oBrw:nColOffSet := nCol1 - oBrw:nFreeze
   oBrw:nColSel     := oBrw:nFreeze + 1

return nil
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
Rick Lipkin
Posts: 2668
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: xBrowse setPos(n,n) error

Post by Rick Lipkin »

Rao

It worked .. but had to add oBrw:ReFresh(),SysReFresh() .. Once the browse was refreshed .. the column and cursor lined up correctly ..

Thanks
Rick

Code: Select all | Expand


//-------------------------------------
function XbrGoToCol( oBrw, nCol1 )

   oBrw:nColOffSet := nCol1 - oBrw:nFreeze
   oBrw:nColSel     := oBrw:nFreeze + 1
   oBrw:ReFresh()
   SysReFresh()

return nil
 
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: xBrowse setPos(n,n) error

Post by nageswaragunupudi »

SysRefresh() won't be necessary.
I feel it is better to use oBrw:Refresh() separately after this function. In the ON INIT clause, we may use more instructions and at the end we can use oBrw:Refresh() once.
Regards

G. N. Rao.
Hyderabad, India
User avatar
Rick Lipkin
Posts: 2668
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: xBrowse setPos(n,n) error

Post by Rick Lipkin »

Thanks Roa !!
Post Reply