IBM Carriage Control (ASA) Formatting

Help with writing and playing macros

IBM Carriage Control (ASA) Formatting

Postby is2gu » Tue Apr 10, 2007 2:46 pm

I have a number of files that have ibm carriage control codes in first column.
How do I create a macro that can replace the codes with the appropriate line feeds and eliminate the extra column?

The codes in column 1 are:
blank Advance one line
0 Advance 2 lines
1 Advance 1 page
- Advance 3 lines
+ Do not advance
User avatar
is2gu
Newbie
 
Posts: 1
Joined: Wed Oct 26, 2005 11:00 pm

Re: IBM Carriage Control (ASA) Formatting

Postby Mofi » Wed Apr 11, 2007 6:42 am

You can't really expect an answer with that poor description. Post an example before and after macro execution enclosed in [code][/code] to help us to understand what you want.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4064
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: IBM Carriage Control (ASA) Formatting

Postby jorrasdk » Mon Apr 23, 2007 10:00 am

Was waiting on is2gu to get back, but as I am quite familiar with ASA control characters:
http://en.wikipedia.org/wiki/ASA_carria ... characters
I offer this solution:

Textfile with ASA control chars in 1st column:
Code: Select all
1first line
0third line
+           overlay on third line (not supported, but deleted)
-sixth line
 seventh line
1new page, 1st line
 Second line
0fourth line


After "expanding" the ASA control chars:
Code: Select all
first line

third line


sixth line
seventh line
^b
new page, 1st line
Second line

fourth line


The "^b" is replaced by the actual page break control char.

Here is the macro (could be named "asaexpand"):
Code: Select all
InsertMode
ColumnModeOff
HexOff
UnixReOff
Find RegExp "%[+]*^p"
Replace All ""
ColumnModeOn
EndSelect
Key Ctrl+END
Key HOME
Key RIGHT ARROW
Key SHIFT
SelectToTop
StartSelect
Key HOME
Find "1"
Replace All SelectText " %%%newpage%%%"
Find "0"
Replace All SelectText "^p "
Find "-"
Replace All SelectText "^p^p "
Key DEL
ColumnModeOff
Top
Find "%%%newpage%%%"
Replace All "^b"
Top
IfCharGt 32
Else
Key DEL
EndIf


Please note, that I use "^p" so the text file should be DOS format (Use File / Conversions if not, or change the macro accordingly )
User avatar
jorrasdk
Master
Master
 
Posts: 275
Joined: Mon Mar 19, 2007 11:00 pm
Location: Denmark


Return to Macros