HyperCard: How To Use for Text File Column Alignment



I want to upload a Macintosh spreadsheet to an AS/400 - via a KMW box - as a
text file with column alignment intact. Both WingZ and Excel write to text
files, but add tabs between columns. I need to have spaces between columns to
correctly align the columns using a nonproportional font.

I tried using Vantage/McSink, but it only left-justifies columns; I need right
justification on numbers.

My idea was to get a generic TTY print driver to print the spreadsheet, then
capture it to a text file for uploading. I received a TTY print driver from
GDT Softworks, but can't think of a method/utility to capture printer output to
a text file.

We aren't aware of a commercial solution to your needs, but HyperCard can be
used for a custom workaround.

Use Vantage (or Microsoft Word or equivalent) to convert the tab-delimited
output from the spreadsheet to comma-delimited text. HyperCard considers each
spreadsheet entry in the text file an item in a line. You could even use
HyperCard to do the tab-comma conversion, but for simplicity, we'll assume the
tabs have been converted.

Read the comma-delimited text into a variable (we used "container1") and call
the following code:

on mouseUp
repeat with i = 1 to the number of lines in container1
repeat with j = 1 to the number of items in line i of container1
set cursor to busy
put expand (item j of line i of container1) after container2
end repeat
put return after container2
end repeat
open file "your filename here"
write container2 to file "your filename here"
end mouseUp

function expand which
put 25 into fieldLength
if which = empty
-- send a string of spaces fieldLength long
then
repeat with i = 1 to fieldLength
put " " after temp
return temp
end repeat
else
repeat with i = 1 to fieldLength - length (which)
put " " after temp
end repeat
-- pad with spaces
return temp & which
end if
end expand

The formatted text is now saved as "your filename here".

(NOTE: The entire process could have been done while reading the text in a line
at a time, rather than moving it into a container before expanding, but it was
easier to explain as a multistep process.)


Published Date: Feb 18, 2012