Page 1 of 1

All fields require an input answer

Posted: Sat Jan 03, 2015 12:18 pm
by morrell
I have burned the midnight oil last night and came back refreshed this morning and yet again I'm 'stumped' (word used in the game of cricket).

All the fields are numeric (can't stop the Return line feed being used):

Code: Select all

on openField
mobileSetKeyboardType "numeric"
end openField
on keyDown theKey 
if theKey is not a number then 
beep
exit keyDown
end if
if the number of chars of me < X then
pass keyDown
else 
beep
end if
end keyDown
Only two buttons are used named Cancel and Go and should the Go be selected before all or only some fields have been answered, I need the calculations to not be performed and the user receive a message.

I tried if and or (my or always gets an error) but feel I'm on the wrong track with this way and the calculations still take place.

Regards,

Ruth

Re: All fields require an input answer

Posted: Sat Jan 03, 2015 1:13 pm
by Dixie
Ruth...

I have attached a stack, I hope that it does what you wish...

1. Takes only numbers in the fields.
2. The returnKey is disabled
3. Warns the user if all the fields are not completed
4. 'Cancel' just clears all the fields..

I have only run this on the desktop...

dixie

Re: All fields require an input answer

Posted: Sat Jan 03, 2015 5:01 pm
by morrell
Thank you Dixie,

Before working on your script I tried to find more examples using noInput and was surprised to find nothing on Google or this Forum.

After adding fields and playing about with it, I now know my own layer numbering had no sequence (not that up to now I needed it).

Whilst I think I may be back asking a question or two on this after I have implemented changes to my Cards this evening. I do have a question in that whilst disabling the Return key works fine, I could not fathom out how to add a beep to it.

Regards,

Ruth

Re: All fields require an input answer

Posted: Sat Jan 03, 2015 8:07 pm
by jacque
morrell wrote:I could not fathom out how to add a beep to it.
There's the "beep" command. But note what the dictionary says about it if you're building for iOS.

But for what it's worth, beeping is largely discouraged. It's irritating and users get hostile. If the problem is simply an incorrect field entry then it is better to just disallow the entry than to beep -- users feel accused if the machine talks back to them, and repeated errors will drive them nuts. I'd reserve beeps for really serious problems that require immediate attention.

Re: All fields require an input answer

Posted: Sat Jan 03, 2015 10:11 pm
by morrell
Hello Jaqueline,

I note your comments regarding IOS. I only found out last week that what I'm working on is going to be no use for an IOP because my App can only be produced on a Mac and as I don't have one, neither does anyone in my quite large family, or even my circle of friends. I'm bitterly disappointed and preparing for my grandson's "We told you so".

Regarding your users observations on the beep. I have to disagree with you, as my own limited research at my 'Elderly ladies club' where I have taken my phone and asked a great many to run it without my explaining what to do (you advised to do this testing on your web site), is they found the beep extremely helpful. I would add that even though the inbuilt numeric keypad I call is quite large there is a surprising amount of miss hitting (myself included). But then we are all in the not so good sight and shaky hands club! Plus my bachelor son has just dropped off his washing to me (I know, I spoil him) and who lives on his mobile phone said that whilst he agrees with you in general, in this case and knowing the age profile who the App is aimed at he thinks the beep will be beneficial.

You wrote There's the "beep" command and I'm not sure what you meant by that.

Regards,

Ruth

Re: All fields require an input answer

Posted: Sat Jan 03, 2015 10:29 pm
by SparkOut
Don't give up!
IOS is not the only mobile operating system. You can still make your app for Android, and :P to your doubting family!

beep is a command that will make a basic beep sound on most OS. On Android it will try to use the default notification sound, or otherwise the ringtone. At a later stage you can get a bit more specific and have a particular beep noise played on a sound channel, but let's get you to a stage where that's just a tweak first.

What part of the UK are you, just out of curiosity? I live in Kent.

Re: All fields require an input answer

Posted: Sat Jan 03, 2015 10:42 pm
by SparkOut
Regarding input validation, my thoughts are:

1) You need to run a check on all the inputs at the time you press the Go button, to ensure that all values required have been input at all, and are within the correct range or type, regardless of any corrections or beeps you have when someone is actually trying to input a value.

2) If at all possible, restrict the input method to be able to enter only the right range of values. For instance, if the value must be in the range 1 to 5, a slider with values 1 to 5 is more effective at controlling the input than a field where someone may start trying to freetype text, or put a number like 999999. A Radio Group to choose one of a particular set of options rather than free typing. Etc.

Re: All fields require an input answer

Posted: Sat Jan 03, 2015 11:20 pm
by Simon
Hi Ruth,
I do have a question in that whilst disabling the Return key works fine, I could not fathom out how to add a beep to it.
You can put beep into "on returnInField" handler of Dixe's stack. "type tab" would be more interesting as it would simulate hitting the tab key.

Any chance you feel like giving a fuller description of your app?
It's not needed at all but would help with answering your questions.
Say it's a full screen phone dial pad, big numbers, easy to hit, (well for that one you don't really need much more) but I would know that you really didn't want to use the native iOS numeric keyboard and Dixe's stack missed a critical point.

Again, no pressure, just a thought.

Simon

Re: All fields require an input answer

Posted: Sun Jan 04, 2015 12:01 am
by jacque
Well then, since you followed my advice about testing you are obviously doing the right thing. :-) Beep at will.

I agree with SparkOut, build for Android. It's way easier anyway.

And when you get to be my age, your age isn't much of an issue.

Re: All fields require an input answer

Posted: Sun Jan 04, 2015 1:23 am
by morrell
Well to answer a few points after my last answer to Jacqueline.

I'm not giving up and what I have done so far with the help of the kind people on this forum is working OK on my Android.

With a few tweaks of the coding still to do I'm finished on that and can move onto what I think are minor design/layout problems (well I hope minor).

I'm from Hampshire SparkOut and the beeps are really quite few when one considers there are not a lot of non numeric keys.
All eight input fields are numeric using the code you see above together with restricting a field to either a maximum of 2 numbers (up to 59) or 4 numbers.(up to 1000) and I prefer the manual input.

Simon the beep is now on the informative script Dixie did for me and the App is speed, distance and time and once again the good people on here have solved all the questions asked.

Jacqueline I'm glad time is being good to you as this creaking gate is just about holding on with just one very rusty hinge. Having found out a little about you, your one very clever lady.

Regards,

Ruth

Re: All fields require an input answer

Posted: Sun Jan 04, 2015 3:53 pm
by sritcp
morrell wrote:I need the calculations to not be performed and the user receive a message.....
...feel I'm on the wrong track with this way and the calculations still take place.
Hi Ruth:

Amidst all the "beep"ing, I wasn't sure if the above issue got sorted out. If not, here is one way:

Put the following in the card script:

Code: Select all

global gFlag

on openCard
   put "red" into gFlag -- initialize
end openCard

on closeField
   if (field "Field1" is empty) or (field "Field2" is empty) or (field "Field2" is empty) then exit closeField
   put "green" into gFlag
end closeField
The above checks all the fields every time a field is edited, and sets the flag to green only if all fields are non-empty.

Put the following script in the "Go" button script:

Code: Select all

global gFlag

on mouseUp
   if gFlag = "red" then
      beep
      answer "Please complete all fields"
      exit mouseUp
   end if
   
   put "red" into gFlag -- reset the flag
   answer "Hey, it is working!" -- Substitute this line with your calculations.
end mouseUp
Hope this helps some.

Regards,
Sri.

Re: All fields require an input answer

Posted: Sun Jan 04, 2015 6:18 pm
by morrell
Thank you for the suggestion Sri.

Regards,

Ruth