Page 1 of 1
Larger text being saved
Posted: Tue Apr 20, 2010 10:39 pm
by urbaud
I have a small program that saves and opens text. It has Open, Save and Clear buttons. It also has a Radio button and a text field. The normal size of the text in the text field is 11. When I highlight a section of the text and click the radio button, the text becomes larger (15 point font). I then save the text field contents to the "test.txt" file. Upon opening the file, the text that had been made larger is back to font size 11. This is not a standalone app. Can anyone tell me why it won't save to the larger text?
Code: Select all
Open btn:
on mouseUp
open file "test.txt"
Read from file "test.txt" until end
Close file "test.txt"
put it into fld "t1"
end mouseUp
Code: Select all
Save btn:
on mouseUp
open file "test.txt" for update
Write fld "t1" to file "test.txt"
Close file "test.txt"
end mouseUp
Code: Select all
Clear btn:
on mouseUp
put "" into fld "t1"
end mouseUp
Code: Select all
Radio btn:
on mouseUp
set the textSize of the selectedText to 15
end mouseUp
Re: Larger text being saved
Posted: Tue Apr 20, 2010 11:18 pm
by bn
Hi Dan,
what is happening here is that if you say "write field "t1" to file..." you implicitly tell Rev to write the plain text of field t1. What you do if you set the height/color or any other attribute of the field you change
the htmlText of field t1
htmlText is a property of a field that is always there and has all the attributes beyond plain ASCII text.
So your script to export and import would be like this:
Code: Select all
on mouseUp
put specialfolderpath("desktop") & "/htmlText.txt" into tPath
open file tPath for update
Write the htmltext of fld "t1" to file tPath
Close file tPath
end mouseUp
note that your file will be on the desktop, I changed that. Change it back if you want.
the import script
Code: Select all
on mouseUp
put specialfolderpath("desktop") & "/htmlText.txt" into tPath
open file tPath
Read from file tPath until end
Close file tPath
set the htmlText of fld "t1" to it
end mouseUp
you could also use the URL form to ex/import the file
Code: Select all
--- export
on mouseUp
put specialfolderpath("desktop") & "/htmlText.txt" into tPath
put the htmlText of field "t1" into URL ("file:" & tPath) -- brackets important
end mouseUp
--------- import
on mouseUp
put specialfolderpath("desktop") & "/htmlText.txt" into tPath
set the htmlText of fld "t1" to URL ("file:" & tPath)
end mouseUp
If you want to see what the htmltext of a field looks like as raw html-text you can say
put the htmlText of field 1 into field 2
greetings to B.C.
regards
Bernd
Re: Larger text being saved
Posted: Tue Apr 20, 2010 11:23 pm
by Zryip TheSlug
Hi Urbaud,
When you write text in a file, you write it in plain text. It means that it contains no style descriptor like text size, bold, italic, etc.
For obtain text with expected formatting, you have to add descriptors in your text.
- It could be html descriptor :
<p style="font-size:15px;"> My Text <p>
- RTF (rich text format) descriptor :
\pnfsN 15
etc
With which application do you want opening your text file?
Re: Larger text being saved
Posted: Wed Apr 21, 2010 7:14 am
by urbaud
Hi Bernd,
Thanks so much for the help with saving and opening a file so that non-ascii characters would also be saved. I had tried every thing I could think of, but not html. In fact, I really didn't know much about it. I didn't realize that Rev used it, but now that I think about it it makes sense since Rev can work with websites.
Are any of the airlines flying in Europe yet? I guess the volcanic ash is all over the place, especially the UK. An interesting stat I heard today: the volcano is spewing out 750 tonnes of ash a second. That's enough to fill an Olympic sized swimming pool in 3 seconds. Have you had any of it where you live?
Regards,
Dan
Re: Larger text being saved
Posted: Wed Apr 21, 2010 11:09 am
by bn
Hi Dan,
Airlines are starting to operate again. But it is not that Europe is covered with ash, we are not in the streets shoveling ashes...
The sunsets are more colorful due to the particles in the atmosphere. We sometimes have sand coming in from the Sahara, its about the same/or less then that. Or it went all into the Olympic sized swimming pools...
Re the htmlText. Rev does only a subset of html, look it up in the dictionary, it is not that Rev can display full html (you need the browser external for that), just enough for the text attributes and such. In rare circumstances you even might want to operate on the htmlText.
You also have the rtfText of a field which can come in handy when you want to export formatted text to an other application, most text oriented applications can read rtf (rich text format).
Lot of things to play around with.
How do you like iCal?
from dust/ash covered Germany to the clean air of B.C.
regards
Bernd
Re: Larger text being saved
Posted: Wed Apr 21, 2010 4:10 pm
by urbaud
Hi ZRYIP THESLUG,
Thank you for your suggestions regarding my recent post. I appreciate the information and will add it to my Rev info database.
Thanks again,
Dan
Re: Larger text being saved
Posted: Wed Apr 21, 2010 4:19 pm
by urbaud
Hi Bernd,
Glad you don't have to use your shovel! I had no idea that sand from the Sahara could blow so far north to "fill the pool". I appreciate the info on htmlText and rtfText and will look them up. As for iCal, can't say enough how useful it is. Thanks for informing me about it. Actually, as you know, BC's air is clean, but it's also SuperNatural BC. Take care.
Dan
Re: Larger text being saved
Posted: Wed Apr 21, 2010 11:10 pm
by Zryip TheSlug
urbaud wrote:Hi ZRYIP THESLUG,
Thank you for your suggestions regarding my recent post. I appreciate the information and will add it to my Rev info database.
Thanks again,
Dan
Hi Dan,
You're welcome
I started my post before Bernd complete his post.
In the end, Bernd wrote more and was much more accurate than me.
Nicely done Bernd!

Re: Larger text being saved
Posted: Wed Apr 21, 2010 11:41 pm
by bn
Hi Zyrip,
thanks.
I like your laboratory and the elaborate code you post there. Thank you.
regards
Bernd
Re: Larger text being saved
Posted: Thu Apr 22, 2010 10:20 pm
by Zryip TheSlug
Hi Bernd,
Thanks for the kind words
If my laboratory could contain something as interesting and varied that we can find on your website, I would be filled.
But I still have work to do before I reach the goal
So thanks to you
Regards,