Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Switching a @ ... EDIT to NOMODIFY on the fly

Status
Not open for further replies.

alanmusician

Programmer
Jun 30, 2005
17
US
Is there a way to switch a certain field to NOMODIFY on a screen during program execution? I need to have a certain field read-only under certain circumstances. I need something that would work like SHOW GET <field> DISABLED only with NOMODIFY. Any info?
 
Use the WHEN clause. From the help file:
The WHEN clause allows or prohibits selection of the editing region based on the logical value of <expL2>, which must evaluate to a logical true value (.T.) before the text editing region can be selected. If <expL2> evaluates to false (.F.), the region cannot be selected and is skipped if placed between other objects.
 
The WHEN clause skips it if .f. is returned. It is a field I need to behave like NOMODIFY rather than DISABLED. The difference is that the user cannot scroll through the information listed in the field. It needs to be selectable, but read-only.
 
I understand now, the only way I could think of is to use the VALID clause, maybe like this:
[tt]
yourvar = "I need to have a certain field read-only under certain circumstances."
oldvalue = yourvar
allowed = .f.
@ 10,10 SAY "allow changes?" GET allowed PICT "Y"
@ 12,10 EDIT yourvar SIZE 3,20 VALID(yourfunc())
READ CYCLE

FUNCTION yourfunc
IF NOT allowed AND yourvar <> oldvalue
WAIT WINDOW "This field is read-only" NOWAIT
yourvar = oldvalue
ENDIF
[/tt]
 
That's my current solution. I was hoping Foxpro might have something more elegant built into it. Thanks for the suggestions, though.
 
If you use the WHEN clause, you are able to scroll through the data, you just can't select it.

There might be a solution is someone knows how to reissue a @edit within the current read. To actually redraw the @edit, not use the SHOW GET(S) command.

B"H
Brak
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top