Hot Topic (More than 10 Replies) [Solved] Concatenation/Padding/Alignment (Read 1424 times)
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
[Solved] Concatenation/Padding/Alignment
Dec 5th, 2007 at 1:59pm
Print Post Print Post  
In a different thread http://www.lantica.com/Forum3/cgi-bin/yabb2/YaBB.pl?num=1195161311 I got some help designing a freeform report, and it's coming along well, and I've used the techniques Erika suggested here http://www.lantica.com/Forum3/cgi-bin/yabb2/YaBB.pl?num=1195159451 to make a command button that opens it in Internet Explorer so it can be emailed.  Here's a sample of my current report output: http://www.jamiara.com/freeform-in-progress.htm.

Here's a sample of some of the code I'm using.  In this case, it prints the Forklift information portion of our invoices:
Code
Select All
Var vF1TotalString as String
Var vF2TotalString as String
Var vF3TotalString as String
Var vForkTotalString as String

Var vF1Total as Money
Var vF2Total as Money
Var vF3Total as Money
Var vForkTotal as Money

vF1Total = Fork_1_Total
vF2Total = Fork_2_Total
vF3Total = Fork_3_Total
vForkTotal = Forklift_Total

IF vF1Total <> 0 THEN vF1TotalString = ".....$" + @Str(@Decimals(vF1Total,2))
IF vF1Total <> 0 THEN vF2TotalString = ".....$" + @Str(@Decimals(vF2Total,2))
IF vF1Total <> 0 THEN vF3TotalString = ".....$" + @Str(@Decimals(vF3Total,2))
IF vForkTotal <> 0 THEN vForkTotalString = "..........$" + @Str(@Decimals(vForkTotal,2))

IF (Fork_1_Total <> 0 or not @IsBlank(Fork_1))
THEN
	{
	Fork_Info = Fork_1 + s5spaces + vF1TotalString + @NewLine()
	}
IF (Fork_2_Total <> 0 or not @IsBlank(Fork_3))
THEN
	{
	Fork_Info = Fork_Info + Fork_2 + s5spaces + vF2TotalString + @NewLine()
	}
IF (Fork_3_Total <> 0 or not @IsBlank(Fork_3))
THEN
	{
	Fork_Info = Fork_Info + Fork_3 + s5spaces + vF3TotalString + @NewLine()
	}
Fork_Info = Fork_Info + s10spaces + Forklift_charges_label + vForkTotalString 


The static variables in Global code that I'm using for spacing are:
Code
Select All
Stat s5spaces as string
Stat s10spaces as string

s5spaces = @Text(5, "&nbsp;")
s10spaces = @Text(10, "&nbsp;") 



My next question is, is there a way to "pad" the concatenated elements so that the money figures right-align, perhaps a better way to be using "&nbsp;"?
« Last Edit: Dec 18th, 2007 at 1:15am by Hammer »  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Concatenation/Padding/Alignment
Reply #1 - Dec 5th, 2007 at 2:29pm
Print Post Print Post  
I usually assemble the info into HTML tables when I need this kind of layout. If that will work for you, I can provide an example.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Concatenation/Padding/Alignment
Reply #2 - Dec 5th, 2007 at 3:51pm
Print Post Print Post  
Yes, please.  Thanks!
  

**
Captain Infinity
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Concatenation/Padding/Alignment
Reply #3 - Dec 10th, 2007 at 7:35pm
Print Post Print Post  
Quote:
I usually assemble the info into HTML tables when I need this kind of layout. If that will work for you, I can provide an example.

Ping.  Just a reminder, if you get a chance Erika, but no hurry.  Thanks!
  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Concatenation/Padding/Alignment
Reply #4 - Dec 11th, 2007 at 2:13am
Print Post Print Post  
Infinity wrote on Dec 10th, 2007 at 7:35pm:
Quote:
I usually assemble the info into HTML tables when I need this kind of layout. If that will work for you, I can provide an example.

Ping.  Just a reminder, if you get a chance Erika, but no hurry.  Thanks!

I'm sorry, Scott. I've been buried. I'll write this up for you in the morning.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Concatenation/Padding/Alignment
Reply #5 - Dec 11th, 2007 at 1:42pm
Print Post Print Post  
Scott,

It looks something like this. You would make all the Forklift elements invisible except ForkliftInfo.
Code
Select All
	ForkliftInfo =
		"<TABLE WIDTH=100% BORDER=1 CELLPADDING=2 CELLSPACING=0>"
		+ "<TR>"
		+ "<TD>" + Forklift1 + "</TD><TD>$" + @Decimals(Forklift1Cost, 2) + "</TD>"
		+ "</TR>"
		+ "<TR>"
		+ "<TD>" + Forklift2 + "</TD><TD>$" + @Decimals(Forklift2Cost, 2) + "</TD>"
		+ "</TR>"
		+ "<TR>"
		+ "<TD>" + Forklift3 + "</TD><TD>$" + @Decimals(Forklift3Cost, 2) + "</TD>"
		+ "</TR>"
		+ "</TABLE>"
 

  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Concatenation/Padding/Alignment
Reply #6 - Dec 11th, 2007 at 2:12pm
Print Post Print Post  
Cool, thanks, I'm working with it now.  How do I add a third column?
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Concatenation/Padding/Alignment
Reply #7 - Dec 11th, 2007 at 2:29pm
Print Post Print Post  
Hello Scott,

To add a third column you would want to change the line

Code
Select All
+ "<TD>" + Forklift1 + "</TD><TD>$" + @Decimals(Forklift1Cost, 2) + "</TD>"  



To:

Code
Select All
+ "<TD>" + Forklift1 + "</TD><TD>$" + @Decimals(Forklift1Cost, 2) + "</TD><TD>" + AnotherField + "</TD>"  



Also

To Right Align a column you would change the <TD> for that column to be <TD ALIGN=RIGHT>

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Concatenation/Padding/Alignment
Reply #8 - Dec 11th, 2007 at 3:31pm
Print Post Print Post  
Thanks guys!  It's starting to look really nice.  So far I've tabled three sections, as seen here http://www.jamiara.com/Invoice_to_Browser_2007_12_11_10_22_51.htm

Question:  What controls the width of the cells?  Is there a way to make each table align with the others?
  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Concatenation/Padding/Alignment
Reply #9 - Dec 11th, 2007 at 3:41pm
Print Post Print Post  
Infinity wrote on Dec 11th, 2007 at 3:31pm:
Thanks guys!  It's starting to look really nice.  So far I've tabled three sections, as seen here http://www.jamiara.com/Invoice_to_Browser_2007_12_11_10_22_51.htm

Question:  What controls the width of the cells?  Is there a way to make each table align with the others?


Some tips:
1. Put &nbsp; in empty cells. It looks better.

2. The width is controlled by the data. The browser tries to make it fit. The WIDTH=100% in the TABLE statement makes it use the whole page. You can also set a width in each TD to make each table use the same amount of space for each column. If you have 3 TDs, make sure the widths add up to 100. Like below.

Code
Select All
+ "<TD WITDH=50%>" + Forklift1 + "</TD><TD WIDTH=25%>$" + @Decimals(Forklift1Cost, 2) + "</TD><TD WIDTH=25%>" + AnotherField + "</TD>" 

  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Concatenation/Padding/Alignment
Reply #10 - Dec 13th, 2007 at 2:41pm
Print Post Print Post  
Thanks to Erika and Ray for help with this.  This is what my report now looks like:

http://www.jamiara.com/Invoice_to_Browser_2007_12_11_16_07_14.htm.

Instead of filling blank cells with &nbsp; I decided to remove the borders, so everything compacts nicely.  I've got a command button that opens it sweetly in Internet Explorer, allowing my folks to email it to one another.  I may adjust the width of the columns but for now I consider it complete.  Thanks again!
  

**
Captain Infinity
Back to top
IP Logged