/* For FlagShip 6 * Copyright (c) 2007 by multisoft GmbH, Munich, Germany * * You may freely modify this source according to your needs and/or * re-use any parts of it in your source code. * Release $Date: 2007/08/17 09:38:58 $ *-------------------------------------------------------------------------- * This application demonstrates use of GET field replacement * via WHEN or VALID as well as overwritting of @..GET by @..SAY. * See also getvalid2.prg for other example. * * Copy the source to your working directory, and * * Compile Linux : FlagShip getvalid1.prg -o getvalid1 * run : ./getvalid1 * or : newfswin ./getvalid1 * or : ./getvalid1 -io=t * Compile Windows: FlagShip getvalid1.prg * run : getvalid1 * or : getvalid1 -io=t */ set font "courier", 10 local v1, v2, v3, v4 v1 := v2 := v3 := space(40) v4 := 0 @ 3,1 say "v1" get v1 when fill() valid check() tooltip "V1 may not be empty" @ 4,1 say "v2" get v2 valid check("two") tooltip "enter anything in field two" @ 5,1 say "v3" get v3 when fill() valid check() @ 6,1 say "v4" get v4 pict "9999.9" when fill() valid check() tooltip "value must be > 1" READ // or READ CLEAR to clear GET fields after READ @ 9,1 say "v1:" + v1 @ 10,1 say "v2:" + v2 @ 11,1 say "v3:" + v3 @ 12,1 say "v4:" + ltrim(str(v4,5,1)) setpos(16,0) wait // CLS or CLEAR SCREEN or: @ 4,4 CLEAR TO 5,maxcol() // not required with READ CLEAR, since already cleared @ 4,4 say "You can overwrite inactive GET by SAY after clear" guicolor "r+" @ 5,4 say "the GET area by CLEAR/CLS or by separate @..CLEAR.." guicolor "r+" setpos(17,0) wait "done..." static function fill() // fill empty data by WHEN local oGet, value, varName, cText oGet := getactive() // current GET object value := oGet:varget() // current GET value varName := Readvar() // current GET variable name if empty(value) if oGet:Type == "C" cText := varName + "'s default value" // or anything else... cText := padr(cText, len(value)) // valid for char field oGet:Varput(cText) // replace GET content elseif oGet:Type == "N" oGet:Varput(0.1) endif oGet:Display(.T.) // re-display GET endif return .T. static function check(cTxt) // check for empty() by VALID local oGet, value oGet := getactive() value := oGet:varget() if empty(value) if empty(cTxt) cTxt := Readvar() endif alert("Field " + cTxt + " may not be empty") return .F. elseif Readvar() == "V4" .and. value <= 1.0 alert("Field V4 must be greater than 1") return .F. endif return .T. // eof