Page 1 of 1

GET with SPINNER

PostPosted: Thu Jul 04, 2019 9:04 am
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  Expand view
#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.

Re: GET with SPINNER

PostPosted: Thu Jul 04, 2019 9:59 am
by Massimo Linossi
Try with ON CHANGE

Re: GET with SPINNER

PostPosted: Thu Jul 04, 2019 12:56 pm
by reds
Thanks

Peter

Re: GET with SPINNER

PostPosted: Fri Jul 05, 2019 4:46 pm
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

Re: GET with SPINNER

PostPosted: Mon Jul 08, 2019 8:41 am
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