Yes, you can define text styles (and even whole text platforms) very easily directly in your script. Often it’s simpler to define them in the Text Preferences and just select them in your script, but sometimes it makes sense to create styles in your script.
If you want to define a style in your script, you can do it like this:
set the currentTextPlatform.styles.NewStyle to (TextFont:font, TextSize:8, Bold:"Yes", TextBackgroundColor:Color1, TextColor:Color2)
That will define a style called “NewStyle” that you can use subsequently in any script during that run.
click (Text:"my text", textStyle:"NewStyle")
All of the text styles for all of the defined text platforms are contained in a global property called the textPlatforms (try typing “put the textPlatforms” in the Do box to see it all). You can modify the styles through the textPlatforms, but it’s a large and complex structure, so the currentTextPlatform is designed to provide a shortcut to the current platform that you can use as shown above.
Keep in mind that generally, if you are working with two different platforms (such as Windows XP and Windows Vista) you should probably define two text platforms, with corresponding styles in each. Then you can set the currentTextPlatform to the one you’re working with and each style will be correct for that platform.