Jump to content
Larry

Text file Converter 80-col to 40-col?

Recommended Posts

Does anyone know of a good text file converter to "cut" 80-column files down to 40-column? Have some PC text files I'd like to convert to Atari format without completely manually editing them.

 

Thanks,

Larry

Share this post


Link to post
Share on other sites

Haven't had the need for that sort of stuff for decades.

Fairly sure a short computing project back at school was to do that sort of thing,

ie - keep track of most recent end-of-word and do line truncation there if the next word exceeded your set limit.

 

You can do that sort of thing in Basic, turbo mode in emulation a big help.

Potential problem though is that you still have the CR/LF from 80 column truncation and you'll likely end up with a bunch of lines somewhat shorter than they could potentially be.

 

But really, no matter what you do, the result will probably need a bit of massaging to make it look the way you want.

Share this post


Link to post
Share on other sites

Does anyone know of a good text file converter to "cut" 80-column files down to 40-column? Have some PC text files I'd like to convert to Atari format without completely manually editing them.

 

You could use a text editor like "jEdit", select 40 chars wrap width as buffer option, select all and choose "Format paragraph".

If you just like to browse/read the files on your Atari, you could use "Seitensprung" which not only supports CR/LF but also wraps the text around.

Edited by Irgendwer

Share this post


Link to post
Share on other sites

Try put it to "First XL-ent". CR/LF can be problem, but i think than "Panther" text editor would be ok for this. Or use simple Turbo Basic XL procedure like this (I dont try it):

99 --
100 PROC CONVERT
101 O.#1,4,0,"PC_TEXT":O.#2,8,0,"ATARI_TEXT":.PC_TEXT AND ATARI_TEXT IS VALID PATH TO TEXTES
102 FOR I=%0 TO 39:.LINE WIDTH IS 40 CHAR
103 TRAP 200:.IF WILL BE ANY ERROR OR EOF
104 GET#1,A:.GET SOURCE
105 IF A=13:GET#1,A:PUT#2,155:I=39:G.102:.13 10 IS CODE FOR CR/LF - IT IS THAT SAME THAN ATARI 155 CODE
106 PUT #2,A:.SAVE LETTER TO ATARI FILE
107 N.I
108 G. 102
110 ENDPROC
200 CL.:END

Good luck.

Share this post


Link to post
Share on other sites

Larry,

Are these Text files already on your PC if so most of the modern Text file editors have a wrap at screen borders and convert WRAPS to CR/LF, so just set your screen size to 39 and Wrap and set CR/LF.

Even the file by Flashjazzcat The Last Word has a macro for putting a carriage return at the screen border.. Just make screen width 40 or what ever and issue the Macro command.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks guys. I like the PC solution best -- should have thought of that, but didn't.

 

I set WORD's right margin to 4.5" and then saved it as text with CR/LF on each line. Works like a charm. No split words, etc. Minimal "tweaking."

 

I was hoping not to reinvent the wheel, and thanks to this procedure, didn't!

 

-Larry

Share this post


Link to post
Share on other sites

If you are not opposed to SDX, there is a way to do it using the FMT command.

 


FMT (Format Text) Command
Purpose
Simple text formatter.
Syntax
FMT [/s|J] fname[.ext] [ncol]
FMT[/s|J] <<fname[.ext]
Type
External - on device CAR:
Related
MAN, MORE, LESS, TYPE
Availability
As of SpartaDOS X 4.42.
Remarks
This is a simple text formatter, which reads the input line by line and
applies to each one:
• Spaces at the beginning of the line are removed.
• '/S' switch: Multiple spaces are turned into one single space.
• If the resulting line is longer than 'ncol' characters, it will be folded.
• '/J' switch: The line gets justified to both margins, unless it contains an
EOL character at the end.
The 'ncol' value may not be less than 32 or more than 127. When 'ncol'
was not specified, the current screen width is assumed.
The line folding and justification works best, when the text is prepared so
that single paragraphs (no matter how long) are terminated by one or
two EOL characters, but do not contain EOLs themselves (continuous
text). In other words, the text should not have been broken into lines. To
prepare such a file a text editor can be used that can do proper line
wrapping and does not enforce terminating each line with the Return key
– e.g. "First XLEnt Wordprocessor".
FMT is a filter command that can receive data from a pipe. Its primary
purpose is helping to format documentation files for the MAN command.
76
4 The Command Processor – Commands
For example, if you want to print one of the help files (say HELP.DOC) on
paper in 80 columns and justified form, do this:
MAN HELP /P | FMT /S /J - 80 >>PRN:
If the text was not prepared according to the remarks above, it is a good
idea to preview the FMT output on the screen first.
Chapter 5 contains more information on pipes.

Share this post


Link to post
Share on other sites

Thanks, Stephen. I do appreciate your post and the info. I'm not a SDX user, but I've bookmarked this thread in case it comes in handy in the future.

 

-Larry

Share this post


Link to post
Share on other sites

No, no, no!

 

Automate it. Always Automate it!

 

Use fold, fmt, or par.

 

Readily available for UNIX, Linux, Macs... If you still use windows, there is a Windoze port for par, here, and there are likely ports for fold & fmt, if you go looking with your favorite search engine.

 

...if you need to compile any source try the Digital Mars ANSI C compiler for Windows, and it may do the trick.

 

Look up sed, awk, and grep, while you're at it... Never do a gazillion things by hand. Remember, if you have to do anything more than once or twice, automate it!

 

Don't forget to create a new directory, and copy everything that you want to modify into that directory, before you get started modifying your text files.

 

You may find that diff (or windiff) will help you out, as a check, to ensure that everything went as you expected it to.

 

Enjoy.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...