Jump to content
Salesforce and other SMB Solutions are coming soon. ×

Carriage Return Issues


tchemiy

Recommended Posts

Hi,

 

Not really sure if I posted in the right forum directory, but anyways...

 

The problem I've stumbled across is "How to tell Filemaker Pro not to insert carriage return if the current line is the last one?". That is to create labels.

 

My calculation field goes like that:

 

Case (

IsEmpty ( First ); " " & Last & "¶";

IsEmpty ( Last);" " & First & "¶";

" "&First & " " & Last & "¶"

) & "" &

If ( IsEmpty ( Nickname ) ; "";" " & GetField ( "Nickname" ) & "¶" ) & "" &

If ( IsEmpty (Title) ;"" ;" "& TextSize (GetField ("Title") ; 8 ) & "¶")& "" &

If ( IsEmpty (Company ) ; "" ;" "& TextStyleAdd (GetField ("Company") ; Bold ) & "¶") & "" &

If ( IsEmpty ( Division ) ; "" ; " "& GetField ("Division") & "¶") & "" &

If ( IsEmpty ( ${Street 1 (Line 1)} ) ;"" ;" "& GetField ( "${Street 1 (Line 1)}" ) & "¶") & "" &

If ( IsEmpty ( ${Street 1 (Line 2)} ); "" ; " "&GetField ( "${Street 1 (Line 2)}" ) & "¶") & "" &

If ( IsEmpty ( City 1 ) ; "" ; " "&GetField ( "City 1" ) & "¶") & "" &

Case (

IsEmpty ( State 1 & Zip 1 ) ;"" ;

IsEmpty ( State 1 );" "& GetField ( "Zip 1" ) & "¶";

IsEmpty ( Zip 1 ); " "& GetField ( "State 1" ) & "¶";

" "&GetField ( "State 1" ) & ", " & GetField ( "Zip 1" ) & "¶"

) & "" &

If ( Country 1 = "UK" ; "" ;" " & GetField ( "Country 1" ) )

 

Thanks

Link to comment
Share on other sites

Yeah, that can be a tricky one. Here's how I generally do it:

 

Field1 & Left ("¶"; Length (Field1)*Length(Field2)) &

Field2 & Left ("¶"; Length (Field1&Field2)*Length(Field3)) &

Field3 & Left ("¶"; Length (Field1&Field2&Field3) * Length (Field4)) & so on

 

 

The hard returns get left out unless the fields on either side of them are non-empty. Thus where:

 

Field1 = "tchemly"

Field2 is blank

Field3 is "FileMaker Cafe"

Field4 is "filemakertoday.com"

 

should return

 

tchemly

FileMaker Cafe

filemakertoday.com

 

Field1 = "tchemly"

Field2 = "London UK"

Field3 is blank

Field4 is "Carriage Return Issues"

 

should return

 

tchemly

London UK

Carriage Return Issues

Link to comment
Share on other sites

  • 2 years later...
I really need this.

 

Actually, using List() and Substitute() , e.g. …

 

List ( 
 field1 ;
 field2 ;
 Substitute ( List ( field3 ; field4 ) ; ¶ ; " " ) ;
 Substitute ( List ( field5 ; field6 ) ; ¶ ; " and " ) ;
 field7 ;
 field8
)

 

… is IMO a better method; List() will simply ignore any empty results, and not generate a trailing CR.

 

AHunter3 and I have been known to disagree on this in the past. :D

Link to comment
Share on other sites

& still do :)

 

But they both work. And it's good to learn multiple ways of doing things in FileMaker. At some future point, you may find one technique adapts to your new purpose better than the other.

Link to comment
Share on other sites

Alan - just curious. What are the pros of doing it your way? Have you seen a performance benefit from it? Or is it more of a muscle-memory thing?

 

This is one of the calculation approaches I've never tested myself, to see how both perform.

Link to comment
Share on other sites

To me it's more self-explanatory, although that could be the illustion of familiarity pretending to transparency. It's also (in my opinion) more flexible, in the sense that if your delimiters are not hard returns you can still use it natively without first substituting returns for the delimiters in use. In the often-recurring case of elements of postal addresses that may or may not exist for a given address, people often also want different "connectors" — commas here, the word " and " inserted between the next two, honorific before the name only if there's a proper name and not just a company, etc — and the "Length" technique using the multiplier that equates to zero in situations where you don't want it works for those additional bits & pieces as well.

Link to comment
Share on other sites

This thread is quite old. Please start a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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...

Important Information

Terms of Use