FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour OutputDebugString(
Posts: 225
Joined: Tue Feb 28, 2006 04:25 PM
OutputDebugString(
Posted: Tue Sep 30, 2008 07:58 PM

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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
OutputDebugString(
Posted: Tue Sep 30, 2008 09:07 PM
Vladimir,

Aqui la tienes:
#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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
OutputDebugString(
Posted: Tue Sep 30, 2008 09:11 PM

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
Posts: 1789
Joined: Tue Oct 11, 2005 05:01 PM
OutputDebugString(
Posted: Tue Sep 30, 2008 11:16 PM
Funciona de la siguiente forma, en cualquier parte de su programa use
??? date(), time(), version(), 1+1

:-)

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


archivo .prg
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)
Posts: 989
Joined: Thu Nov 24, 2005 03:01 PM
OutputDebugString(
Posted: Wed Oct 01, 2008 01:48 PM
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.


#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,

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


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

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.
Saludos
Carlos Mora
http://harbouradvisor.blogspot.com/
StackOverflow http://stackoverflow.com/users/549761/carlos-mora
鈥淚f you think education is expensive, try ignorance"
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
OutputDebugString(
Posted: Wed Oct 01, 2008 02:02 PM

Carlos,

Muy buena aportaci贸n. Gracias! :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion