Gregory Lypny wrote:
> I create cards that require my students to input data that is used
> in computations. It seems more efficient for development to have
> the data input into separate lines of one field than into separate
> fields.
Efficient in what way?
> In order for the field to have the commonly expected behaviour, I
> use the card script below.
If you use seperate fields, they will automatically have the commonly
expected behaviour without you needing to script it in.
And what happens if the user has selected the second line, but presses
the backspace key too many times? They will end up deleting too far,
moving into the first line. Not standard behaviour.
> Is there a function that allows me to determine the number of lines
> visible in the field even if it is empty
You might need to divide the height of the field by the height of each
line. This could get complicated if the lines have variable heights, or
if the height of the field isn't an exact multiple of the line heights.
I usually don't recommend using "magic numbers", but you might find it
easier to store the number of lines in a custom property of the field,
and then refer to it. ie:
if word 2 of the selectedline < the MyNumberOfLines of the target
> Also, it has been suggested to me that it is actually preferable to
> use separate fields for single value inputs, but I was not provided
> with any compelling reason. Is there any?
1. Less scripting. Standard behaviour is already built in without any
extra scripting. Non-standard behaviour (eg down arrow jumps to the next
field) can be accomplished with very little scripting.
2. Data integrity. There is less chance the user can accidently corrupt
the data if it is split into seperate fields. Eg there is no way they
can accidently overtype all four sets of data in one action, which could
happen in a single field.
3. Easier maintainance of the program. Lets say that one of the fields
is a person's name. Compare the following data retrievals:
get field "Person Name"
with:
get line 3 of field "Data Entry"
In twelve months time when you are maintaining this program, which one
is easier to understand?
If you decide to move the name field from line 3 to line 2, how many
places will you have to edit the script to change 3 to 2? Are you sure
you haven't missed one? What if you decide to add an extra field? Now
you have to go through the scripts and edit them all again. It is *much*
easier to refer to them by name.
None of these issues are insurmountable with the single-field data entry
method, but it takes extra work to implement it. I'm not sure why you
think it is neccessary.
--
Steven D'Aprano
==========================================
M.B. Sales Pty Ltd Ph: +61 3 9460-5244
A.C.N. 005-964-796 Fax: +61 3 9462-1161
This is the MetaCard mailing list.
Archives: http://www.mail-archive.com/metacard%40lists.best.com/
Info: http://www.xworlds.com/metacard/mailinglist.htm