Jump to content

Advice re: centering address in area


rsilverns.sympatico.ca

Recommended Posts

Hey all,

 

Was tossing around a few ideas of how to do this, and wanted to see how others would do it. Here is the scenario... I have 5 lines for address in my database...

i.e.

addr1 = Suite #101

addr2 = 123 Main St.

addr3 = Anytown

addr4 = MyState, MyCountry

addr5 = 12345

 

The problem is that there can be a varying number of lines used, i.e. someones address could be...

 

addr1 =

addr2 = 123 Main St.

addr3 = Anytown

addr4 = MyState, MyCountry

addr5 = 12345

 

On top of this, given user error, the data is not guaranteed to be in order, so as given above, it may be addr1 that is blank, addr2 and so on. Plus I am not going to count on the user not having entered a " " into one of the fields.

 

My goal is to account for all of these things if possible. Initially I had 5 lines, with a removeLineWhenBlank flag set on each and was calling .trim() on each field to make sure that they would be the top fields in sequence with no blank lines on a produced report. However this wasn't centering the fields in the given address window.

 

My challenge, is how would you accomplish this? I considered using a variable, but the expression to the check for null, .trim().length() == 0, add in a n etc for each field made for an ugly expression that can't be efficient at runtime.

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Note: I ended up creating a variable "ADDRESS" whose expression was:

 

"\n" +

(($V{FULL_NAME} == null || $V{FULL_NAME}.length() == 0)?"":($V{FULL_NAME} + "\n"))

+

(($F{addr1} == null || $F{addr1}.length() == 0)?"":($F{addr1} + "\n"))

+

(($F{addr2} == null || $F{addr2}.length() == 0)?"":($F{addr2} + "\n"))

+

(($F{addr3} == null || $F{addr3}.length() == 0)?"":($F{addr3} + "\n") )

+

(($F{addr4} == null || $F{addr4}.length() == 0)?"":($F{addr4} + "\n"))

+

(($F{addr5} == null || $F{addr5}.length() == 0)?"":($F{addr5} + "\n"))

 

 

The \n at start centers with the inevitable \n at end and for now I will ignore use of the .trim()

Post edited by: rsilver@bfm.bm, at: 2006/10/12 17:57

Link to comment
Share on other sites

Sorry,

 

I was referring to the best way to align the contents of the fields so that they appear as a series of sequential lines, and these lines would be centered verticially and without missing lines in the given address space in my report.

 

So given the space...

 

---------------------------------------------

.

.addr1

.addr2

.addr3

.addr4

.addr5

.

---------------------------------------------

 

If I had blank values for addr2 (e.g.) I wouldn't have...

 

---------------------------------------------

.

.addr1

.

.addr3

.addr4

.addr5

.

---------------------------------------------

 

but instead have...

 

---------------------------------------------

.

.addr1

.addr3

.addr4

.addr5

.

.

---------------------------------------------

 

Now that I've implemented the address as a variable I kind of like that approach, as I can just make 1 large field and center text verticially in the field.

 

Thx.

Rob

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...