Re: FileMaker styled text [part 2 of 2]
Re: FileMaker styled text [part 2 of 2]
- Subject: Re: FileMaker styled text [part 2 of 2]
- From: Kai <email@hidden>
- Date: Mon, 23 Jun 2003 03:35:53 +0100
in part 1 of this message, I wrote:
>
So how does the 'set {text:x} to x as text' approach compare with the above
>
forms?
On the one hand, the downside of using any 'undocumented feature' is that a
future fix might break it. (Some wags might suggest that even well
established behaviour can occasionally go MIA - but let's not go there right
now.) ;-)
On the other hand, it can still offer a few advantages - namely:
1) It generally handles Unicode text, other styled text and plain text
without error or the need for try blocks.
2) For further brevity, it can be inserted 'on the fly', without additional
lines or sub-routines. For example:
--------------------------
set {text:fileName} to (info for (choose file))'s name as string
--------------------------
3) It's significantly faster than the above alternatives. OMM, speed
benefits can range from nearly twice as fast (when processing plain text) to
almost 20 times faster (when converting Unicode text).
>
2. Since you showed us how to get text without style (sorry, no pun
>
intended) into FM, I started wondering how to control the style as well.
[Sigh] Well - I tried to muster up sufficient finesse. But sometimes, it
seems one's best just isn't good enough... ;-)
>
This is what I did (checked the archives this time, finally got in...). Also
>
tried a number of methods to control style, with no luck at all.
AFAIK, although AppleScript preserves style and font information when
copying text objects between applications and scripts, it provides no
commands for directly manipulating styled text. So, to change the style or
font for a styled text value, I guess you'd be better off doing it with an
application that knows how to manipulate styled text.
To achieve this in FileMaker Pro, I'd use the 'do menu' command - along the
lines of this example:
--================================
tell application "FileMaker Pro"
go to database "FMP_Test"'s record 2's cell "title"
do menu menu "Edit"'s menu item "Select All"
do menu menu "Format"'s menu "Style"'s menu item "Italic"
do menu menu "Format"'s menu "Text Color"'s menu item 37
end tell
--================================
In case you're not already aware of it, scripts that use the 'do menu'
command must be external to FMP - rather than incorporated as a 'Perform
AppleScript' ScriptMaker step. (Unless things have changed recently, all
menu items are disabled while a ScriptMaker script is running, so an
internal script won't be able to access the 'do menu' command.)
========================================================================
Examples and notes
========================================================================
[1] For anyone not familiar with setting record patterns, here are a few
simple examples (just illustrations, really - not recommendations):
--======================
set {name:n, creation date:d} to info for (choose file)
display dialog "The file \"" & n & "\" was created " & d & "."
--======================
set {length:stringLength} to "123456"
stringLength
--> 6
--======================
on monthName(monthNum)
set {month:n} to date ("1/" & monthNum)
n as string
end monthName
monthName(4)
--> "April"
--======================
on monthNum(monthName)
set {a, b, c} to monthName as string
set text item delimiters to a & {b, c}
set {{number:n}, text item delimiters} to
{"JanFebMarAprMayJunJulAugSepOctNovDec"'s text item 1, {""}}
n div 3 + 1
end monthNum
monthNum(April) -- or text: "April"
--> 4
--======================
-------------------------------------------------------
(Any wrapped lines abutting the left edge of the window
should be reconnected to the end of the previous line)
-------------------------------------------------------
[2] (x as record)'s <<class ksty>>: originally suggested by Arthur Knapp.
[3] For those not acquainted with the way this list works, the '<<' and '>>'
signs should be replaced by option-\ and shift-option-\ (ASCII character 199
and ASCII character 200) respectively.
--
Kai
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.