FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Xbrowse : Check by database names or Xbrowse names
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM

Xbrowse : Check by database names or Xbrowse names

Posted: Tue Aug 08, 2017 02: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.08 with Harbour
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: Xbrowse : Check by database names or Xbrowse names

Posted: Wed Aug 09, 2017 01: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
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM

Re: Xbrowse : Check by database names or Xbrowse names

Posted: Wed Aug 09, 2017 07: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

Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM

Re: Xbrowse : Check by database names or Xbrowse names

Posted: Wed Aug 09, 2017 07:52 PM

Sorry Rick, I don't folow what you mean ? Could you explace a little more ?

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM

Re: Xbrowse : Check by database names or Xbrowse names

Posted: Thu Aug 10, 2017 03: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
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM

Re: Xbrowse : Check by database names or Xbrowse names

Posted: Thu Aug 10, 2017 08: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.08 with Harbour
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: Xbrowse : Check by database names or Xbrowse names

Posted: Fri Aug 11, 2017 06: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
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM

Re: Xbrowse : Check by database names or Xbrowse names

Posted: Fri Aug 11, 2017 07: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.08 with Harbour

Continue the discussion