From: BatiVenci on
Dear VO-ers !!!

Wish YOU ALL THE BEST for the New 2010 Year !

And now, my simple question:

there is a function: ClassName( SELF ) ---> symValue which returns the
symboloc name of the class from which it has been invoked.
Is there a way, to retrieve the Name / symName of the method/access/
assign where am I now ?

TIA, Venci
From: John Martens on
Could this help ?

John


FUNCTION LeesPrgStack() AS STRING
*
* Functie om aanroep stack te tonen
*
* function to return the program calling stack
*
LOCAL cPrgStack AS STRING
LOCAL dwPrgNr AS DWORD
LOCAL dwPrgStartNr AS DWORD
*
* stack vaststellen
dwPrgStartNr := 2
cPrgStack := ''
dwPrgNr := dwPrgStartNr
DO WHILE Len(AllTrim(Psz2String(ProcName(dwPrgNr)))) > 0
*
* naam opbergen in string
IF dwPrgNr > dwPrgStartNr
cPrgStack := cPrgStack + Space(1*(dwPrgNr-dwPrgStartNr)+1)+'--> '
ENDIF
cPrgStack := cPrgStack + Psz2String(ProcName(dwPrgNr))
IF ProcLine(dwPrgNr) > 0
cPrgStack := cPrgStack + '(' + NTrim(ProcLine(dwPrgNr)) + ')'
ENDIF
cPrgStack := cPrgStack + '<.>'
*
* volgende programma
dwPrgNr := dwPrgNr + 1
ENDDO
RETURN cPrgStack


Op 14-1-2010 10:50, BatiVenci schreef:
> Dear VO-ers !!!
>
> Wish YOU ALL THE BEST for the New 2010 Year !
>
> And now, my simple question:
>
> there is a function: ClassName( SELF ) ---> symValue which returns the
> symboloc name of the class from which it has been invoked.
> Is there a way, to retrieve the Name / symName of the method/access/
> assign where am I now ?
>
> TIA, Venci
From: BatiVenci on
Thanks John.

Your example gived me the clue.
The ProcName() function was what I was looking for.

I have a function
FUNCTION EventLog( cLine AS STRING )
LOCAL ptrHandle AS PTR

IF Empty( cLogFile )
RETURN FALSE
ENDIF

IF !File( cLogFile )
ptrHandle := FCreate2( cLogFile, FC_NORMAL )
IF ptrHandle != F_ERROR
FClose(ptrHandle)
ENDIF
ENDIF

ptrHandle := FOpen2( cLogFile, FO_READWRITE)
IF ptrHandle != F_ERROR
FSeek( ptrHandle, 0, FS_END )
FWriteLine( ptrHandle, cLine )
FClose( ptrHandle )
ENDIF

ptrHandle := NULL_PTR

RETURN TRUE

and the use is something like this:
EventLog( DToC( Today() ) + ' ' + Time24() + ' [E] ' +
'(xShellWindow:Correct()) -> ERROR Opening ARTICLES DataBase - ' +
oArticles:Status:Description ).

Now I want to optimize the code, to put the date, time and procname as
part of the main EventLog function, and not to pass them as parameter
every time I call the function. And ProcName( 2 ) in this case gives
me what I need.

Thanks again, Venci
From: John Martens on
Glad I could be of help.

Take care that procname is linked in your app. It is a setting and when
you leave it out your app becomes smaller but you will lose the extra in
your EvetnLog function.


Op 14-1-2010 12:42, BatiVenci schreef:
> Thanks John.
>
> Your example gived me the clue.
> The ProcName() function was what I was looking for.
>
> I have a function
> FUNCTION EventLog( cLine AS STRING )
> LOCAL ptrHandle AS PTR
>
> IF Empty( cLogFile )
> RETURN FALSE
> ENDIF
>
> IF !File( cLogFile )
> ptrHandle := FCreate2( cLogFile, FC_NORMAL )
> IF ptrHandle != F_ERROR
> FClose(ptrHandle)
> ENDIF
> ENDIF
>
> ptrHandle := FOpen2( cLogFile, FO_READWRITE)
> IF ptrHandle != F_ERROR
> FSeek( ptrHandle, 0, FS_END )
> FWriteLine( ptrHandle, cLine )
> FClose( ptrHandle )
> ENDIF
>
> ptrHandle := NULL_PTR
>
> RETURN TRUE
>
> and the use is something like this:
> EventLog( DToC( Today() ) + ' ' + Time24() + ' [E] ' +
> '(xShellWindow:Correct()) -> ERROR Opening ARTICLES DataBase - ' +
> oArticles:Status:Description ).
>
> Now I want to optimize the code, to put the date, time and procname as
> part of the main EventLog function, and not to pass them as parameter
> every time I call the function. And ProcName( 2 ) in this case gives
> me what I need.
>
> Thanks again, Venci
From: BatiVenci on
I usually use Event_Log(), as it's name shows to export some events in
the program during program flow. Normally it exports some errors, or
the value of some variables, that i need. Because of that, I hope that
there would not be any problems of the use I plan.

Venci
 | 
Pages: 1
Prev: pop:getmail()
Next: touchscreen keyboard