Hi
I have a problem in foxpro 2.6. I have 2 Fields in a screen. The first field
is alphanumeric and the second is a date field. In field1-Valid() I check
that field1 is empty and if so field2 will be disabled. When the program runs
and field1 is empty it works to use the tabulator to leave field1. What
happens is that field 2 is disabled and the control is forwarded to the next
object in the screen.
My problem is if I use the mousepointer to click in field2. Then, field2 is
disabled but the program aborts without any messages. I have tried different
solutions for example to add code in the When() clause for field2 that
determines that field1 is empty and gives control to another object in the
screen. But it won't work.

If anyone knows how to get around please send a response.

Best regards /G

Re: foxpro 2.6 Fields - disabled fields makes software to abort by Andrew

Andrew
Thu Oct 21 08:55:43 CDT 2004

Gunnar wrote:
> Hi
> I have a problem in foxpro 2.6. I have 2 Fields in a screen. The
> first field is alphanumeric and the second is a date field. In
> field1-Valid() I check that field1 is empty and if so field2 will be
> disabled. When the program runs and field1 is empty it works to use
> the tabulator to leave field1. What happens is that field 2 is
> disabled and the control is forwarded to the next object in the
> screen.
> My problem is if I use the mousepointer to click in field2. Then,
> field2 is disabled but the program aborts without any messages. I
> have tried different solutions for example to add code in the When()
> clause for field2 that determines that field1 is empty and gives
> control to another object in the screen. But it won't work.

FPW isn't always terribly great when you have a load of code in a valid and
you use the mouse to exit the field.

If (for example) you place a =MSGBOX call in the valid snippet for a field
and then use the mouse to select another field, the msgbox shows but it
leaves the focus on the field you clicked but the mouse works as if the left
mouse button is held down until you click it.


Anyway. I replicated the situation you describe above and traced it; the
READ is being terminated. If you're happy about using the WHEN clause (it
leaves a bad visual hint in that the control looks available but the user
cannot select it) then I think you can workaround quite neatly like so:

Make the WHEN for field2 an expression, and give it the value
"!EMPTY(m.field1)"


Alternatively, maybe it is possible to check the "initially disable"
checkbox for your field2 and then in field1 valid place
IF !EMPTY(m.field1)
SHOW GET m.field2 ENABLE
ENDIF

But this will still trip up if the user "fiddles around" filling/emptying
the field and using the mouse to navigate. You also need to disable it again
when moving to a different record or saving (or whatever that screen does..)

--
HTH
Andrew Howell




Re: foxpro 2.6 Fields - disabled fields makes software to abort by G

G
Fri Oct 22 06:59:04 CDT 2004

Hi Andrew
Thanks for your answer. I tried to use an expression in WHEN as you said,
but didn't work. =(
I also tried to make a procedure in the WHEN for field2 where I create a
file with fcreate() but it won't work either. When I enter the field2 when it
is enabled the file is created. So for me it appears that the WHEN 'event'
doesn't run in my case. That is when I click with the mouse from the empty
field1 into field2. As I described in the first mail, when I move from field1
to field2 then field2 is disabled.

I'm not sure there is a way around this case...?

/Gunnar


"Andrew Howell" wrote:

> Gunnar wrote:
> > Hi
> > I have a problem in foxpro 2.6. I have 2 Fields in a screen. The
> > first field is alphanumeric and the second is a date field. In
> > field1-Valid() I check that field1 is empty and if so field2 will be
> > disabled. When the program runs and field1 is empty it works to use
> > the tabulator to leave field1. What happens is that field 2 is
> > disabled and the control is forwarded to the next object in the
> > screen.
> > My problem is if I use the mousepointer to click in field2. Then,
> > field2 is disabled but the program aborts without any messages. I
> > have tried different solutions for example to add code in the When()
> > clause for field2 that determines that field1 is empty and gives
> > control to another object in the screen. But it won't work.
>
> FPW isn't always terribly great when you have a load of code in a valid and
> you use the mouse to exit the field.
>
> If (for example) you place a =MSGBOX call in the valid snippet for a field
> and then use the mouse to select another field, the msgbox shows but it
> leaves the focus on the field you clicked but the mouse works as if the left
> mouse button is held down until you click it.
>
>
> Anyway. I replicated the situation you describe above and traced it; the
> READ is being terminated. If you're happy about using the WHEN clause (it
> leaves a bad visual hint in that the control looks available but the user
> cannot select it) then I think you can workaround quite neatly like so:
>
> Make the WHEN for field2 an expression, and give it the value
> "!EMPTY(m.field1)"
>
>
> Alternatively, maybe it is possible to check the "initially disable"
> checkbox for your field2 and then in field1 valid place
> IF !EMPTY(m.field1)
> SHOW GET m.field2 ENABLE
> ENDIF
>
> But this will still trip up if the user "fiddles around" filling/emptying
> the field and using the mouse to navigate. You also need to disable it again
> when moving to a different record or saving (or whatever that screen does..)
>
> --
> HTH
> Andrew Howell
>
>
>
>

Re: foxpro 2.6 Fields - disabled fields makes software to abort by Andrew

Andrew
Fri Oct 22 08:14:33 CDT 2004

G wrote:
> Hi Andrew
> Thanks for your answer. I tried to use an expression in WHEN as you
> said, but didn't work. =(
> I also tried to make a procedure in the WHEN for field2 where I
> create a file with fcreate() but it won't work either. When I enter
> the field2 when it is enabled the file is created. So for me it
> appears that the WHEN 'event' doesn't run in my case. That is when I
> click with the mouse from the empty field1 into field2. As I
> described in the first mail, when I move from field1 to field2 then
> field2 is disabled.
>
> I'm not sure there is a way around this case...?

Odd, it worked fine for me..... I am using 2.6a - I don't know if this was
something that was fixed in the patches from 2.6 to 2.6a. Definately you
should patch to 2.6a if you haven't already. I have pasted my screen code
below, could you try pasting it into an empty .PRG and then running it?

***************
* butchered from screen generator:
***************
#REGION 0
REGIONAL m.currarea, m.talkstat, m.compstat

IF SET("TALK") = "ON"
SET TALK OFF
m.talkstat = "ON"
ELSE
m.talkstat = "OFF"
ENDIF
m.compstat = SET("COMPATIBLE")
SET COMPATIBLE FOXPLUS

m.rborder = SET("READBORDER")
SET READBORDER ON

m.currarea = SELECT()

* Windows Window definitions

IF NOT WEXIST("_1d00udaa0")
DEFINE WINDOW _1d00udaa0 ;
AT 0.000, 0.000 ;
SIZE 22.000,98.400 ;
FONT "MS Sans Serif", 8 ;
FLOAT ;
NOCLOSE ;
MINIMIZE ;
SYSTEM
ENDIF

* DELME/Windows Setup Code - SECTION 2

#REGION 1
STORE '' TO m.field1, m.field3
STORE {//} TO m.field2

* DELME/Windows Screen Layout

#REGION 1
IF WVISIBLE("_1d00udaa0")
ACTIVATE WINDOW _1d00udaa0 SAME
ELSE
ACTIVATE WINDOW _1d00udaa0 NOSHOW
ENDIF
@ 3.769,10.000 GET m.field1 ;
SIZE 1.000,6.000 ;
DEFAULT " " ;
FONT "MS Sans Serif", 8 ;
PICTURE "@K XXXXX"
@ 3.769,26.800 GET m.field2 ;
SIZE 1.000,6.000 ;
DEFAULT " " ;
FONT "MS Sans Serif", 8 ;
PICTURE "@K" ;
WHEN !EMPTY(m.field1)
@ 3.769,41.200 GET m.field3 ;
SIZE 1.000,18.400 ;
DEFAULT " " ;
FONT "MS Sans Serif", 8 ;
PICTURE "@K"
@ 16.615,36.000 GET m.dummy ;
PICTURE "@*HN CLEAR READ" ;
SIZE 1.769,15.167,0.667 ;
DEFAULT 1 ;
FONT "MS Sans Serif", 8 ;
STYLE "B" ;
VALID _1d00udac8()

IF NOT WVISIBLE("_1d00udaa0")
ACTIVATE WINDOW _1d00udaa0
ENDIF

READ CYCLE ;
VALID READKEY(1)=3

RELEASE WINDOW _1d00udaa0
SELECT (m.currarea)


#REGION 0

SET READBORDER &rborder

IF m.talkstat = "ON"
SET TALK ON
ENDIF
IF m.compstat = "ON"
SET COMPATIBLE ON
ENDIF


FUNCTION _1d00udac8 && m.dummy VALID
#REGION 1
CLEAR READ

***************
* end screen code
***************


--
HTH
Andrew Howell



Re: foxpro 2.6 Fields - disabled fields makes software to abort by G

G
Fri Oct 22 08:57:05 CDT 2004

Thanks
I tried the code and in your program it works. I use 2.6a.
When I move from field1 in your program and clicks in field2 it moves to
field3, OK. In your field1, do you write code in VALID that disables field2?
That's what I do.

/G

"Andrew Howell" wrote:

> G wrote:
> > Hi Andrew
> > Thanks for your answer. I tried to use an expression in WHEN as you
> > said, but didn't work. =(
> > I also tried to make a procedure in the WHEN for field2 where I
> > create a file with fcreate() but it won't work either. When I enter
> > the field2 when it is enabled the file is created. So for me it
> > appears that the WHEN 'event' doesn't run in my case. That is when I
> > click with the mouse from the empty field1 into field2. As I
> > described in the first mail, when I move from field1 to field2 then
> > field2 is disabled.
> >
> > I'm not sure there is a way around this case...?
>
> Odd, it worked fine for me..... I am using 2.6a - I don't know if this was
> something that was fixed in the patches from 2.6 to 2.6a. Definately you
> should patch to 2.6a if you haven't already. I have pasted my screen code
> below, could you try pasting it into an empty .PRG and then running it?
>
> ***************
> * butchered from screen generator:
> ***************
> #REGION 0
> REGIONAL m.currarea, m.talkstat, m.compstat
>
> IF SET("TALK") = "ON"
> SET TALK OFF
> m.talkstat = "ON"
> ELSE
> m.talkstat = "OFF"
> ENDIF
> m.compstat = SET("COMPATIBLE")
> SET COMPATIBLE FOXPLUS
>
> m.rborder = SET("READBORDER")
> SET READBORDER ON
>
> m.currarea = SELECT()
>
> * Windows Window definitions
>
> IF NOT WEXIST("_1d00udaa0")
> DEFINE WINDOW _1d00udaa0 ;
> AT 0.000, 0.000 ;
> SIZE 22.000,98.400 ;
> FONT "MS Sans Serif", 8 ;
> FLOAT ;
> NOCLOSE ;
> MINIMIZE ;
> SYSTEM
> ENDIF
>
> * DELME/Windows Setup Code - SECTION 2
>
> #REGION 1
> STORE '' TO m.field1, m.field3
> STORE {//} TO m.field2
>
> * DELME/Windows Screen Layout
>
> #REGION 1
> IF WVISIBLE("_1d00udaa0")
> ACTIVATE WINDOW _1d00udaa0 SAME
> ELSE
> ACTIVATE WINDOW _1d00udaa0 NOSHOW
> ENDIF
> @ 3.769,10.000 GET m.field1 ;
> SIZE 1.000,6.000 ;
> DEFAULT " " ;
> FONT "MS Sans Serif", 8 ;
> PICTURE "@K XXXXX"
> @ 3.769,26.800 GET m.field2 ;
> SIZE 1.000,6.000 ;
> DEFAULT " " ;
> FONT "MS Sans Serif", 8 ;
> PICTURE "@K" ;
> WHEN !EMPTY(m.field1)
> @ 3.769,41.200 GET m.field3 ;
> SIZE 1.000,18.400 ;
> DEFAULT " " ;
> FONT "MS Sans Serif", 8 ;
> PICTURE "@K"
> @ 16.615,36.000 GET m.dummy ;
> PICTURE "@*HN CLEAR READ" ;
> SIZE 1.769,15.167,0.667 ;
> DEFAULT 1 ;
> FONT "MS Sans Serif", 8 ;
> STYLE "B" ;
> VALID _1d00udac8()
>
> IF NOT WVISIBLE("_1d00udaa0")
> ACTIVATE WINDOW _1d00udaa0
> ENDIF
>
> READ CYCLE ;
> VALID READKEY(1)=3
>
> RELEASE WINDOW _1d00udaa0
> SELECT (m.currarea)
>
>
> #REGION 0
>
> SET READBORDER &rborder
>
> IF m.talkstat = "ON"
> SET TALK ON
> ENDIF
> IF m.compstat = "ON"
> SET COMPATIBLE ON
> ENDIF
>
>
> FUNCTION _1d00udac8 && m.dummy VALID
> #REGION 1
> CLEAR READ
>
> ***************
> * end screen code
> ***************
>
>
> --
> HTH
> Andrew Howell
>
>
>

Re: foxpro 2.6 Fields - disabled fields makes software to abort by Andrew

Andrew
Mon Oct 25 02:33:33 CDT 2004

G wrote:
> Thanks
> I tried the code and in your program it works. I use 2.6a.
> When I move from field1 in your program and clicks in field2 it moves
> to field3, OK. In your field1, do you write code in VALID that
> disables field2? That's what I do.

No, and I think that's what's tripping it up.
When you click on field2 with the mouse, Fox thinks it's OK. However, it
then needs to execute its valid for field1 and part of that routine disables
field2. It seems to finish executing the field1 valid clause and then tries
to move focus to a disabled control and terminates the READ.

I handled it with *just* a WHEN clause on field2 (no disabling of controls.)
Here's a picture of the screen designer to try to show you how I made it:
http://www.rowan.nildram.co.uk/pic/fpwfocus.png

There's no problem sticking most code in the field1 valid, but I think if
you try enabling/disabling other field controls you will run into bother if
you click on those other fields with the mouse.

--
HTH
Andrew Howell