PDA

View Full Version : I'm Having Trouble Comparing length of string


nancyhutch
January 7th, 2009, 07:03 AM
What would be the rule that would verify number of characters in a field and return one value if less that 2 characters and another if more than 1 character? I have a data base where some of the first names are just an initial in which case I want to return the initial and their last name, else return their first name. Thanks for any help.

Alex Marshall
January 7th, 2009, 08:40 AM
If you know the names of the fields you want to check, you can use this
function:
function NumNonEmptyFields()
{
var count = 0;
for (var i = 0; i < arguments.length; i++)
{
try
{
if (Field(arguments[i]))
count++;
}
catch (e)
{
//Print(e);
}
}
return count;
}
You can call it with any number of parameters, like so:
return NumNonEmptyFields("Home", "Fax", "Cell", "Office");
If you want to know the total number of fields present in the job
(actually in a record of data), without knowing their names in advance,
you can create an ExternalDataFileEx object to read the delimited text
input file. Or you can wait for an enhancement in an upcoming release
which will allow you to iterate through all of the fields in the job.