Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASCII report: field is blank and not spacing

Status
Not open for further replies.

cunner26

Technical User
Nov 18, 2002
9
CA
I am currently working on an ASCII report. Each field must start at the same point. I have come to a field based on employee middle names. The problem lies in that some employees have middle names and some do not. The field length for the Middle Name is 12. For those employees that have a middle name the spacing works fine, it is for those employees that do not. It seems that if the field is blank then it is not picked up and therefore there is no spacing put in.

eeEmployee.EInitial is a string type field.

I have been trying to play around with the following formula:

if Length ({eeEmployee.EInitial}) = 1 then Picture ({eeEmployee.EInitial},"x___________" )
else if Length ({eeEmployee.EInitial}) = 2 then Picture ({eeEmployee.EInitial},"xx__________")
else if Length ({eeEmployee.EInitial}) = 3 then Picture ({eeEmployee.EInitial},"xxx_________")
else if Length ({eeEmployee.EInitial}) = 4 then Picture ({eeEmployee.EInitial},"xxxx________" )
else if Length ({eeEmployee.EInitial}) = 5 then Picture ({eeEmployee.EInitial},"xxxxx_______" )
else if Length ({eeEmployee.EInitial}) = 6 then Picture ({eeEmployee.EInitial},"xxxxxx______" )
else if Length ({eeEmployee.EInitial}) = 7 then Picture ({eeEmployee.EInitial},"xxxxxxx_____" )
else if Length ({eeEmployee.EInitial}) = 8 then Picture ({eeEmployee.EInitial},"xxxxxxxx____" )
else if Length ({eeEmployee.EInitial}) = 9 then Picture ({eeEmployee.EInitial},"xxxxxxxxx___" )
else if Length ({eeEmployee.EInitial}) = 10 then Picture ({eeEmployee.EInitial},"xxxxxxxxxx__" )
else if Length ({eeEmployee.EInitial}) = 11 then Picture ({eeEmployee.EInitial},"xxxxxxxxxxx_" )
else if Length ({eeEmployee.EInitial}) = 12 then Picture ({eeEmployee.EInitial},"xxxxxxxxxxxx" )
else if IsNull ({eeEmployee.EInitial}) then "____________" else
""

Thank you for your help,
 
You must always test for nulls first. Move your null test to the begining of your formula and you should be fine.

Here is an alternate formula:

if isnull({eeEmployee.EInitial}) then ReplicateString("_",12) else
{eeEmployee.EInitial}+replicatestring("_",12-length({eeEmployee.EInitial}))

It is much easier than yours and acheives the same end.

Software Training and Support for Macola, Crystal Reports and Goldmine
714-348-0964
dgilsdorf@mchsi.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top