
Saving Styled text to Binary File
I have a EditField in a global floating window and I have a save function:
dim f as folderItem
dim b as binarystream
f = PreferencesFolder.child("Floatpad Prefs")
If f.exists then
b = f.openasbinaryfile(true)
else
b = f.createbinaryfile("pref")
end if
If b <> nil then
b.length = 0
b.writelong Notes.left
b.writelong Notes.top
b.writelong Notes.width
b.writelong Notes.height
b.writepstring Notes.title
b.writepstring Notes.EditField1.text
b.writepstring Notes.EditField1.textstyledata
b.close
Notes.TextHasChanged = false
end if
which saves all text in the edit fine. But then when I go to open the file:
dim m as menuItem
dim i as integer
dim f as folderItem
dim b as binarystream
dim s, t as string
f = PreferencesFolder.child("Floatpad Prefs")
If f.exists then
b = f.openasbinaryfile(false)
Notes.left = b.readlong
Notes.top = b.readlong
Notes.width = b.readlong
Notes.height = b.readlong
Notes.title = b.readpstring
t = b.readpstring
s = b.readpstring
Notes.EditField1.settextandstyle t, s
b.close
else
Notes.left = 9
Notes.top = 41
end if
Notes.TextHasChanged = false
It only opens 255 characters of the text saved, then I go to look at the
file and find that is also has 255 characters but I looked at the files
before and it had all the text saved. Does anyone have any ideas why?
Chris