| Hi Cindy,
TEXT_FILE stores the line attributes as you change them. Then keeps
using that same attribute until you change it to something else. So
what you need to do to get the end control in place is issue a:
TEXT_FILE SET LINE_ATTRIBUTES xxx /SOFT
This changes the attribute to be just a soft carriage return, and turns
off the PRINT_CONTROL resulting in a END_CONTROL block being generated.
Rick
|
| Hi cindy,
text_file works miracles, but you can't learn how from the
documentation.
Find below a script that I use to convert OfficeVision documents from
a tagged text file to WPS document. I hope you can extract what you
need.
Good luck
Klaus
! load.scp
! read an OfficeVision document and convert to WPL
!
! The input TXT file is a normal text file structured as followed:
! Each block starts with a tag consisting of two letters
! Following this tag are zero or more lines of the specified type
! The output file is a WPL document
!
! � Klaus Hamann 1992 Stuttgart, Germany
!
! --------------------------------------------------------------
!
! SET_TRACE (ALL,LOG="LOAD.LOG")
prompt 'input TXT-file: '
.if oa$prompt_dispose eqs '0' then .exit
get #in = oa$prompt_text
!
prompt 'output WPL-file: '
.if oa$prompt_dispose eqs '0' then .exit
get #out = oa$prompt_text
!
text_file open/read in #in
.if oa$status eqs '0' then .goto open_in_error
!
text_file open/write out #out
.if oa$status eqs '0' then .goto open_out_error
!
.CLEAR 1,24
! -----------------------------------------------------------------
.label read_next_tag
!
GET #TAG=#LINE=#ATTS=""
!
text_file READ in #tag
.if oa$status eqs '0' then .goto eof
!
.TEXT 1,1, "TAG " #TAG
!
.label process_next_tag
!
.if #tag eqs 'RU' then .goto got_ruler
.if #tag eqs 'TX' then .goto got_text
.if #tag eqs 'PC' then .goto got_printercommand
.if #tag eqs 'FT' then .goto got_fontcommand
.if #tag eqs 'AA' then .goto got_nobreak
.if #tag eqs 'AE' then .goto got_endnobreak
.if #tag eqs '**' then .goto got_comment
.if #tag eqs 'PA' then .goto got_page
.if #tag eqs 'SL' then .goto got_softline
.if #tag eqs 'SC' then .goto got_STARTCONTROL
.if #tag eqs 'EC' then .goto got_ENDCONTROL
.if #tag eqs 'TC' then .goto got_TOC
.GOTO TAG_ERROR
! ............................................................
.label got_ruler
! ruler is in next line
!
text_file READ in #line
text_file set ruler out #line
text_file put out
.goto READ_NEXT_TAG
! ............................................................
.LABEL GOT_TEXT
! next line is text, following line attributes
!
text_file READ in #line
text_file READ in #atts
text_file set line_type/text out
text_file set text out #line
text_file set text_attributes out #atts
text_file put out
text_file set line_attribute out
.goto READ_NEXT_TAG
! ............................................................
.LABEL GOT_PRINTERCOMMAND
! next line is command
!
text_file READ in #line
text_file set line_type/text out "
text_file set line_attribute/print_control out
text_file set line_attribute/first_print_control out
text_file put out
text_file set line_type/text out
text_file set line_attribute/print_control out
text_file set text out #line
text_file set text_attributes out #atts
TEXT_FILE PUT OUT
text_file set line_attribute out
text_file set line_type/text out
text_file put out
.goto READ_NEXT_TAG
! ............................................................
.LABEL GOT_FONTCOMMAND
! next line is font name
!
text_file READ in #line
text_file set line_type/text out "
text_file set line_attribute/print_control out
text_file set line_attribute/first_print_control out
text_file put out
text_file set line_type/text out
text_file set line_attribute/print_control out
text_file set text out #line
text_file set text_attributes out #atts
TEXT_FILE PUT OUT
text_file set line_attribute out
text_file set line_type/text out
text_file put out
.goto READ_NEXT_TAG
! ............................................................
.LABEL GOT_NOBREAK
! no data line
!
text_file set line_type/text out "
text_file set line_attribute/print_control out
text_file set line_attribute/first_print_control out
text_file put out
text_file set line_type/text out
text_file set line_attribute/print_control out
text_file set text out "NO_BREAK"
text_file set text_attributes out " "
TEXT_FILE PUT OUT
text_file set line_attribute out
text_file set line_type/text out
text_file put out
.goto READ_NEXT_TAG
! ............................................................
.LABEL GOT_ENDNOBREAK
! no data line
!
text_file set line_type/text out "
text_file set line_attribute/print_control out
text_file set line_attribute/first_print_control out
text_file put out
text_file set line_type/text out
text_file set line_attribute/print_control out
text_file set text out "END_NO_BREAK"
text_file set text_attributes out " "
TEXT_FILE PUT OUT
text_file set line_attribute out
text_file set line_type/text out
text_file put out
.goto READ_NEXT_TAG
! ............................................................
.LABEL GOT_COMMENT
! next line is comment
!
text_file READ in #line
text_file set line_type/comment out
text_file put out
text_file set line_type/comment out
text_file set text out "COMMENT"
TEXT_FILE SET TEXT_ATTRIBUTES OUT " "
text_file put out
!
text_file set line_type/comment out
text_file set text out #LINE
TEXT_FILE SET TEXT_ATTRIBUTES OUT " "
text_file put out
!
text_file set line_type/text out
TEXT_FILE PUT OUT
.GOTO READ_NEXT_TAG
! ............................................................
.LABEL GOT_PAGE
! got page mark, no data line
!
TEXT_FILE SET LINE_TYPE/HARD_PAGE OUT
TEXT_FILE SET LINE_ATTRIBUTE OUT
TEXT_FILE PUT OUT
.GOTO READ_NEXT_TAG
! ............................................................
.label GOT_SOFTLINE
!
text_file set line_attribute/soft_line out
.goto READ_NEXT_TAG
! ............................................................
.label GOT_STARTCONTROL
! got a TOP or BOTTOM control block, text in next lines until
! tag is not 'TX'
!
text_file set line_type/text out
text_file set line_attribute/print_control out
text_file set line_attribute/first_print_control out
text_file put out
text_file read in #bot
text_file set line_type/text out
text_file set line_attribute/print_control out
text_file set text out #bot
text_file set text_attributes out " "
TEXT_FILE PUT OUT
!
.label next_line
text_file read in #tag
.if #tag nes 'TX' then .goto FINISH_CONTROL
text_file READ in #line
text_file READ in #atts
text_file set line_type/text out
text_file set line_attribute/PRINT_CONTROL out
text_file set text out #line
text_file set text_attributes out #atts
text_file put out
.goto next_line
!
.LABEL FINISH_CONTROL
text_file set line_attribute out
TEXT_FILE SET LINE_TYPE/TEXT OUT
TEXT_FILE PUT OUT
.GOTO PROCESS_NEXT_TAG
! ............................................................
.label GOT_ENDCONTROL
! should be caught in GOT_STARTCONTROL
.GOTO READ_NEXT_TAG
! ............................................................
.label GOT_TOC
! TOC processing to be supplied
!
.GOTO READ_NEXT_TAG
! ----------------------------------------------------------------------
.label tag_error
get #mess = "no such tag >" #tag "< after line" #line
display (#mess)
.goto eof
! ............................................................
.label open_in_error
display ("open in error " #in)
.exit
! ............................................................
.label open_out_error
display ("open out error " #out)
.exit
! ............................................................
.label eof
text_file close in
text_file close out
! SET_TRACE (OFF)
.exit
|