# File lib/native_file_types/apple2/AppleWorksWP.rb, line 11
def to_text
    s=""
                i=300 #skip 300 byte header
                i+=2 if contents[183]>3 #skip the first invalid line if SFMInVers non-zero
                while i<contents.length-4 do
                        command_byte_0=contents[i]
                        command_byte_1=contents[i+1]
                        i+=2
                        if command_byte_1==0xD0 then #it's a carriage return line - do nothing
                        elsif command_byte_1>0xD0 then #it's a command line - do nothing
                        else #it's a text record
                                bytes_in_line=command_byte_0
                                control_byte=contents[i+1]
                                chars_remaining=control_byte%0x80
                                contents[i+2..i+2+chars_remaining-1].each_byte do |b|
                                        if b==0x16 then #tab char
                                                s<<"\t"
                                        elsif b==0x17 then
                                                s<<" "
                                        elsif b>=0x20 then
                                                s<<b.chr
                                        end
                                end
                                i+=bytes_in_line
                                s<<"\n"
                        end
                end           
                s

end