Wish: Function to show any type of data

Wish: Function to show any type of data

Postby sambomb » Fri Dec 19, 2008 1: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
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Postby Antonio Linares » Fri Dec 19, 2008 1: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42097
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby sambomb » Fri Dec 19, 2008 3:46 pm

Antonio, some of these functions returns the value of multidimensional array?
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 42097
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby sambomb » Tue Dec 23, 2008 5: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
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Postby Maurizio » Tue Dec 23, 2008 5: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
User avatar
Maurizio
 
Posts: 824
Joined: Mon Oct 10, 2005 1:29 pm

Postby sambomb » Tue Dec 23, 2008 6: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
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: Wish: Function to show any type of data

Postby Marcelo Via Giglio » Mon Dec 29, 2008 2:27 am

Hello,

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

Code: Select all  Expand view
#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
Marcelo Via Giglio
 
Posts: 1064
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: Wish: Function to show any type of data

Postby nageswaragunupudi » Fri Dec 18, 2009 6:27 pm

Now
XBrowse( <anydatatype> )
works
Regards

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

Re: Wish: Function to show any type of data

Postby hua » Mon Dec 21, 2009 1: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
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am


Return to To do - WishList / Por hacer - Peticiones

Who is online

Users browsing this forum: No registered users and 6 guests