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!

Validate on read progress in defined windows without reconstruct

Status
Not open for further replies.

koklimabc

Programmer
Jun 17, 2013
49
MY
Dear all,

I'm having some problem in doing validation check on whether it is numeric value or not after read progress in defined window.I'd ended up to reconstruct the defined windows each time if failed to
validate as true. Is there any good way to perform validation check without reconstruct the defined windows?

My Coding
define class btn_quan as CommandButton

procedure click
local win_name,vl_width,vl_height,;
vl_result,vl_stat

vl_stat = .t.

vl_result = SPACE(8)

win_name = "Change Quantity"

vl_width = this.parent.width/3
vl_height = 4

do while vl_stat = .t.

define windows win_name at 1,1 size vl_height,vl_width ;
TITLE "Change Quantity!" ;
COLOR RGB(255,0,0,94,94,94) ;
close

move wind win_name center

activate wind win_name

@ 1,1 SAY "Type to change :"
@ 1,17 GET vl_result
read =>I've no idea to perform validate check after read progress here.

if type(vl_result) <> 'N'
messagebox("Numeric value only!")
vl_result = SPACE(8)
else
vl_stat = .f.
endif

release win_name =>Destroy the defined windows for later reconstruct again once failed in validate.
clear
enddo

release wind win_name
clear


endpro

enddefine

Thanks appopriate to all mindful helps.
 
First of all, I'm sure you can better of this.
SAY, GET and READ are obsolete commands.

Anyway, if you want vl_result to be numeric, than simply give it a numeric value instead of SPACE(8) :
Code:
* instead
vl_result = SPACE(8)
* use
vl_result = 0
* or, if you need some decimals
vl_result = 0.00

GET command also has a VALID clause (and a MESSAGE clause), among many other clauses.
Code:
@ 1,17 GET vl_result VALID vl_result > 0 MESSAGE "Must be > 0"

But why not using a textbox instead ? [wink]

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania
 
Dear vgulielmus

Greats, It worked and Thanks.
I still don't know how to put textbox at inside define windows instead of forms. However,I've practice the same way by using SAY,GET,READ before in foxpro 2.6
but it is little different with VFP 6.0.
 
Taking Mike's comment one step further, I wouldn't have hand-written an @...SAY in FPW either. I would have used the screen builder.

The equivalent in VFP is the form designer. This task MIGHT need as many as four lines of code, but even that is probably doing the work that the tool can do for you.
 
Based on your previous questions you appear to be new to Foxpro.
If we haven't said it before WELCOME.

BUT your other questions also make it clear that you are attempting (learn?) to use OLD, OLD programming methods to get the work done.

Stop doing that and learn the more modern approach to Foxpro development.

As has been said above, go over and spend some time at:
where you can find free, on-line VISUAL Foxpro tutorials and get rid of the OLD @SAY/GET approach to your programming.
You can even download the videos so that you can watch off-line at your convenience.

Good Luck,
JRB-Bldr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top