Hello,

I have a situation where in VFP8 I build the app. and run
a form and the click event code of the cancel button does
the following:

SELECT classes
SET DELETED off
SET EXCLUSIVE on
browse
DELETE
browse
PACK
browse

SELECT ids
replace ids.nextid WITH lnId
thisform.release

When run from the app I see that the delete marks the
record and the browse after the PACK still shows the
record as just deleted. When I open the project and just
run the form everything works as expected.

I have tried everything I can think of to no avail. Can
someone please give me a clue? Thanks in advance...

Rich

Re: Pack not working by Willianto

Willianto
Wed Nov 05 14:39:50 CST 2003

Rich:

SWAG: do you have any ON ERROR command? Looks like VFP couldn't open the
file exclusively, and the PACK command failed to run. AFAIK, VFP
should've genereted an error message by then.
By the way, taking a step back, I wonder why you PACK right after you
DELETE a recor? PACK command can be costly if you have large tables. If
you did this because the deleted records keep on showing, maybe you
benefit from my discussion with Igor on this ng:

/start
Hi, Willianto!
You wrote on Sat, 11 Jan 2003 12:55:25 +0700:

> Hi Igor,

>> No!!! It must be in DE.BeforeOpenTables(), as tables and views
>> mentioned
> in
>> form's DE opened prior to form's Load event fired.

> You're right about the DE opened prior to form's load event (I refer
to
> VFP help under 'Tracking Event Sequences' topic). Based on Nancy's and
> your reply, I did a quick test and here is what I found:
> ---------------------------------------------------------
> Location of | Deleted records | Deleted records
> SET DELETED ON | (on view) | (on table)
> ---------------------------------------------------------
> Init Event | SHOWED | SHOWED
> Load Event | SHOWED | NOT SHOWED
> DE.BeforeOpenTables | NOT SHOWED | NOT SHOWED
> ---------------------------------------------------------

> Notes: the view and the table are in the DE.

First of all, SET DELETED ON will work for tables even from
SomeButton.Click
() code, you only have to jerk record pointer (simply GO RECNO() may
help)
and refresh the form - and filter "on deleted" will be in effect (note -
you
can do it for views with REQUERY(), but it will be inefficient to pull
the
data twice).

> Not until now I realized the importance of ability to subclassed the
DE!
> I'm glad VFP8 is on the way. Unfortunately, I cannot use that feature
> now because this project will have to be compiled under VFP7SP1.

You may use one interesting feature (or maybe bug, but it work OK for
me, so
I don't bother on its "legality"). I call it "base class subclassing"
just
run this program, and then try to run any form to see how it works:

PUBLIC oDEHook
m.oDEHook = CREATEOBJECT ("DEHook")

DEFINE CLASS DEHook AS DataEnvironment
Name = "DataEnvironment"

PROCEDURE BeforeOpenTables
SET DELETED ON
MESSAGEBOX ("Now pseudo-base class code is executed")
ENDPROC

ENDDEFINE

Note that the main thing here is line Name = "DataEnvironment"

To remove this pseudo-base class you have to use
m.oDEHook = .F.
CLEAR CLASS DataEnvironment

Also note that if you will have any code in DE.BeforeOpenTables() event
for
some form, you have to include DODEFAULT () function call there to
execute
new "built-in" code.

P.S. I use this technique now (also VFP7SP1) for several purposes, and
one
of them is well-known problem in pathing - fox store path info for any
Cursor objects in DE and so it can use data from some wrong place. With
this
approach you don't need to setup AutoOpen = .F., then change
Cursor.Database
= "\\correct\path\to\database.dbc" or Cursor.CursorSource =
"\\correct\path\to\free\table.dbf" in FORM.Load event and at last call
DE.OpenTables() method...

WBR, Igor
/end

hth,
Willianto



Re: Pack not working by Dan

Dan
Wed Nov 05 15:34:07 CST 2003

FWIW, your SET EXCLUSIVE ON here will do nothing for you. It will have no
effect on an already-open table.

Dan

"Rich" <anonymous@discussions.microsoft.com> wrote in message
news:057f01c3a3d9$cd7c9330$a101280a@phx.gbl...
> Hello,
>
> I have a situation where in VFP8 I build the app. and run
> a form and the click event code of the cancel button does
> the following:
>
> SELECT classes
> SET DELETED off
> SET EXCLUSIVE on
> browse
> DELETE
> browse
> PACK
> browse
>
> SELECT ids
> replace ids.nextid WITH lnId
> thisform.release
>
> When run from the app I see that the delete marks the
> record and the browse after the PACK still shows the
> record as just deleted. When I open the project and just
> run the form everything works as expected.
>
> I have tried everything I can think of to no avail. Can
> someone please give me a clue? Thanks in advance...
>
> Rich



Re: Pack not working by trw7at

trw7at
Thu Nov 06 11:37:04 CST 2003

Dan nailed it. SET EXCLUSIVE only affects tables opened
*after* it has been turned on. To pack a table already
opened SHARED:

SELECT myTable
USE
USE myTable IN 0 EXCLUSIVE
PACK
USE
USE myTable in 0 SHARED

-- TRW

Rich seemed to utter in news:057f01c3a3d9$cd7c9330$a101280a@phx.gbl:

> Hello,
>
> I have a situation where in VFP8 I build the app. and run
> a form and the click event code of the cancel button does
> the following:
>
> SELECT classes
> SET DELETED off
> SET EXCLUSIVE on
> browse
> DELETE
> browse
> PACK
> browse
>
> SELECT ids
> replace ids.nextid WITH lnId
> thisform.release
>
> When run from the app I see that the delete marks the
> record and the browse after the PACK still shows the
> record as just deleted. When I open the project and just
> run the form everything works as expected.
>
> I have tried everything I can think of to no avail. Can
> someone please give me a clue? Thanks in advance...
>
> Rich



--
_______________________________________
My e-mail: t r w 7
@ i x . n e t c o m . c o m
_______________________________________

Re: Pack not working by Paul

Paul
Thu Nov 06 14:01:15 CST 2003

Don't include the "IN 0" in those statements. That will open the table in
the lowest available work area, which might not be the current one. This is
better:

SELECT myTable
USE myTable EXCLUSIVE
* Have some error handling here in case the table cannot be opened
exclusively.
PACK
USE myTable SHARED





"Tim Witort" <trw7at@ixdot.netcomdotcom> wrote in message
news:Xns942B61DC9475Ftimwitortwrotethis@207.217.77.201...
> Dan nailed it. SET EXCLUSIVE only affects tables opened
> *after* it has been turned on. To pack a table already
> opened SHARED:
>
> SELECT myTable
> USE
> USE myTable IN 0 EXCLUSIVE
> PACK
> USE
> USE myTable in 0 SHARED
>
> -- TRW
>
> Rich seemed to utter in news:057f01c3a3d9$cd7c9330$a101280a@phx.gbl:
>
> > Hello,
> >
> > I have a situation where in VFP8 I build the app. and run
> > a form and the click event code of the cancel button does
> > the following:
> >
> > SELECT classes
> > SET DELETED off
> > SET EXCLUSIVE on
> > browse
> > DELETE
> > browse
> > PACK
> > browse
> >
> > SELECT ids
> > replace ids.nextid WITH lnId
> > thisform.release
> >
> > When run from the app I see that the delete marks the
> > record and the browse after the PACK still shows the
> > record as just deleted. When I open the project and just
> > run the form everything works as expected.
> >
> > I have tried everything I can think of to no avail. Can
> > someone please give me a clue? Thanks in advance...
> >
> > Rich
>
>
>
> --
> _______________________________________
> My e-mail: t r w 7
> @ i x . n e t c o m . c o m
> _______________________________________



Re: Pack not working by trw7at

trw7at
Fri Nov 07 11:09:43 CST 2003

When I first saw your code I was sure that the USE
statements would raise an error #3 (file in use).
I was surprised that VFP doesn't complain about these
USE statements. Learn something new every day.
Good one, Paul.

-- TRW

Paul Pedersen seemed to utter in
news:uwks9CKpDHA.976@tk2msftngp13.phx.gbl:

> Don't include the "IN 0" in those statements. That will open the table
> in the lowest available work area, which might not be the current one.
> This is better:
>
> SELECT myTable
> USE myTable EXCLUSIVE
> * Have some error handling here in case the table cannot be opened
> exclusively.
> PACK
> USE myTable SHARED
>
>
>
>
>
> "Tim Witort" <trw7at@ixdot.netcomdotcom> wrote in message
> news:Xns942B61DC9475Ftimwitortwrotethis@207.217.77.201...
>> Dan nailed it. SET EXCLUSIVE only affects tables opened
>> *after* it has been turned on. To pack a table already
>> opened SHARED:
>>
>> SELECT myTable
>> USE
>> USE myTable IN 0 EXCLUSIVE
>> PACK
>> USE
>> USE myTable in 0 SHARED
>>
>> -- TRW
>>
>> Rich seemed to utter in news:057f01c3a3d9$cd7c9330$a101280a@phx.gbl:
>>
>> > Hello,
>> >
>> > I have a situation where in VFP8 I build the app. and run
>> > a form and the click event code of the cancel button does
>> > the following:
>> >
>> > SELECT classes
>> > SET DELETED off
>> > SET EXCLUSIVE on
>> > browse
>> > DELETE
>> > browse
>> > PACK
>> > browse
>> >
>> > SELECT ids
>> > replace ids.nextid WITH lnId
>> > thisform.release
>> >
>> > When run from the app I see that the delete marks the
>> > record and the browse after the PACK still shows the
>> > record as just deleted. When I open the project and just
>> > run the form everything works as expected.
>> >
>> > I have tried everything I can think of to no avail. Can
>> > someone please give me a clue? Thanks in advance...
>> >
>> > Rich
>>
>>
>>
>> --
>> _______________________________________
>> My e-mail: t r w 7
>> @ i x . n e t c o m . c o m
>> _______________________________________
>
>
>



--
_______________________________________
My e-mail: t r w 7
@ i x . n e t c o m . c o m
_______________________________________

Re: Pack not working by Willianto

Willianto
Fri Nov 07 13:09:18 CST 2003

> FWIW, your SET EXCLUSIVE ON here will do nothing for you. It will
> have no effect on an already-open table.
I should've known that! :-(

Willianto