Hello All,

I have the following code for an dataenvironment for a report.
The last line("this.cursor1.filter...) in the IF statement doesn't
work unless I have the variables as PUBLIC. The variables contain
valid dates. Could I do this any other way?

Thanks
Dave

DEFINE CLASS dteInspectionHoursReport as dteDataEnvironment

initialselectedalias = "vr0002"

ADD OBJECT cursor1 as cursor WITH ;
alias = "vr0002", ;
cursorsource = "vr0002", ;
database = "main.dbc"

PROCEDURE Init()
DODEFAULT()
LOCAL loDateRange as Object, ldStartDate as Date, ;
ldEndDate as Date
LOCAL ARRAY laDate[2]

laDate[1] = DATE() - 30
laDate[2] = DATE()

loDateRange = CREATEOBJECT("_daterange",@laDate)
loDateRange.Show(1)

IF TYPE("loDateRange") = "O" AND !ISNULL(loDateRange)
ldStartDate = loDateRange.dStartDate
ldEndDate = loDateRange.dEndDate

this.cursor1.filter =
"BETWEEN(dinspectionact,ldStartDate,ldEndDate)"
ENDIF

ENDPROC

ENDDEFINE

Re: dataenvironment class code by Jack

Jack
Thu Mar 30 23:08:10 CST 2006

On Thu, 30 Mar 2006 19:52:59 -0500, Dave <scialabba2@comcast.net>
wrote:

>Hello All,
>
>I have the following code for an dataenvironment for a report.
>The last line("this.cursor1.filter...) in the IF statement doesn't
>work unless I have the variables as PUBLIC. The variables contain
>valid dates. Could I do this any other way?
>
>Thanks
>Dave
>
>DEFINE CLASS dteInspectionHoursReport as dteDataEnvironment
>
> initialselectedalias = "vr0002"
>
> ADD OBJECT cursor1 as cursor WITH ;
> alias = "vr0002", ;
> cursorsource = "vr0002", ;
> database = "main.dbc"
>
> PROCEDURE Init()
> DODEFAULT()
> LOCAL loDateRange as Object, ldStartDate as Date, ;
> ldEndDate as Date
> LOCAL ARRAY laDate[2]
>
> laDate[1] = DATE() - 30
> laDate[2] = DATE()
>
> loDateRange = CREATEOBJECT("_daterange",@laDate)
> loDateRange.Show(1)
>
> IF TYPE("loDateRange") = "O" AND !ISNULL(loDateRange)
> ldStartDate = loDateRange.dStartDate
> ldEndDate = loDateRange.dEndDate
>
> this.cursor1.filter =
>"BETWEEN(dinspectionact,ldStartDate,ldEndDate)"
> ENDIF
>
> ENDPROC
>
>ENDDEFINE

I haven't tried this, but something like this should work.

Assuming that you the start and end dates don't change after this code
runs, you need to put date constants in the filter. The easy way is
to put a CTOD in the filter. The more efficient way, to avoid
executing two CTOD functions each time the filter is evaluated, is to
use a date constant, but it is more work to generate a constant.

this.cursor1.filter = ;
"BETWEEN(dinspectionact,CTOD('" +DTOC(ldStartDate) + ;
"'),CTOD('" + DTOC(ldEndDate) + "'))"

Re: dataenvironment class code by Dan

Dan
Fri Mar 31 10:37:57 CST 2006

Probably doesn't exactly work if they're PUBLIC. Just doesn't error because
they're in scope.

You're declaring those variables LOCAL to the init, which means those values
are local copies that disappear when the init method ends.

If you're going to use values that are scoped to the life of the form, they
should be Form properties. (Form menu -> New Property)

Dan

Dave wrote:
> Hello All,
>
> I have the following code for an dataenvironment for a report.
> The last line("this.cursor1.filter...) in the IF statement doesn't
> work unless I have the variables as PUBLIC. The variables contain
> valid dates. Could I do this any other way?
>
> Thanks
> Dave
>
> DEFINE CLASS dteInspectionHoursReport as dteDataEnvironment
>
> initialselectedalias = "vr0002"
>
> ADD OBJECT cursor1 as cursor WITH ;
> alias = "vr0002", ;
> cursorsource = "vr0002", ;
> database = "main.dbc"
>
> PROCEDURE Init()
> DODEFAULT()
> LOCAL loDateRange as Object, ldStartDate as Date, ;
> ldEndDate as Date
> LOCAL ARRAY laDate[2]
>
> laDate[1] = DATE() - 30
> laDate[2] = DATE()
>
> loDateRange = CREATEOBJECT("_daterange",@laDate)
> loDateRange.Show(1)
>
> IF TYPE("loDateRange") = "O" AND !ISNULL(loDateRange)
> ldStartDate = loDateRange.dStartDate
> ldEndDate = loDateRange.dEndDate
>
> this.cursor1.filter =
> "BETWEEN(dinspectionact,ldStartDate,ldEndDate)"
> ENDIF
>
> ENDPROC
>
> ENDDEFINE



Re: dataenvironment class code by Dave

Dave
Fri Mar 31 10:50:16 CST 2006

Thanks, I'll give this a try. I would also be interested in using the
constant idea, but the value of the dates are not know at the start of the
init method, can it be done?

"Jack Jackson" wrote:

> On Thu, 30 Mar 2006 19:52:59 -0500, Dave <scialabba2@comcast.net>
> wrote:
>
> >Hello All,
> >
> >I have the following code for an dataenvironment for a report.
> >The last line("this.cursor1.filter...) in the IF statement doesn't
> >work unless I have the variables as PUBLIC. The variables contain
> >valid dates. Could I do this any other way?
> >
> >Thanks
> >Dave
> >
> >DEFINE CLASS dteInspectionHoursReport as dteDataEnvironment
> >
> > initialselectedalias = "vr0002"
> >
> > ADD OBJECT cursor1 as cursor WITH ;
> > alias = "vr0002", ;
> > cursorsource = "vr0002", ;
> > database = "main.dbc"
> >
> > PROCEDURE Init()
> > DODEFAULT()
> > LOCAL loDateRange as Object, ldStartDate as Date, ;
> > ldEndDate as Date
> > LOCAL ARRAY laDate[2]
> >
> > laDate[1] = DATE() - 30
> > laDate[2] = DATE()
> >
> > loDateRange = CREATEOBJECT("_daterange",@laDate)
> > loDateRange.Show(1)
> >
> > IF TYPE("loDateRange") = "O" AND !ISNULL(loDateRange)
> > ldStartDate = loDateRange.dStartDate
> > ldEndDate = loDateRange.dEndDate
> >
> > this.cursor1.filter =
> >"BETWEEN(dinspectionact,ldStartDate,ldEndDate)"
> > ENDIF
> >
> > ENDPROC
> >
> >ENDDEFINE
>
> I haven't tried this, but something like this should work.
>
> Assuming that you the start and end dates don't change after this code
> runs, you need to put date constants in the filter. The easy way is
> to put a CTOD in the filter. The more efficient way, to avoid
> executing two CTOD functions each time the filter is evaluated, is to
> use a date constant, but it is more work to generate a constant.
>
> this.cursor1.filter = ;
> "BETWEEN(dinspectionact,CTOD('" +DTOC(ldStartDate) + ;
> "'),CTOD('" + DTOC(ldEndDate) + "'))"
>

Re: dataenvironment class code by Jack

Jack
Fri Mar 31 11:23:26 CST 2006

You need to generate constants from the values you have. Something
like:

cStr = "{^" + TRANSFORM(YEAR(ldStartDate)) + "-" +
TRANSFORM(MONTH(ldStartDate)) + "-" + TRANSFROM(DAY(ldStartDate)) +
"}"

On Fri, 31 Mar 2006 08:50:16 -0800, Dave
<Dave@discussions.microsoft.com> wrote:

>Thanks, I'll give this a try. I would also be interested in using the
>constant idea, but the value of the dates are not know at the start of the
>init method, can it be done?
>
>"Jack Jackson" wrote:
>
>> On Thu, 30 Mar 2006 19:52:59 -0500, Dave <scialabba2@comcast.net>
>> wrote:
>>
>> >Hello All,
>> >
>> >I have the following code for an dataenvironment for a report.
>> >The last line("this.cursor1.filter...) in the IF statement doesn't
>> >work unless I have the variables as PUBLIC. The variables contain
>> >valid dates. Could I do this any other way?
>> >
>> >Thanks
>> >Dave
>> >
>> >DEFINE CLASS dteInspectionHoursReport as dteDataEnvironment
>> >
>> > initialselectedalias = "vr0002"
>> >
>> > ADD OBJECT cursor1 as cursor WITH ;
>> > alias = "vr0002", ;
>> > cursorsource = "vr0002", ;
>> > database = "main.dbc"
>> >
>> > PROCEDURE Init()
>> > DODEFAULT()
>> > LOCAL loDateRange as Object, ldStartDate as Date, ;
>> > ldEndDate as Date
>> > LOCAL ARRAY laDate[2]
>> >
>> > laDate[1] = DATE() - 30
>> > laDate[2] = DATE()
>> >
>> > loDateRange = CREATEOBJECT("_daterange",@laDate)
>> > loDateRange.Show(1)
>> >
>> > IF TYPE("loDateRange") = "O" AND !ISNULL(loDateRange)
>> > ldStartDate = loDateRange.dStartDate
>> > ldEndDate = loDateRange.dEndDate
>> >
>> > this.cursor1.filter =
>> >"BETWEEN(dinspectionact,ldStartDate,ldEndDate)"
>> > ENDIF
>> >
>> > ENDPROC
>> >
>> >ENDDEFINE
>>
>> I haven't tried this, but something like this should work.
>>
>> Assuming that you the start and end dates don't change after this code
>> runs, you need to put date constants in the filter. The easy way is
>> to put a CTOD in the filter. The more efficient way, to avoid
>> executing two CTOD functions each time the filter is evaluated, is to
>> use a date constant, but it is more work to generate a constant.
>>
>> this.cursor1.filter = ;
>> "BETWEEN(dinspectionact,CTOD('" +DTOC(ldStartDate) + ;
>> "'),CTOD('" + DTOC(ldEndDate) + "'))"
>>

Re: dataenvironment class code by Dave

Dave
Sat Apr 01 08:17:48 CST 2006

Dan, I actually tried using properties but I couldn't get the filter
expression to work This is what I used.

this.cursor1.filter = "BETWEEN(dinspectionact, this.dStartDate,
this.dEndDate)

The properties did contain valid dates so it makes me think the filter
expression was wrong.

Right now I'm using Jack's solution (thank-you), but I think using
properties would be the way to go.


Dave



On Fri, 31 Mar 2006 08:37:57 -0800, "Dan Freeman" <spam@microsoft.com>
wrote:

>Probably doesn't exactly work if they're PUBLIC. Just doesn't error because
>they're in scope.
>
>You're declaring those variables LOCAL to the init, which means those values
>are local copies that disappear when the init method ends.
>
>If you're going to use values that are scoped to the life of the form, they
>should be Form properties. (Form menu -> New Property)
>
>Dan
>
>Dave wrote:
>> Hello All,
>>
>> I have the following code for an dataenvironment for a report.
>> The last line("this.cursor1.filter...) in the IF statement doesn't
>> work unless I have the variables as PUBLIC. The variables contain
>> valid dates. Could I do this any other way?
>>
>> Thanks
>> Dave
>>
>> DEFINE CLASS dteInspectionHoursReport as dteDataEnvironment
>>
>> initialselectedalias = "vr0002"
>>
>> ADD OBJECT cursor1 as cursor WITH ;
>> alias = "vr0002", ;
>> cursorsource = "vr0002", ;
>> database = "main.dbc"
>>
>> PROCEDURE Init()
>> DODEFAULT()
>> LOCAL loDateRange as Object, ldStartDate as Date, ;
>> ldEndDate as Date
>> LOCAL ARRAY laDate[2]
>>
>> laDate[1] = DATE() - 30
>> laDate[2] = DATE()
>>
>> loDateRange = CREATEOBJECT("_daterange",@laDate)
>> loDateRange.Show(1)
>>
>> IF TYPE("loDateRange") = "O" AND !ISNULL(loDateRange)
>> ldStartDate = loDateRange.dStartDate
>> ldEndDate = loDateRange.dEndDate
>>
>> this.cursor1.filter =
>> "BETWEEN(dinspectionact,ldStartDate,ldEndDate)"
>> ENDIF
>>
>> ENDPROC
>>
>> ENDDEFINE
>


Re: dataenvironment class code by Jack

Jack
Sat Apr 01 12:49:24 CST 2006

You can't use "this". The filter expression gets evaluated every time
the record pointer of the table changes, and whatever you have in the
filter expression must be able to be evaluated when that happens.

"this" refers to the current object, which will not be your class.

"thisform" may work, but I'm not sure exactly what environment the
filter expression gets evaluated in.

On Sat, 01 Apr 2006 09:17:48 -0500, Dave <scialabba2@comcast.net>
wrote:

>Dan, I actually tried using properties but I couldn't get the filter
>expression to work This is what I used.
>
>this.cursor1.filter = "BETWEEN(dinspectionact, this.dStartDate,
>this.dEndDate)
>
>The properties did contain valid dates so it makes me think the filter
>expression was wrong.
>
>Right now I'm using Jack's solution (thank-you), but I think using
>properties would be the way to go.
>
>
>Dave
>
>
>
>On Fri, 31 Mar 2006 08:37:57 -0800, "Dan Freeman" <spam@microsoft.com>
>wrote:
>
>>Probably doesn't exactly work if they're PUBLIC. Just doesn't error because
>>they're in scope.
>>
>>You're declaring those variables LOCAL to the init, which means those values
>>are local copies that disappear when the init method ends.
>>
>>If you're going to use values that are scoped to the life of the form, they
>>should be Form properties. (Form menu -> New Property)
>>
>>Dan
>>
>>Dave wrote:
>>> Hello All,
>>>
>>> I have the following code for an dataenvironment for a report.
>>> The last line("this.cursor1.filter...) in the IF statement doesn't
>>> work unless I have the variables as PUBLIC. The variables contain
>>> valid dates. Could I do this any other way?
>>>
>>> Thanks
>>> Dave
>>>
>>> DEFINE CLASS dteInspectionHoursReport as dteDataEnvironment
>>>
>>> initialselectedalias = "vr0002"
>>>
>>> ADD OBJECT cursor1 as cursor WITH ;
>>> alias = "vr0002", ;
>>> cursorsource = "vr0002", ;
>>> database = "main.dbc"
>>>
>>> PROCEDURE Init()
>>> DODEFAULT()
>>> LOCAL loDateRange as Object, ldStartDate as Date, ;
>>> ldEndDate as Date
>>> LOCAL ARRAY laDate[2]
>>>
>>> laDate[1] = DATE() - 30
>>> laDate[2] = DATE()
>>>
>>> loDateRange = CREATEOBJECT("_daterange",@laDate)
>>> loDateRange.Show(1)
>>>
>>> IF TYPE("loDateRange") = "O" AND !ISNULL(loDateRange)
>>> ldStartDate = loDateRange.dStartDate
>>> ldEndDate = loDateRange.dEndDate
>>>
>>> this.cursor1.filter =
>>> "BETWEEN(dinspectionact,ldStartDate,ldEndDate)"
>>> ENDIF
>>>
>>> ENDPROC
>>>
>>> ENDDEFINE
>>

Re: dataenvironment class code by Dave

Dave
Mon Apr 03 18:53:20 CDT 2006

Thanks, I tried using the object name also (just really trying
anything) but no luck. Your first suggesting is working just fine, and
seems to be quit fast.

Dave

On Sat, 01 Apr 2006 10:49:24 -0800, Jack Jackson
<jacknospam@pebbleridge.com> wrote:

>You can't use "this". The filter expression gets evaluated every time
>the record pointer of the table changes, and whatever you have in the
>filter expression must be able to be evaluated when that happens.
>
>"this" refers to the current object, which will not be your class.
>
>"thisform" may work, but I'm not sure exactly what environment the
>filter expression gets evaluated in.
>
>On Sat, 01 Apr 2006 09:17:48 -0500, Dave <scialabba2@comcast.net>
>wrote:
>
>>Dan, I actually tried using properties but I couldn't get the filter
>>expression to work This is what I used.
>>
>>this.cursor1.filter = "BETWEEN(dinspectionact, this.dStartDate,
>>this.dEndDate)
>>
>>The properties did contain valid dates so it makes me think the filter
>>expression was wrong.
>>
>>Right now I'm using Jack's solution (thank-you), but I think using
>>properties would be the way to go.
>>
>>
>>Dave
>>
>>
>>
>>On Fri, 31 Mar 2006 08:37:57 -0800, "Dan Freeman" <spam@microsoft.com>
>>wrote:
>>
>>>Probably doesn't exactly work if they're PUBLIC. Just doesn't error because
>>>they're in scope.
>>>
>>>You're declaring those variables LOCAL to the init, which means those values
>>>are local copies that disappear when the init method ends.
>>>
>>>If you're going to use values that are scoped to the life of the form, they
>>>should be Form properties. (Form menu -> New Property)
>>>
>>>Dan
>>>
>>>Dave wrote:
>>>> Hello All,
>>>>
>>>> I have the following code for an dataenvironment for a report.
>>>> The last line("this.cursor1.filter...) in the IF statement doesn't
>>>> work unless I have the variables as PUBLIC. The variables contain
>>>> valid dates. Could I do this any other way?
>>>>
>>>> Thanks
>>>> Dave
>>>>
>>>> DEFINE CLASS dteInspectionHoursReport as dteDataEnvironment
>>>>
>>>> initialselectedalias = "vr0002"
>>>>
>>>> ADD OBJECT cursor1 as cursor WITH ;
>>>> alias = "vr0002", ;
>>>> cursorsource = "vr0002", ;
>>>> database = "main.dbc"
>>>>
>>>> PROCEDURE Init()
>>>> DODEFAULT()
>>>> LOCAL loDateRange as Object, ldStartDate as Date, ;
>>>> ldEndDate as Date
>>>> LOCAL ARRAY laDate[2]
>>>>
>>>> laDate[1] = DATE() - 30
>>>> laDate[2] = DATE()
>>>>
>>>> loDateRange = CREATEOBJECT("_daterange",@laDate)
>>>> loDateRange.Show(1)
>>>>
>>>> IF TYPE("loDateRange") = "O" AND !ISNULL(loDateRange)
>>>> ldStartDate = loDateRange.dStartDate
>>>> ldEndDate = loDateRange.dEndDate
>>>>
>>>> this.cursor1.filter =
>>>> "BETWEEN(dinspectionact,ldStartDate,ldEndDate)"
>>>> ENDIF
>>>>
>>>> ENDPROC
>>>>
>>>> ENDDEFINE
>>>