i have a funny Problem : i "lost" a Variable after Second Call ?
it work twice, but when call 3rd, Time i got "Error BASE/1003 Variable does not exist: DFROM" ???
STATIC PROCEDURE DoSetFilterRange( nZEIT )
LOCAL lUse := USED()
LOCAL bError := ERRORBLOCK( { | oErr | BREAK( oErr ) } )
LOCAL oError
BEGIN SEQUENCE
SET FILTER TO
BLPRESS.Text_Min.ReadOnly := .F.
BLPRESS.Text_Max.ReadOnly := .F.
IF SP_DTO() >= SP_DFROM()
DO CASE
CASE nZEIT = 3
SET FILTER TO BLPRESS->PDATE >= SP_DFROM() .AND. ;
BLPRESS->PDATE <= SP_DTO()
CASE nZEIT = 2
Jimmy, your first program may have worked with PRIVATE variables for dates instead of local.
They stay active until you close the function/procedure that you create them in. Not sure about static procedure, have never used them.
Jimmy, private variables stay active until you release calling program. Local are not available to any procedures called from
procedure making them.
Build this below. you will see how it works. in procedure checkvar variable "B" is known but "A" will crash as it was local only
to first Procedure or Function.
franco wrote: ↑Thu Jan 01, 2026 5:39 pm
Build this below. you will see how it works. in procedure checkvar variable "B" is known but "A" will crash as it was local only to first Procedure or Function.
THX, i know this
as you can see i pass LOCAL as Parameter and i also declare DEFAULT TO so i don´t understand why a Error of "unkown DFROM" can exist ?!
p.s. i do not like using PRIVATE, because it becomes confusing with large programs containing many lines of CODE.
Using FUNCTION instead of PRIVATE/PUBLIC, together with a documenter like CLICK, you get an overview of WHERE the variables are called up.
Every time you go to a different function or procedure you will have to pass the parameter.
I use this all the time in very large programs, but never from a main type function. these functions get closed fairly quickly.
If I need variables for throughout the program I make them public. I also have a large control file that if I need to store variables
I have a field for them in there and can change them when needed.
I guess it depends on what you get used to doing..... We all have own ways.