Wish: Function to show any type of data

Post Reply
User avatar
sambomb
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Wish: Function to show any type of data

Post by sambomb »

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
Antonio Linares
Site Admin
Posts: 42529
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 77 times
Contact:

Post by Antonio Linares »

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
sambomb
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Post by sambomb »

Antonio, some of these functions returns the value of multidimensional array?
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
User avatar
Antonio Linares
Site Admin
Posts: 42529
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 77 times
Contact:

Post by Antonio Linares »

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
sambomb
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Post by sambomb »

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
Maurizio
Posts: 826
Joined: Mon Oct 10, 2005 1:29 pm
Contact:

Post by Maurizio »

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
sambomb
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Post by sambomb »

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
Marcelo Via Giglio
Posts: 1077
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia
Has thanked: 1 time

Re: Wish: Function to show any type of data

Post by Marcelo Via Giglio »

Hello,

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

Code: Select all | Expand

#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
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: Wish: Function to show any type of data

Post by nageswaragunupudi »

Now
XBrowse( <anydatatype> )
works
Regards

G. N. Rao.
Hyderabad, India
hua
Posts: 1076
Joined: Fri Oct 28, 2005 2:27 am
Has thanked: 1 time
Been thanked: 1 time

Re: Wish: Function to show any type of data

Post by hua »

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
Post Reply