<!--- Create the data query. --->
<cfset qData = QueryNew( "" ) />

<!--- Create the ID column. --->
<cfset QueryAddColumn(
	qData,
	"id",
	"cf_sql_integer",
	ListToArray( "1,5,78,3,232" )
	) />

<!--- Create the name column. --->
<cfset QueryAddColumn(
	qData,
	"name",
	"cf_sql_varchar",
	ListToArray( "Anna,Kit,Libby,Sarah,Franci" )
	) />

<!--- Create the astrology sign column. --->
<cfset QueryAddColumn(
	qData,
	"sign",
	"cf_sql_varchar",
	ListToArray( "Virgo,Libra,Scorpio,Scorpio,Leo" )
	) />


<!---
	Now, we are going to move the data in our constructed
	query into a fixed-with data file.
--->


<!---
	Create an array to hold our complete set of data.
	Each index in this array will represent a row in
	our final data file.
--->
<cfset arrData = [] />

<!---
	Now, we are gonna loop over the query to convert each
	record into a fixed width data row.
--->
<cfloop query="qData">

	<!---
		Create an array to hold all the fields for this row
		of data. In this array, each index of the array will
		represent a single data field.
	--->
	<cfset arrRowData = [] />

	<!--- Create a 10 digit ID. --->
	<cfset arrRowData[ 1 ] = LJustify( qData.id, 10 ) />

	<!--- Create a 30 digit name. --->
	<cfset arrRowData[ 2 ] = LJustify( qData.name, 30 ) />

	<!--- Create a 20 digit sign. --->
	<cfset arrRowData[ 3 ] = LJustify( qData.sign, 20 ) />


	<!---
		Now that our array is full of the field data, each of
		which is "padded" to be fixed length, we need to add
		it to the master data array. As we do this, however,
		we are gonna collapse this row into a single string
		by converting it into a list that has no delimiter.
	--->
	<cfset ArrayAppend(
		arrData,
		ArrayToList( arrRowData, "" )
		) />

</cfloop>


<!---
	At this point, our master data array has a finalized row of
	data in each index. We now need to collapse the master data
	array down into a single data string. We will do this by
	converting the data array into a list that uses line breaks
	as a delimiter.
--->
<cfset strFinalData = ArrayToList(
	arrData,
	(Chr( 13 ) & Chr( 10 ))
	) />


<!---
	When we output the data, let's replace the spaces with
	periods so that we can see on the web page how the fields
	were padding using LJustify().
--->
<cfoutput>
	<pre>#Replace( strFinalData, " ", ".", "all" )#</pre>
</cfoutput>