Script Library: 1213 scripts
 

bro2text.r

REBOL [ Title: "brother to text" Date: 8-Feb-2002/17:31:18-8:00 Version: 1.1.0 File: %bro2text.r Author: "Ryan S. Cole" Purpose: {Converts some brother word processing files (.wpt) to text.} Email: %ryan--practicalproductivity--com Comments: {This script runs with REBOL/view, download from www.rebol.com} library: [ level: 'intermediate platform: 'all type: 'Tool domain: [file-handling parse text-processing] tested-under: none support: none license: none see-also: none ] ] ;;; PARSE RULES ;;; format-chars: charset [#"^B"] txt-chars: charset [#" " - #"~" #"^B"] end-of-text: [ any [ #"^]" (add-text line " ") | #"^M" (add-text line "^/") | #"^K" (add-text line "^/^/^/^/") | #"^[" (add-text line " ") | #"^B" (add-text line " ") | #"^R" (add-text line " ") | #"" (add-text line " ") | #"" (add-text line " ") ] ] some-text: [thru "^F^Y^F^Y" copy line any txt-chars] wpt-to-doc-rule: [ some [ some-text end-of-text ] ] add-text: func [line ender] [ either none? line [ line: copy "" ] [ replace line "^B" "" ] append doc join line ender ] ;;;;;;;;;;;;;; convert: func [files] [ if none? files [quit] foreach fn files [ wpt: to-string read/binary fn doc: copy "" parse/all wpt wpt-to-doc-rule replace fn ".wpt" ext/text if not all [ exists? fn not confirm rejoin ["Overwrite the file " fn "?"] ] [ write fn doc ] ] quit ] get-names: function [path-blk] [name-blk] [ name-blk: copy [] foreach f path-blk [ append name-blk second split-path f ] return name-blk ] ;;;;;;;;;;;;;;; selected-files: [] view layout [ backdrop effect [gradient 1x1 128.128.128 90.90.90] txt "This program converts brother WPT files to plain text." txt "Converted files will be placed in same directory (folder)." guide file-list: text-list return button "Browse" [ file-list/lines: get-names selected-files: request-file/filter/title ["*.wpt"] "Select one or more files." "Select" show file-list ] pad 0x40 ext: rotary ".txt" ".doc" pad 0x40 button red "Cancel" [quit] button forest "Convert" [convert selected-files] ]
halt ;; to terminate script if DO'ne from webpage
Notes
  • email address(es) have been munged to protect them from spam harvesters. If you are a Library member, you can log on and view this script without the munging.
  • (ryan:practicalproductivity:com)