FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index To do - WishList / Por hacer - Peticiones Wish: Function to show any type of data
Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
Wish: Function to show any type of data
Posted: Fri Dec 19, 2008 01:40 PM

A function that acts like Alert() but show:
Objects(name, type)
String(value,len,OEM/ANSI)
Numeric(value)
Date(value)
Array(value of each data, even if multidimensional)
Null(show a message tha it's nil with a different color)

I think that it can be done easily and will give a help to many developpers.

Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Wish: Function to show any type of data
Posted: Fri Dec 19, 2008 01:59 PM

Samir,

You can use MsgInfo( uValue ), or MsgAlert( uValue ), or MsgStop( uValue ).

Also you have cValToChar( uValue ) that converts any value to a string.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
Wish: Function to show any type of data
Posted: Fri Dec 19, 2008 03:46 PM

Antonio, some of these functions returns the value of multidimensional array?

Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Wish: Function to show any type of data
Posted: Tue Dec 23, 2008 11:28 AM

No, you have to code it by yourself, using a browse or a tree, or building a string yourself.

Those functions will show "Array".

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
Wish: Function to show any type of data
Posted: Tue Dec 23, 2008 05:50 PM

If I ain't wrong, some of these functions don't accept null too....
I im thinking in a universal function to show values, maybe a upgrade in the functions or a new function....

I know that I can do it myself, but I'm not thinking only im me...
It will help me to avoid add a procedure at each project only.

Thanks, merry christmas and happy new year!

Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM
Wish: Function to show any type of data
Posted: Tue Dec 23, 2008 05:54 PM

Hello
you have to try in fwh\samples\insptest.prg ( from older version of FW )
it works to inspect array and object

Regards MAurizio

Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
Wish: Function to show any type of data
Posted: Tue Dec 23, 2008 06:46 PM

Maurizio, is something like that but why not change the actual functions to do this?
or add a procedure: Analyse( uVar )
that send message( like Alert(), Msg() ) with the type of the data(in the title) and the value.
All I want is to group already done functions to a better result.

Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
Posts: 1088
Joined: Fri Oct 07, 2005 03:33 PM
Re: Wish: Function to show any type of data
Posted: Mon Dec 29, 2008 02:27 AM
Hello,

you can start with this tiny example, and extend for other data types

#include "FiveWin.ch" 
#include "xbrowse.ch"


function Main() 
       viewdata( {"a","b","c", {"A","B","C", {1,"2", DATE() } } } )
return nil 

//----------------------------------------------------------------------------// 
FUNCTION viewdata( data )
//----------------------------------------------------------------------------// 
       
       IF VALTYPE( data ) = "A"
	  viewarray( data )
       ELSE
          msginfo( data )
       ENDIF

RETURN NIL

//----------------------------------------------------------------------------// 
STATIC FUNCTION viewarray( aArray ) 
//----------------------------------------------------------------------------// 
   LOCAL oBrw, oDlg, aData := {}, i 

   FOR i := 1 TO LEN( aArray )
       DO CASE
          CASE valtype( aArray[i] ) = "D" ; AADD( aData, {i, "D", DTOC( aArray[i] ) } )
	  CASE valtype( aArray[i] ) = "N" ; AADD( aData, {i, "N", STR( aArray[i] ) } )
	  CASE valtype( aArray[i] ) = "L" ; AADD( aData, {i, "L", IF( aArray[i], ".T.", ".F." ) } )
	  CASE valtype( aArray[i] ) = "C" ; AADD( aData, {i, "C", aArray[i] } )
	  CASE valtype( aArray[i] ) = "A" ; AADD( aData, {i, "A", "ARRAY" } )
       ENDCASE
   NEXT

   DEFINE DIALOG oDlg FROM 1,1 TO 20,28

   @ 0,0 XBROWSE oBrw ;
              OF oDlg ;
	   ARRAY aData ;
	 HEADERS "Ind", "Tipo", "Valor" ;
         JUSTIFY .T., 2, .F.;
        COLSIZES 30,30,100 ;
        AUTOCOLS ;
       ON CHANGE oDlg:aEvalWhen()
   
   oBrw:lHScroll      := .F.
   oBrw:lVScroll      := .T.
   oBrw:nMarqueeStyle := 5
   oBrw:nRowHeight    := 20
   oDlg:oClient       := oBrw

   oBrw:CreateFromCode()

   @ 7,01 BUTTON "Array" OF oDlg WHEN aData[ oBrw:nArrayAt, 2 ] == "A" ACTION viewarray( aArray[oBrw:nArrayAt] )
   @ 7,12 BUTTON "Salir" OF oDlg	ACTION oDlg:end()

   ACTIVATE DIALOG oDlg ON INIT oBrw:SetFocus() 

RETURN NIL


regards

Marcelo
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Wish: Function to show any type of data
Posted: Fri Dec 18, 2009 06:27 PM

Now
XBrowse( <anydatatype> )
works

Regards



G. N. Rao.

Hyderabad, India
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: Wish: Function to show any type of data
Posted: Mon Dec 21, 2009 01:43 AM

Samir,
I find ValToPrg() helps me a lot in my debugging. It's a function in xHarbour. I normally use it to inspect arrays

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour

Continue the discussion