Have you ever used separate lists on a form to enter tables of information and then wanted to display them in a view column only to find that it is almost impossible to format them for display?
This tip will take the lists and allow blank spaces to be used as fill between to line up the displayed values as if they were in separate columns.
In the example below I am using two lists, the first being an ingredient description and the second being the amount of ingredient used.
Note: Make sure that the column in the view uses a monospaced font so that the information lines up.
Ingreds := " " + @Left( Ingredient; 18); Amts:= @Text( Amount; "F2"); REM "Generate an array of numbers 0..29 (simply add to first array for higher ranges)"; numArray := "":"1":"2" *+ "0":"1":"2":"3":"4":"5":"6":"7":"8":"9"; REM "Generate an array of spaces 0..29 (simply add #*10 spaces to first array for higher ranges)"; spaceArray := "":" ":" " *+ "":" ":" ":" ":" ":" ":" ":" ":" ":" "; REM "Standardize to 25 chars in length"; Ingreds2 := Ingreds + @Replace( @Text(25-@Length(Ingreds)- @Length(Amnts)); numArray; spaceArray);
Ingreds2 + Amnts
In response to Mark Eddy's tip with the same title, here's a way to do the same thing that has the following advantages: - It doesn't require use of a monospaced font. - If entries are too long to fit, R5 users can adjust the column widths to see the entire entry. - It's a lot faster because the columns contain fields instead of formulas.
Supposing your list fields are called Ingredients and Amounts. Create two view columns displaying the field Ingredients in one and Amounts in the other. Set the columns to use Newline as the multivalue separator. They should use the same font so that the lines are the same height. Set the view to display nine rows per entry and select "Shrink rows to content."
If the values in one of the columns are too long, they will wrap misaligning it with the values in the other column. The R5 user can fix this by dragging the column bigger. Otherwise, use the following to trim entries in the Ingredients column to a standard length:
Where x is the maximum length you're sure will fit in the column.
This was first published in May 2001