Hi Len,
1) Why does put "4" is a date return true? If this function
doesn't actually work, why is it still available? I'd like to be
able to have users enter a date without any kind of punctuation
(i.e., 08142007) and be able to validate it as a valid date. The
same applies to entering 1315 as a time (no colon).
Others have explained why "is a date" returns true for any integer.
Here is a function that validates user input as valid according to
the current system date format and returns the date in dateItems format.
function validDate theString -- 5 April 04:RCC
put stripBlanks(theString,false) into theString -- strips leading
or trailing blanks from a string
get systemDateFormat() -- see Called Routines below
set the itemDelimiter to char -1 of it -- the Separater
if the number of items of theString <> 3 then return false
delete the last char of it
delete char offset("mm",it) of it -- remove double characters, if any...
-- which
there will be until RR system date
--
correctly recognizes suppression of leading
-- zeroes
delete char offset("dd",it) of it
delete char offset("yy",it) of it
repeat with x = 1 to 3
switch char x of it
case "m"
put item x of theString into theMonth
if not validDigits(theMonth) then return false -- each
char >= "0" and <= "9"
if theMonth < 1 or theMonth > 12 then return false
break
case "d"
put item x of theString into theDay
if not validDigits(theDay) then return false
if theDay < 1 or theDay > 31 then return false
break
case "y"
put item x of theString into theYear
if not validDigits(theYear) then return false
put length(theYear) into charCount
if charCount <> 2 and charCount <> 4 then return false
if charCount is 2 then add 2000 to theYear
if theYear < 1 then return false
break
end switch
end repeat
if theDay < 29 then return
true&return&theYear&comma&theMonth&comma&theDay&",0,0,0,0"
if theMonth is 2 then
if theDay > 29 or not leapYear(theYear) then return false --
leapYear returns boolean
else return true&return&theYear&comma&theMonth&comma&theDay&",0,0,0,0"
else
if offset("0",theMonth) = 1 then delete char 1 of theMonth
set the itemDelimiter to comma
if theMonth is among the items of "1,3,5,7,8,10,12" then return
true&return&theYear&comma&theMonth&comma&theDay&",0,0,0,0"
if theDay is 31 then return false
else return true&return&theYear&comma&theMonth&comma&theDay&",0,0,0,0"
end if
end validDate
Cal;led routines:
function systemDateFormat
put "1999,1,9,0,0,0,0" into testDate
convert testDate to short system date -- RR pads day/month
regardless of settings
--
which means function will not recognize the
--
absence of leading zeroes until this is fixed
put 2 into characterNumber
repeat while char characterNumber of testDate is in "1,9"
add 1 to characterNumber
end repeat
put char characterNumber of testDate into dateSeparater
put empty into returnDateFormat
set the itemDelimiter to dateSeparater
repeat for each item datePart in testDate
if datePart > 9 then
if datePart > 99 then put "y" after returnDateFormat
put "y" after returnDateFormat
else if datePart > 1 then
if length(datePart) > 1 then put "d" after returnDateFormat
put "d" after returnDateFormat
else
if length(datePart) > 1 then put "m" after returnDateFormat
put "m" after returnDateFormat
end if
end repeat
return returnDateFormat&dateSeparater
end systemDateFormat
2) This is the "biggie." What is the proper way to validate the
contents of a field. I tried writing a "closeField" script that
would do the validation, put up a message box if the format/contents
are wrong, then set the focus back to the field for correction by
the user. I end up getting two insertion point cursors (one in the
"bad" field and one in the next field. The keyboard does go to the
bad field but having more than one insertion point is confusing to
me let alone my end users. By the way, I have tried not passing the
closeField message but I'm not sure if the "tab to next field" takes
place anyway.
Among my back burner projects is a Data Dictionary-driven RAD, which
will validate user input in a field as compliant with the Data
Dictionary specifications for the data that field captures (eg:
required?, numeric?, # of decimal positions, show thousands
separator?, show currency symbol?, lookup table, autoentry?, max
length, max lines, etc). Only some of the edits have been tested at
this stage; but all that our working are triggered by closeField,
enterInField (and returnInField for single-line fields),or internal
logic if auto-entry fields, and I have not experienced the problems
you describe.
However, I would note that my user interface keeps ALL fields without
focus locked while accepting user input in a field. When the user
signals "I'm done", the field contents are validated to DD specs. If
invalid, an error message is displayed; if valid, the field is locked
and the next (either by ordinal or based on the user input) field is
unlocked and given focus.
3) Related to #2 above, I frequently get vertical lines (insertion
point cursors) in a field as I move the mouse across it. Once they
start showing up, (and they stay so I end up with vertical bars
between every letter in the field!), I can get them to appear by
moving the mouse ABOVE the field (not in it) like I have a vertical
line that runs the height of the entire screen. Is this something
I'm doing or is it a known problem?
Do you get the same effect from a standalone compiled from your stack?
Rob Cozens CCW
Serendipity Software Company
"And I, which was two fooles, do so grow three;
Who are a little wise, the best fooles bee."
from "The Triple Foole" by John Donne (1572-1631)
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution