Checking Spinner Range(s)

Started by oradba4u, June 02, 2015, 03:45:56 AM

Previous topic - Next topic

oradba4u

All:
I have a winbatch window (mydialog) with 3 spinner controls. Each has a max, min, and incremental value assigned.

A lot of times a user will manually type in a value instead of using the up/down control.
When 'OK' is pressed, How can I check to see if each spinner is within the range limits (min,max) I have specified?
If any of the three is 'out of range', I want to display an error message of some kind and clear all values and display the window again.

As always, I appreciate the help.

Baffled in Buffalo


td

If the ranges are properly set as you indicate then the user cannot type in an out of range value.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

oradba4u

The spinners work fine as long as the user presses the up/down arrows... They cannot go beyond the min or max limits, but they can type a number greater than or less than the range allows and the app doesn't complain until the user presses OK, and then they get a dimension out of bounds error.

Here's my code:

initvalue = 1
initvalue2 = 1
minimum = 1
maximum = 20
increment = 1
settings = StrCat(minimum, "|", maximum, "|", increment)       ;"1|20|1"
settings2 = StrCat(minimum, "|", maximum, "|", increment)    ;"1|20|1"

initvalue3 = 1
minimum2 = 1
maximum2 = 25
increment2 = 1
settings3 = StrCat(minimum2, "|", maximum2, "|", increment2)     ;"1|25|1"

MyDialogFormat=`WWWDLGED,6.1`

MyDialogCaption=`  Hello World`
MyDialogX=175
MyDialogY=070
MyDialogWidth=330
MyDialogHeight=257
MyDialogNumControls=013
MyDialogProcedure=`MyDialogCallbackProc`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0

MyDialog001=`063,179,068,018,PUSHBUTTON,DEFAULT,"OK",1,1,32,"Microsoft Sans Serif|9728|70|34","0|0|0",DEFAULT`
MyDialog002=`199,179,068,018,PUSHBUTTON,DEFAULT,"Back to Main",0,2,DEFAULT,"Microsoft Sans Serif|9728|70|34","0|0|0",DEFAULT`
MyDialog003=`061,091,044,018,SPINNER,settings,%initvalue%,DEFAULT,3,DEFAULT,"Microsoft Sans Serif|10752|70|34","0|0|0",DEFAULT`
MyDialog004=`061,149,044,018,SPINNER,settings2,%initvalue2%,DEFAULT,4,DEFAULT,"Microsoft Sans Serif|10752|70|34","0|0|0",DEFAULT`
MyDialog005=`197,089,044,018,SPINNER,settings3,%initvalue3%,DEFAULT,5,DEFAULT,"Microsoft Sans Serif|10752|70|34","0|0|0",DEFAULT`
MyDialog006=`041,063,086,028,STATICTEXT,DEFAULT,"Number/Rank         (1-20)",DEFAULT,6,DEFAULT,"Microsoft Sans Serif|10752|70|34","0|128|0",DEFAULT`
MyDialog007=`043,119,078,032,STATICTEXT,DEFAULT,"Number/Rank         (1-20)",DEFAULT,7,DEFAULT,"Microsoft Sans Serif|10752|70|34","0|128|0",DEFAULT`
MyDialog008=`167,057,116,028,STATICTEXT,DEFAULT,"How Many?     (Maximum of 25)",DEFAULT,8,DEFAULT,"Microsoft Sans Serif|10752|70|34","0|128|0",DEFAULT`
MyDialog009=`130,110,165,016,CHECKBOX,MyVariable4,"Display Summary",1,9,DEFAULT,"Microsoft Sans Serif|8192|70|34","0|128|0",DEFAULT`
MyDialog010=`130,125,165,016,CHECKBOX,MyVariable5,"Display Progress",1,10,DEFAULT,"Microsoft Sans Serif|8192|70|34","0|128|0",DEFAULT`
MyDialog011=`297,225,165,016,CHECKBOX,MyVariable7," ",1,12,DEFAULT,"Microsoft Sans Serif|8192|70|34","192|192|192",DEFAULT`
MyDialog012=`103,239,132,012,STATICTEXT,DEFAULT,"Copyright Ã,© 2015 xxxxxxxxx, Inc.",DEFAULT,13,DEFAULT,"Microsoft Sans Serif|8192|70|34","0|0|0",DEFAULT`
MyDialog013=`043,033,240,020,STATICTEXT,DEFAULT,"Better Than Average - User Setup",DEFAULT,14,DEFAULT,"Microsoft Sans Serif|16384|70|34","0|0|0",DEFAULT`

ButtonPushed=Dialog("MyDialog")

Exit

td

You must be using an old version of WinBatch.  The release notes for version 2009c state: 'Fixed bug in WIL Dialog SPINNER control that allow the control to accept out of  numeric range or character data.'   So the current version of WinBatch will not allow a user to even type in an out of range values.  The value just remains unchanged when a user tries it.

You may be able to use a dynamic dialog callback procedure handling event 10 which should fire when a value changes or you could try checking the value when the uses attempts to dismiss the dialog.  Both steps would work with newer versions of WinBatch but aren't necessary because of the above stated bug fix...

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

oradba4u

Sorry I didn't include my winbatch version number. you are correct I am using an earlier version of winbatch.

After looking at the example in the reference manual, I think I got a "handle" (no pun intended) on how to make a workaround.

I have been away from Winbatch for some years now, and I am just getting back into it. After looking at the winbatch upgrade policy, I find it would be cheaper to pay $500 (again) then to upgrade my long expired maintenance contract! Right now that's a pretty hefty price to pay for 3 correctly running spinner controls  :)

As always, thanks for your help.

td

You get a lot more than '3 correctly running spinner controls' but that is your choice.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade