Xbrowse : Check by database names or Xbrowse names

Xbrowse : Check by database names or Xbrowse names

Postby Marc Venken » Tue Aug 08, 2017 2:43 pm

Hello,

Best technique for this kind of checks (If a certain condition, then color....)

oBrw[6]:T4:bClrStd := { || if (at( oRs:t1_4 , 'AZKSVTXF' ) > 0 , { CLR_BLACK,CLR_HRED } , { CLR_BLACK,CLR_WHITE } ) }

In a online system (oRs) do we check by the fieldnames of the database of do you prefer to check the values from the Xbrowse.
(I have no sample for this now)

Check by database, will look into the online system, and that is maybe no the ideal situation.
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1431
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Xbrowse : Check by database names or Xbrowse names

Postby nageswaragunupudi » Wed Aug 09, 2017 1:30 pm

We advise you to use XBrowse names as far as possible. This helps us to write code portable across different data sources.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Xbrowse : Check by database names or Xbrowse names

Postby Rick Lipkin » Wed Aug 09, 2017 7:37 pm

Marc

Be careful in your code block that your oRs:Field or NOT Null .. put another in line If( oRs:Eof, ,your code )

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

Re: Xbrowse : Check by database names or Xbrowse names

Postby Marc Venken » Wed Aug 09, 2017 7:52 pm

Sorry Rick, I don't folow what you mean ? Could you explace a little more ?
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1431
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Xbrowse : Check by database names or Xbrowse names

Postby Rick Lipkin » Thu Aug 10, 2017 3:43 pm

Marc

Lets say your recordset returned zero rows and you are at :eof ... when you create your code block

oBrw[6]:T4:bClrStd := { || if (at( oRs:t1_4 , 'AZKSVTXF' ) > 0 , { CLR_BLACK,CLR_HRED } , { CLR_BLACK,CLR_WHITE } ) }


Hard to read what oRs:t1_4 actually is ?? ... if you are asking for a value from an oRs Field ... what do you think might happen if you are are oRs:Eof .. there is no field value because there are no rows and you may ( probably will ) get a run-time error ...

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

Re: Xbrowse : Check by database names or Xbrowse names

Postby Marc Venken » Thu Aug 10, 2017 8:22 pm

You are right ! Have to think of this.

In the sample above, it was the idea to get rid of the oRs calls, but use the Xbrowse field instead, because it is a simple call to color a column in the browse.
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1431
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Xbrowse : Check by database names or Xbrowse names

Postby nageswaragunupudi » Fri Aug 11, 2017 6:53 am

oBrw:oCol:Value is safer and simpler. This never fails.

If the browse is something like:

@ r,c XBROWSE ..... COLUMNS "FIRST", "LAST", ......... HEADERS "FirstName", "LastName", .......

Then
condition like oBrw:FirstName:Value = <something> is better than oRs:First value or oRs:Fields( "first" ):Value.

Reasons:
1. oBrw:Col:Value never errors out
2. This works whether you are browsing DBF, ADO recordset or MYSQL or any other datasource.

XBrowse and TDatarow are specifically made to enable programmer to write portable code.
If you still refer to or use oRs or cAlias you have decided not to take advantage the power of xbrowse.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Xbrowse : Check by database names or Xbrowse names

Postby Marc Venken » Fri Aug 11, 2017 7:04 am

Thanks.

And no, I surely prefer also the Xbrowse code. I just had not the code yet... Now I have :D
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1431
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 107 guests