Jump to content

Len of First Name


Recommended Posts

This seems SO simple, yet it doesn't work...

 

if (Len(Trim(Field("FIRST NAME")) >= 2))

{

return Field(Trim("FIRST NAME"));

}

else

{

return ("Hello");

}

 

...basically just wanting to have "Hello" if a First Name has less than 2 characters. The First Name as in the data is the result without regards to the length of characters. I've used this logic in other programs, but can't seem to get the same result in FP.

 

Any help would be appreciated - Thanks!

Link to comment
Share on other sites

Your syntax is a little mixed up:

 

if (Len(Trim(Field("FIRST NAME"))[color="red"])[/color] >= 2) // You were missing a ')' and had an extra one at the trail end
{
return [color="red"]Trim[/color]([color="Red"]Field[/color]("FIRST NAME")); // Trim function needs to be around the Field
}
else
{
return "Hello"; // You do not need '()' around this string
}

 

Of course, if you'd like to condense your code a little, you could replace it with this:

 

return (Len(Trim(Field("FIRST NAME"))) >= 2 ) ? Trim(Field("FIRST NAME")) : "Hello";

Edited by step
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...