FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Column with progressive number with xBrowse
Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
Column with progressive number with xBrowse
Posted: Wed Jul 09, 2008 06:40 PM

Hi all,
I need to display a column with the progressive number in a xBrowse.

I always used the following command with the standard browse:

ADD COLUMN TO oBrw DATA oBrw:nAt() ;
HEADER "Num" SIZE 30 RIGHT

Do you know the equivalent command to make this with xBrowse ?

Thanks.

Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Column with progressive number with xBrowse
Posted: Wed Jul 09, 2008 10:35 PM

nArrayAt in xBrowse is the same as nAt of WBrowse.

Regards



G. N. Rao.

Hyderabad, India
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Column with progressive number with xBrowse
Posted: Wed Nov 19, 2008 07:52 AM
How can I achieve the progressive no's while using Recordset (ADO) with xBrowse

I am getting error when I try nArrayAt and nAt

Error Base/1111 Argument Error : Len From ErroSys, Line:0

Code

*-----------------------------------*
FUNCTION connect()
*-----------------------------------*
Local SQL,oBrw
Local oCon := CreateObject('ADODB.Connection') 
Local oRecSet := CreateObject( "ADODB.RecordSet" ) 

oCon:ConnectionString:= "Driver={MySQL ODBC 3.51 Driver};Server=192.168.0.170;Port=3306;Database=MyDataBase;User=MyUser;Password=MyPassword;Option=3;"
TRY
   oCon:Open()
   msgInfo("Connected to Database")  
CATCH oError
   MsgInfo("Connection Failed")
   RETURN(.F.)
END 

oRecSet:CursorLocation := adUseClient
oRecSet:LockType := adLockOptimistic
oRecSet:CursorType := adOpenDynamic
oRecSet:Source := "SELECT * FROM ISSUE_TRA WHERE FIN_YEAR=2004"
oRecSet:ActiveConnection(oCon) 
oRecSet:Open()

if oRecSet:BOF .AND. oRecSet:EOF
	Msginfo("No Records")
	Return .F.
Endif

oRecSet:MoveFirst()

@0,0 XBROWSE oBrw ;
     OF oWnd ;          
     OBJECT oRecSet;
     LINES CELL
 
oCol:=oBrw:AddCol()
oCol:cHeader:="No #"
oCol:bStrdata:={ || oBrw:nArrayAt }   // Problem is here

oBrw:CreateFromCode()

RETURN .T.


Regards

Anser
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Column with progressive number with xBrowse
Posted: Wed Nov 19, 2008 02:27 PM
Anser:

Try with oRecSet:AbsolutePosition()

oCol:bStrdata:={ || TRANSFORM(oRecSet:AbsolutePosition(),"@Z 99999") }


:AbsolutePosition() it's like RecNo() in DBF's

Regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Column with progressive number with xBrowse
Posted: Wed Nov 19, 2008 03:11 PM
test it...

oCol:bStrData:=GenProgessNumber( oBrw )
....

function GenProgressNumber( oBrw )
return {|| oBrw:nArrayAt }
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Column with progressive number with xBrowse
Posted: Thu Nov 20, 2008 05:04 AM
Dear Armando

Your solution worked

oCol:bStrdata:={ || TRANSFORM(oRecSet:AbsolutePosition(),"@Z 99999") }


Dear mcfox

your solution did not work and it was giving error

oCol:bStrData:=GenProgessNumber( oBrw )
....

function GenProgressNumber( oBrw )
return {|| oBrw:nArrayAt }


So I changed your code in function GenProgressNumber( oBrw ) to

function GenProgressNumber( oBrw )
return {|| str(oBrw:nArrayAt) }


By adding str I avoided error but the progressive no in the xBrowse is always 0 in all the lines.

Thanks for your help.

I am writing it down here what I have learned and I hope that it may be useful to newbies like me and help them to reduce their learning curve. Time is valuable

So this is how we get a progressive no in xBrowse

IF Array is used in xBrowse then

oCol:bStrData:={ || oBrw:nArrayAt  }


If DBF is used in xBrowse then

oCol:bStrData:={ || str(  RecNo() )   } // I am doubtful here what happens if the DBF is indexed


If RecordSet is used in xBrowse
oCol:bStrdata:={ || TRANSFORM(oRecSet:AbsolutePosition(),"@Z 99999") } 
                OR
oCol:bStrdata:={ || str(oRecSet:AbsolutePosition() ) }


Regards

Anser
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Column with progressive number with xBrowse
Posted: Thu Nov 20, 2008 07:45 AM
anserkk wrote:
oCol:bStrData:={ || str(  RecNo() )   } // I am doubtful here what happens if the DBF is indexed


You can use OrdKeyNo() instead. But please build indexes with FOR !Deleted() clause or you will have holes in the numbers sequence.

EMG
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Column with progressive number with xBrowse
Posted: Thu Nov 20, 2008 07:50 AM
Dear EMG

Is there any other way to show a progressive no on xBrowse when used with a DBF other than using OrdKeyNo() with !Delted clause in the index ?

You can use OrdKeyNo() instead. But please build indexes with FOR !Deleted() clause.


Regards

Anser
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Column with progressive number with xBrowse
Posted: Thu Nov 20, 2008 08:23 AM

I don't know, sorry.

EMG

Continue the discussion