In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

access objects from a function

Xailer professional forum in English
Ron Broere
Mensajes: 44
Registrado: Dom Abr 19, 2009 10:01 am

access objects from a function

Mensaje por Ron Broere »

How can I access the form or object from a function?
In the example I have a recursive function to delete files with a certain
extension. I want to make a progress bar on the form, but from within the
function I cannot access the form or the application or any object. Should I
convert the function to a method? How?
Example:
//---------------------------------------------------------- --------------------
STATIC FUNCTION DIR_RECURS( cPath, cMask)
local x, aFiles, nFilCount
aFiles := directory( cPath + '*.*', 'D' )
nFilCount := len( aFiles )
for x := 1 to nFilCount
if aFiles[ X, F_NAME ] <> '..'
// it is a file,
// do we want to delete it?
IF right( aFiles[ X, F_NAME ],3) == cMask
IF FERASE( cPath + "" + aFiles[ X, F_NAME ])
nResult++
// updating the form does not work from inside this function
// NO SELF
::oLabel3:lVisible := .t.
//
ENDIF
ENDIF
endif
if 'D' $ aFiles[ X, F_ATTR ]
if aFiles[ X, F_NAME ] <> '.'
DIR_RECURS( cPath + '' + aFiles[ X, F_NAME ], cMask )
endif
endif
next
RETURN NIL
Responder