#include special.inc
setwin( 1, 1, 28, 79 )
system( 7001, 'Data Entry' )
private i,b,c,count,q
reg = 'b/w'
hig = 'b/w+'
inv = 'w/b'
#define SF_COMBO 12
#define SF_DROP 13

set color to &reg

declare b[ 10 ], c[ 10 ]
for i = 1 to 10 
  b[ i ] = ltrim( str( i ) )
  c[ i ] = ltrim( str( i ) )
next	
listchoice=4

count = 0
rad = 3
clk = 'Around'
tri = 2
lst = 2
lst2 = 'Fourth'
chk = .t.

set fullread on

@ 0.5,1 say "Demonstration of Field Types" font "Helvetica Bold",15 color "l/wu"

@ 2.2, 5 say 'Radio: ' get rad picture ;
  '@*RN   O~ne  ;  T~wo  ;  T~hree  ;  ~Four  ;  F~ive  ' ;
  valid valfun( rad ) size 1.5,12

@ 2,25 say 'Button:' get clk picture ;
  '@*N  ~Over ; ~Under ; ~Around ; ~Through ' ;
  valid valfun(  clk ) size 1.75,10,.25

SET DELIMITERS ON
SET CONFIRM OFF
store space(30) to s1
  @10,5 say 'Text 1: ' get s1 size 1,10 valid valfun( s1 ) 

SET DELIMITERS OFF

s2 = 'This is a default string'
@11.5,5 say 'Text 2: ' get s2 size 1,28 picture '@K' ;
 valid valfun( s2 )
@12.5,13 say 'Field will be blanked out when first character entered.' font 'Helvetica',7

SET DELIMITERS ON
n1 = -123456.789
@14,5 say 'Number: ' get n1 pict;
  '@$ 9999,999,999.99-'  valid valfun( n1 )

n2=150
@ 15.5,4 say 'Spinner: '
@15.9,13 get n2 SPINNER 1,1,200;
  picture '@K' valid valfun( n2 )
@ 15.5,30 say '(1-200 by 1)'

n3=0
tbl = { 0.5, ' Min', 3, 'Mid', 6, 'Max ' }
@ 17.3,2 say 'Slider: '
@17,11 get n3 SLIDER 1,0,7 from tbl size 2,32;
  picture '@K' valid valfun( n3 ) color b/w

s3 = 'This is a text field (30)' + chr(13) + ;
     'with a second line'
@20,3 say 'Multi Line: ' get s3 size 3.3,30 valid valfun( s3 )

set color to r/b
@1.5,45.5 to 24,78 double clear

set color to w/b
@10.1,47 to 19.25,71.5

@ 2,48 say 'Three-Way:' get tri picture ;
  '@*3 Yes/No/Maybe';
  valid valfun( tri ) size 1,17

@ 3.75,48 say 'Check-Box:' get chk picture ;
  '@*C True/False';
  valid valfun ( chk ) size 1,14

@5.5, 52.25 say 'List.' get listchoice from c picture ;
  '@&' valid valfun( listchoice ) size 4,12

@10.5,51.75 say  'Combo.' get lst from b picture '@~';
  valid valfun( lst ) size 5,5

@15.5, 47.75 say 'Drop Down.' get lst picture ;
  '@^N First;Second;Third;Fourth;Fifth;Sixth';
  valid valfun( lst ) size 5,10

@20.5, 47 say 'Drop Down2.' get lst2 picture ;
  '@^N First;Second;Third;Fourth;Fifth;Sixth';
  valid valfun( lst2 ) size 5,10

set color to &reg
q = .f.
@22,4 get q picture '@* ~Quit' size 3,8 

do while .t.
   read save
   if msgbox('Termination Selected', 'Are you sure?',4) = 6
      exit
   endif
enddo

clear gets
return

**********************************************************
func quitfun
return .t.

func valfun
para s
	
	if otype( s ) = 'N'
		p = str( s, 12, 2 )
	else
		if ( otype( s ) = 'L' )
			p = iif( s, 'TRUE' , 'FALSE' )
		else
			if otype( s ) = 'U'
				p = '***UNDEFINED***'
			else
				p = trim(s)
			endif
		endif
	endif
				
	@ 25,1 say 'Entered field=(' + ltrim(str(lastfield())) + ') type=('+otype(s)+')' + ' Data=(' + p + ')' + space( 50 )
	COUNT = COUNT +1 
*
* The Combo & 1st dropdown share the same variable
*
	if lastfield() = SF_COMBO
		showgets( SF_DROP )
	endif
	if lastfield() = SF_DROP
		showgets( SF_COMBO )
	endif
	return .t.
