XBROWSE <binary> problem

XBROWSE <binary> problem

Postby avista » Fri Jun 22, 2012 12:08 pm

Hi all,
I have xbrowse created with data received from the SQL SELECT statement.
In some cases in some columns in some row i get field data (field info) <binary>
Probably in some row of that column there is some binary characters.

My question is how to define that that column is only a sample text column.

Best regards,
User avatar
avista
 
Posts: 301
Joined: Fri Jun 01, 2007 9:07 am
Location: Macedonia

Re: XBROWSE <binary> problem

Postby ukoenig » Fri Jun 22, 2012 12:16 pm

Same Question, but couldn't find out the reason for it :

viewtopic.php?f=3&t=24050&p=129498&hilit=xbrowse+binary#p129498

Best Regards
Uwe
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
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: XBROWSE <binary> problem

Postby Rick Lipkin » Fri Jun 22, 2012 1:50 pm

avista

If you want to design a custom xBrowse .. you can define your standard columns and then insert your Binary Column at a specific column ( in this case column 5 ) and the Code Block allows you to Return any value you like to view in column 5.

Rick Lipkin

Code: Select all  Expand view

 ADD oCol TO oLbx AT 5 DATA {|x| x := _ChkComp(oRsRepair:Fields("cc"):Value) };
                   HEADER "Instructions" size 165
...
...

//-------------------
Static Func _ChkComp( cComplaint )

Local cName

cName := cComplaint

Return(cName)


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

Re: XBROWSE <binary> problem

Postby avista » Sat Jun 23, 2012 3:07 pm

Hi Rick
And thanks for reply
I dont know the field names or sizes or types ... received from the SQL SELECT statement...
But that is not problem ...
Problem is that sometimes user put TAB key not SPACE ... and in XBROWSE that is BINARY valye.
See this sample.
Code: Select all  Expand view
#include "FiveWin.ch"
#include "xbrowse.ch"

function Main()

   local oDlg, oBrw

   DEFINE DIALOG oDlg SIZE 300, 200

   @ 0, 0 XBROWSE oBrw OF oDlg ;
          ARRAY { "Tom Jones", "Tom"+chr(32)+"Jones", "Tom"+chr(14)+"Jones" } ;
          AUTOCOLS

   oBrw:CreateFromCode()

   ACTIVATE DIALOG oDlg CENTER

return nil
 


In this case the row 3 have <binary> value.

Some help or sugestions ?

Best regards,
User avatar
avista
 
Posts: 301
Joined: Fri Jun 01, 2007 9:07 am
Location: Macedonia

Re: XBROWSE <binary> problem

Postby nageswaragunupudi » Sun Jun 24, 2012 2:10 pm

If the value of a column is displayable text, it displays the text ( either in a single row or if space of the cell permits in multiple rows even ).

If the value contains non-printable characters, obviously it can not display it as text.

Still xbrowse makes an effort to examine if it is a valid image buffer. If it is a valid image buffer it displays the image.

Still after all efforts there are unprintable characters, it indicates that the value contains <binary> data. So that the programmer knows that his table contains some binary data and can provide an appropriate conversion function to display the data in a printable form.
Regards

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

Re: XBROWSE <binary> problem

Postby avista » Mon Jun 25, 2012 3:01 pm

Hi Rao
Thanks for reply
It is not problem to create conversion function
For example

Code: Select all  Expand view
function Conversion(uData)

   local cReturn := ""
   local i       := 0

   for i = 1 to len(uData)
       if asc(substr(uData,i,1)) < 32
          cReturn := cReturn + "?"
        else
          cReturn := cReturn + substr(uData,i,1)
       endif
   next

return cReturn


But where and how to use that function in XBROWSE

Best regards,
User avatar
avista
 
Posts: 301
Joined: Fri Jun 01, 2007 9:07 am
Location: Macedonia

Re: XBROWSE <binary> problem

Postby reinaldocrespo » Mon Jun 25, 2012 3:06 pm

Avista;

Use Rick's suggestion. Simply replace your function into the code block for all columns.


Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: XBROWSE <binary> problem

Postby nageswaragunupudi » Mon Jun 25, 2012 3:27 pm

Like our friends suggested above, we need to provide our codeblock.
Several ways of doing it.
Example 1
If we are browsing fwh\samples\customer.dbf and we expect some control chars in the NOTES field
Method-1
@ 0,0 XBROWSE oBrw OF oWnd ;
COLUMNS "First", "Last", "City", "Notes" ;
< .... other clauses >
....
oBrw:Notes:bStrData := { || MyConvert( Eval( oBrw:Notes:bEditValue ) ) }

Method-2

@ 0,0 XBROWSE oBrw OF oWnd ALIAS "CUSTOMER" ;
COLUMNS "First", "Last", "City", { || MyConvert( FIELD->NOTES ) } ;
< .... other clauses >

Array Example:
Assuming we expect 3rd column to contain control chars
@ 0,0 XBROWSE oBrw ARRAY aData ;
COLUMNS 1, 2, { || MyConvert( oBrw:aRow[ 3 ] ) } ;
HEADERS ......<continue with other clauses )

OOPS example:
WITH OBJECT oBrw:AddCol
:bEditValue := { || MyConvert( FIELD->NOTES ) }
END
Regards

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

Re: XBROWSE <binary> problem

Postby avista » Wed Jun 27, 2012 1:48 pm

Hi Rao,
Thanks verry much for reply.

One more Question please,
How to detect non-printable characters ? (control chars like you said) .
Less than 32 or ? (probably no ...CRLF chr(13)+chr(10) is not binary ... ?)
Which ASCII codes to control ? Is it good to replace them with "?" or ?
Or need i analize blocks ?

Thanks again for helping,
Best regards.
User avatar
avista
 
Posts: 301
Joined: Fri Jun 01, 2007 9:07 am
Location: Macedonia

Re: XBROWSE <binary> problem

Postby Rick Lipkin » Wed Jun 27, 2012 2:27 pm

Avista

A quick question .. what is the field name of the binary column ? Generally Binary designates a 'file' of some sort stored in that field which is in hex .. it could be a document, picture, .pdf file ...

I don't think you will be able to determine what is in the binary field without some knowledge of the table.

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

Re: XBROWSE <binary> problem

Postby nageswaragunupudi » Wed Jun 27, 2012 2:31 pm

avista wrote:Hi Rao,
Thanks verry much for reply.

One more Question please,
How to detect non-printable characters ? (control chars like you said) .
Less than 32 or ? (probably no ...CRLF chr(13)+chr(10) is not binary ... ?)
Which ASCII codes to control ? Is it good to replace them with "?" or ?
Or need i analize blocks ?

Thanks again for helping,
Best regards.


Please try using FiveWin function IsBinaryData( <cVar> ) --> .t. or .f.
Regards

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

Re: XBROWSE <binary> problem

Postby avista » Fri Jun 29, 2012 8:42 am

Hi
And thanks to all for reply

This funciion is working good BUT
Code: Select all  Expand view

FUNCTION MyBinaryConversion( cData )

local cVrati := ""
local cChar  := ""
local nAsc   := 0
local i      := 0

IF !IsBinaryData( cData )
   return cData
ENDIF

FOR i = 1 TO LEN( cData )
    cChar := SUBSTR( cData, i, 1 )
    nAsc  := ASC( cChar )

    IF nAsc <  32 .AND. ;
       nAsc <>  9 .AND. nAsc<> 10 .AND. nAsc<> 13 .AND. nAsc<> 26
       cVrati := cVrati + CHR( 127 )
     ELSE
       cVrati := cVrati + cChar
    ENDIF
NEXT

RETURN cVrati
 


BUT I HAVE OTHER PROBLEM

The database i use (.DBF) is created by SQL SELECT statement and i dont know the fieldnames ... (columns names)
I have try this code:

Code: Select all  Expand view

FOR i := 1 TO Fcount()
    IF !Empty( oCol := oBrw:oCol( oBrw:oCol(i):cHeader ) )
       IF FieldType( i ) == "M" .OR. ;
          FieldType( i ) == "C"
          oCol:bStrData := { || MyBinaryConversion( EVAL(oCol:bEditValue) ) }
       ENDIF
    ENDIF
NEXT
 


But in XBROWSE i have the same data in all columns (data from the last column)
Probably becouse at the end of FOR,NEXT ciclusulse 'i' have value of Fcount() and EVAL(oCol:bEditValue) return value of last column for all columns.
I cant use the stagement like this:
oBrw:Notes:bStrData := { || MyBinaryConversion( Eval( oBrw:Notes:bEditValue ) ) }
becouse like i said i dont know the column names.

I have try this:
Code: Select all  Expand view

FOR i := 1 TO Fcount()
    IF !Empty( oCol := oBrw:oCol( oBrw:oCol(i):cHeader ) )
       IF FieldType( i ) == "M" .OR. ;
          FieldType( i ) == "C"
          cField := oBrw:oCol(i):cHeader
          oBrw:oCol(cField):bStrData := { || MyBinaryConversion(EVAL(oBrw:oCol(cField):bEditValue)) }
       ENDIF
    ENDIF
NEXT
 


BUT THE SAME RESULTS all columns have the same value of the last column

I have no more solutions so
Please help

BEST best regards,
Last edited by avista on Wed Jul 04, 2012 6:59 am, edited 1 time in total.
User avatar
avista
 
Posts: 301
Joined: Fri Jun 01, 2007 9:07 am
Location: Macedonia

Re: XBROWSE <binary> problem

Postby avista » Wed Jul 04, 2012 6:59 am

Hi,
I still need help ...
Regards,
User avatar
avista
 
Posts: 301
Joined: Fri Jun 01, 2007 9:07 am
Location: Macedonia

Re: XBROWSE <binary> problem

Postby avista » Sat Jul 07, 2012 12:53 pm

?
User avatar
avista
 
Posts: 301
Joined: Fri Jun 01, 2007 9:07 am
Location: Macedonia

Re: XBROWSE <binary> problem

Postby avista » Tue Jul 10, 2012 8:21 pm

Everyone on vacation ?
:)

Regards.
User avatar
avista
 
Posts: 301
Joined: Fri Jun 01, 2007 9:07 am
Location: Macedonia

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 95 guests