Trouble with formattedWidth revisited
Graham Samuel
livfoss at mac.com
Fri Apr 14 12:08:57 EDT 2006
On Fri, 14 Apr 2006 19:59:37 +0800, "Martin Blackman"
<martinblackman at gmail.com> wrote:
> Graham, this behaviour is stated in the docs, at least for 2.6.1
> Perhaps you could lock screen and go the card in question then return.
> Normally the formattedwidth is useful for making a card to be seen by
> the user so the behaviour is kind of understandable.
>
> regards
> Martin Blackman
>
>> That's what I am doing, but it doesn't work if field "myField" isn't
>> in the current card of the current stack, at least to as far as I
>> understand it - it just returns zero without so much as an electronic
>> squawk. Bummer for those of us who want to keep our working fields
>> far away in obscure substacks, and worse bummer if you believe the
>> RR documentation (will BZ, I promise).
Martin - thanks for the interest.
Here are the relevant extracts from the 2.7.0 Dictionary
>
> The formattedWidth of an object is a positive integer. The object
> must be on the current card of an open stack.
> The formattedWidth of a chunk in a field is the amount of
> horizontal space that portion of the field's text requires, taking
> line breaks into account.
In my experience, it must be the current card of 'this stack', not
some other stack that happens to be open: this is why I got into
trouble. IMHO, if a script tries to get the formattedWidth or
formattedHeight of an 'illegal' card, then at the very least this
should be reported as an error in 'the result'.
I eventually learned to do the calculations with an invisible and/or
offscreen card. BTW the reason I wanted the formattedWidth is as part
of a complex calculation of what will fit on a printed page and - in
the case of the width - not go past a tab already set (the
formattedHeight is also pressed into service to check the total
vertical space on the page, as you can imagine). The issue is that I
want to investigate the width and height of a text before adding it
to the page, to prevent overrunning of the available page area. In
fact the user probably won't see even the final page except as a
printout. RR could make some of this a lot easier if revPrintText
worked as advertised. I am a long-term critic of Rev's printing
features - see also BZ 1619. But I live in hope.
Graham
------------------------------------------------------------------------
---
Graham Samuel / The Living Fossil Co. / UK and France
More information about the use-livecode
mailing list