OutputDebugString(

Post Reply
Vladimir Zorrilla
Posts: 225
Joined: Tue Feb 28, 2006 4:25 pm
Location: PERU

OutputDebugString(

Post by Vladimir Zorrilla »

Amigos Leyendo en http://codigo-base.blogspot.com/ hay un tema que dice Depurando en Windows

Y precisa que podemos invocar desde FW esta funcion del API

IF File( "test.txt" )
OutputDebugString( "El archivo existe" + hb_osnewline() )
ELSE
OutputDebugString( "El archivo no existe" + hb_osnewline() )
ENDIF

Al incluir esto en nuestro codigo fuente realmente no estaremos viendo nada, en primer lugar antes de ejecutar nuestro programa debemos tener en ejecucion dbwin32.exe, este programa se encarga de mostrar en pantalla la informacion pasada como parametro a la funcion
OutputDebugString().


CUando pongo esta fuincion me sale un error

UNRESOLVED EXTERNAL hb_fun_OutputDebugString

que LIB contiene el soporte a esta funcion del API
que deba poner en mi lnk.

Gracias
ME INTERESA FW Y XHB POR SER OPEN SOURCE
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Vladimir,

Aqui la tienes:

Code: Select all

#include "FiveWin.ch" 

function Main() 

   OutputDebugString( "Test" ) 

return nil 

#pragma BEGINDUMP 

#include <hbapi.h> 
#include <windows.h>

HB_FUNC( OUTPUTDEBUGSTRING ) 
{ 
   OutputDebugString( hb_parc( 1 ) );    
} 

#pragma ENDDUMP
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Y aqui una copia de DbWin32.zip para que la tengamos siempre a mano :-)

www.fivetechsoft.com/files/utilities/dbwin32.zip
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
carlos vargas
Posts: 1421
Joined: Tue Oct 11, 2005 5:01 pm
Location: Nicaragua

Post by carlos vargas »

Funciona de la siguiente forma, en cualquier parte de su programa use

Code: Select all

??? date(), time(), version(), 1+1
:-)

archivo .ch

Code: Select all

#xcommand ??? <xData> [, <xDataN> ] => OutPutDebugString( <xData> ) ;
                                   	[; OutPutDebugString( <xDataN>) ]

archivo .prg

Code: Select all

FUNCTION OutPutDebugString(xVal)
   OutPutDebugStringC( HB_ValToStr(xVal) )
RETURN NIL

#pragma BEGINDUMP

#include "windows.h"
#include "hbapi.h"
#include "hbapiitm.h"
#include "hbapierr.h"


HB_FUNC( OUTPUTDEBUGSTRINGC )
{
   OutputDebugStringA( hb_parc( 1 ) );
}

HB_FUNC ( EXITPROCESS )
{
  ExitProcess( 0 ) ;
}

#pragma ENDDUMP
Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
Carlos Mora
Posts: 988
Joined: Thu Nov 24, 2005 3:01 pm
Location: Madrid, España

Post by Carlos Mora »

Gente,
tengo una definición de comando que uso hace bastante tiempo, que te pasa no solo el valor sino tambien la lineas de la funcion donde se invoca, y la expresion evaluada. Al ser un comando, se puede hacer una definición nula cuando se compila la version final.

Code: Select all


#ifdef __RELEASE__

# xtranslate DEBUG <clauses, ...> =>

#else

#translate ASSTRING( <x> ) => If( <x> == NIL, 'NIL', Transform( <x> , NIL ) ) + CRLF

#xcommand DEBUG <cString1>[, <cStringN>] ;
         => ;
          OutputDebugString( ProcName() +"("+LTrim(Str(ProcLine())) +") - " ) ; OutputDebugString( <"cString1">+" ("+ValType( <cString1> )+"): " ) ; OutputDebugString( ASSTRING( <cString1> ) ) ;
          [ ; OutputDebugString( ProcName() +"("+LTrim(Str(ProcLine())) +") - " ) ; OutputDebugString( <"cStringN">+" ("+ValType( <cStringN> )+"): " ) ; OutputDebugString( ASSTRING( <cStringN> ) ) ]

#endif

Es interesante tambien el uso de transform para hacer string casi cualquier cosa, pero no es el tema a tratar ;)

Por ejemplo, si ponemos en la línea 895 de bitmap.prg la sig. línea,

Code: Select all


   DEBUG ::lScroll, nVisHeight, nVisWidth, ::hBitmap, ::oVScroll

Un ejemplo de lo que obtendremos en dBWin32 podría ser:

Code: Select all

TBITMAP:SCROLLADJUST(895) - ::lScroll (L): F
TBITMAP:SCROLLADJUST(895) - nVisHeight (N):        329
TBITMAP:SCROLLADJUST(895) - nVisWidth (N):        450
TBITMAP:SCROLLADJUST(895) - ::hBitmap (N):          -1509616760
TBITMAP:SCROLLADJUST(895) - ::oVScroll (U): NIL
TBITMAP:SCROLLADJUST(895) - ::lScroll (L): F
TBITMAP:SCROLLADJUST(895) - nVisHeight (N):        656
TBITMAP:SCROLLADJUST(895) - nVisWidth (N):       1024
TBITMAP:SCROLLADJUST(895) - ::hBitmap (N): -536539779
TBITMAP:SCROLLADJUST(895) - ::oVScroll (U): NIL

Esto nos ayuda a saber Exactamente que estamos viendo, porque si imprimimos solo el valor en outdebug no sabremos exactamente a que variable o campo corresponde, ni a que punto del programa corresponde si tenemos muchos valores.

Y todo esto se quita con añadir un /D__RELEASE__ en la línea de compilación de los prgs!

Espero que les sea tan útil como a mí,

Carlos.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Carlos,

Muy buena aportación. Gracias! :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply