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
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.
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
-
- Mensajes: 44
- Registrado: Dom Abr 19, 2009 10:01 am
access objects from a function
Hello Ron
To keep your function simple add a third parameter
something like this :
STATIC FUNCTION DIR_RECURS( cPath, cMask,oForm)
If your form is the main application form you can have access on it simply
call Application:oMainForm:anyObjectInstance or
passing self as third parameter.
now in your function you need to do something like this
> oForm:oLabel3:lVisible := .t.
Hope this can help you
Best Regards
Dionisis
"Ron Broere" <ronbroere@bbkm.nl> wrote in message
news:4a54636a$[email=1@svctag-j7w3v3j....]1@svctag-j7w3v3j....[/email]
> 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
>
>
To keep your function simple add a third parameter
something like this :
STATIC FUNCTION DIR_RECURS( cPath, cMask,oForm)
If your form is the main application form you can have access on it simply
call Application:oMainForm:anyObjectInstance or
passing self as third parameter.
now in your function you need to do something like this
> oForm:oLabel3:lVisible := .t.
Hope this can help you
Best Regards
Dionisis
"Ron Broere" <ronbroere@bbkm.nl> wrote in message
news:4a54636a$[email=1@svctag-j7w3v3j....]1@svctag-j7w3v3j....[/email]
> 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
>
>
access objects from a function
Hello Ron
To keep your function simple add a third parameter
something like this :
STATIC FUNCTION DIR_RECURS( cPath, cMask,oForm)
If your form is the main application form you can have access on it simply
call Application:oMainForm:anyObjectInstance or
passing self as third parameter.
now in your function you need to do something like this
> oForm:oLabel3:lVisible := .t.
Hope this can help you
Best Regards
Dionisis
"Ron Broere" <ronbroere@bbkm.nl> wrote in message
news:4a54636a$[email=1@svctag-j7w3v3j....]1@svctag-j7w3v3j....[/email]
> 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
>
>
To keep your function simple add a third parameter
something like this :
STATIC FUNCTION DIR_RECURS( cPath, cMask,oForm)
If your form is the main application form you can have access on it simply
call Application:oMainForm:anyObjectInstance or
passing self as third parameter.
now in your function you need to do something like this
> oForm:oLabel3:lVisible := .t.
Hope this can help you
Best Regards
Dionisis
"Ron Broere" <ronbroere@bbkm.nl> wrote in message
news:4a54636a$[email=1@svctag-j7w3v3j....]1@svctag-j7w3v3j....[/email]
> 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
>
>
-
- Mensajes: 44
- Registrado: Dom Abr 19, 2009 10:01 am
access objects from a function
thank you! perfect.
"Dionisis Divaris" <info@sgs-soft.gr> wrote in message
news:[email=4a5466e9@svctag-j7w3v3j....]4a5466e9@svctag-j7w3v3j....[/email]
> Hello Ron
>
> To keep your function simple add a third parameter
> something like this :
> STATIC FUNCTION DIR_RECURS( cPath, cMask,oForm)
>
> If your form is the main application form you can have access on it
> simply call Application:oMainForm:anyObjectInstance or
> passing self as third parameter.
> now in your function you need to do something like this
>> oForm:oLabel3:lVisible := .t.
>
> Hope this can help you
> Best Regards
> Dionisis
>
> "Ron Broere" <ronbroere@bbkm.nl> wrote in message
> news:4a54636a$[email=1@svctag-j7w3v3j....]1@svctag-j7w3v3j....[/email]
>> 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
>>
>>
>
>
"Dionisis Divaris" <info@sgs-soft.gr> wrote in message
news:[email=4a5466e9@svctag-j7w3v3j....]4a5466e9@svctag-j7w3v3j....[/email]
> Hello Ron
>
> To keep your function simple add a third parameter
> something like this :
> STATIC FUNCTION DIR_RECURS( cPath, cMask,oForm)
>
> If your form is the main application form you can have access on it
> simply call Application:oMainForm:anyObjectInstance or
> passing self as third parameter.
> now in your function you need to do something like this
>> oForm:oLabel3:lVisible := .t.
>
> Hope this can help you
> Best Regards
> Dionisis
>
> "Ron Broere" <ronbroere@bbkm.nl> wrote in message
> news:4a54636a$[email=1@svctag-j7w3v3j....]1@svctag-j7w3v3j....[/email]
>> 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
>>
>>
>
>
-
- Mensajes: 44
- Registrado: Dom Abr 19, 2009 10:01 am
access objects from a function
thank you! perfect.
"Dionisis Divaris" <info@sgs-soft.gr> wrote in message
news:[email=4a5466e9@svctag-j7w3v3j....]4a5466e9@svctag-j7w3v3j....[/email]
> Hello Ron
>
> To keep your function simple add a third parameter
> something like this :
> STATIC FUNCTION DIR_RECURS( cPath, cMask,oForm)
>
> If your form is the main application form you can have access on it
> simply call Application:oMainForm:anyObjectInstance or
> passing self as third parameter.
> now in your function you need to do something like this
>> oForm:oLabel3:lVisible := .t.
>
> Hope this can help you
> Best Regards
> Dionisis
>
> "Ron Broere" <ronbroere@bbkm.nl> wrote in message
> news:4a54636a$[email=1@svctag-j7w3v3j....]1@svctag-j7w3v3j....[/email]
>> 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
>>
>>
>
>
"Dionisis Divaris" <info@sgs-soft.gr> wrote in message
news:[email=4a5466e9@svctag-j7w3v3j....]4a5466e9@svctag-j7w3v3j....[/email]
> Hello Ron
>
> To keep your function simple add a third parameter
> something like this :
> STATIC FUNCTION DIR_RECURS( cPath, cMask,oForm)
>
> If your form is the main application form you can have access on it
> simply call Application:oMainForm:anyObjectInstance or
> passing self as third parameter.
> now in your function you need to do something like this
>> oForm:oLabel3:lVisible := .t.
>
> Hope this can help you
> Best Regards
> Dionisis
>
> "Ron Broere" <ronbroere@bbkm.nl> wrote in message
> news:4a54636a$[email=1@svctag-j7w3v3j....]1@svctag-j7w3v3j....[/email]
>> 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
>>
>>
>
>