GET with SPINNER

Post Reply
reds
Posts: 50
Joined: Tue May 16, 2017 12:19 pm
Location: North London

GET with SPINNER

Post by reds »

I want to specify start and end number ranges via Spinner and show the number of records that match the various ranges
entered as the Up or Down key is selected (example below)

Presumably while I just press the UP or DOWN arrow it's still in focus and the VALID clause isn't getting called.

Calling it via ON UP and ON DOWN just prevents the Spinner from working

Thanks
Peter

Code: Select all

#Include "FiveWin.Ch"


Function Main()
   Local oDlg
   Local oGet1
   LOCAL oGet2
   LOCAL nStart := 0
   LOCAL nEnd   := 0
       
  USE CUSTOMER NEW  SHARE

   DEFINE DIALOG oDlg FROM 100,100 TO 400,400 PIXEL
   
   @ 2,1  GET oGet1 VAR nStart PICT "99" SPINNER  VALID  Selected(nStart,nEnd)
   @ 2,10 GET oGet2 VAR nEnd   PICT "99" SPINNER  VALID  Selected(nStart,nEnd)
     
   ACTIVATE DIALOG oDlg 
 
 return nil
 
    FUNCTION Selected(nStart,nEnd)
LOCAL nSelected := 0

DBGOTOP()
 DO WHILE  ! EOF()
       IF   nStart <= CUSTOMER->AGE .AND.  nEnd  >= CUSTOMER->AGE 
                nSelected++
      ENDIF

DBSKIP()
ENDDO
@ 14,15 SAY STR(nSelected)+" selected"

RETURN .T.
User avatar
Massimo Linossi
Posts: 474
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: GET with SPINNER

Post by Massimo Linossi »

Try with ON CHANGE
reds
Posts: 50
Joined: Tue May 16, 2017 12:19 pm
Location: North London

Re: GET with SPINNER

Post by reds »

Thanks

Peter
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: GET with SPINNER

Post by ukoenig »

Peter,
a much faster solution :

instead of using a spinner ( it takes to long scrolling on two gets )
opening only one xbrowse with a range-selection of ages ( array )
define a range with 2 clicks for the start- and end-value.
The higher value will move to the second get
The image shows that the startvalue 33 is moved to the 1. get
After the 2. click the xbrowse will be closed ( hide )
and the final result is shown.

because of start and end = 0 by default, the first selection is moving to the 2. get
the position can change after the 2. selection.

Image

if You like it smaller :

Image

regards
Uwe :D
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
reds
Posts: 50
Joined: Tue May 16, 2017 12:19 pm
Location: North London

Re: GET with SPINNER

Post by reds »

Thanks for that Uwe

I can definitely see the merits in this for selecting from a short range of numbers but I have one range between 0-99999
a couple in four figures and a percentage range with decimal places.

In most cases the intial numbers will be entered via the keyboard and the spinner option is to provide "fine tuning" of
the selected number range.

However currently when using the spinner if a range is in error, i.e. start > end ,allthough the get
still has focus,it doesn't prevent moving the cursor to other Spinners/Xbrowses on the dialog

Regards
Peter
Post Reply