Page 1 of 1
Question about wordOffset
Posted: Fri Sep 12, 2014 4:58 am
by Jellobus
Hi All,
I have a word in the field to make it "italic". I used wordOffset function. Number of the "TITLES" constantly change in the field and all "TITLES" must be in italic.
I found that wordOffset returns only first value of "TITLES" but not second and third "TITLES" in the field. And what if there are 10 "TITLES" in the field? I need your advice.

Please see attached stack file.
Thanks in advance,
Louis
Re: Question about wordOffset
Posted: Fri Sep 12, 2014 7:15 am
by Simon
Great sample!
Here you go:
Code: Select all
repeat with x = 1 to the number of words in fld "text"
put wordoffset("title",field "text", tTitle) into title1
set the textstyle of word title1+ tTitle of field "text" to "italic"
put title1 + tTitle into tTitle
end repeat
that words-to-skip always messes with me.
Mind you that makes italics out of any word that contains "title'
Simon
Re: Question about wordOffset
Posted: Fri Sep 12, 2014 8:32 am
by Jellobus
Wow Thanks Simon!!

Re: Question about wordOffset
Posted: Fri Sep 12, 2014 8:59 am
by bn
Hi Louis,
try this:
Code: Select all
on mouseUp
put 0 into tWordOffset
put 0 into tLastWordFound
set the caseSensitive to true
lock screen
repeat
put wordOffset("TITLE",field "text",tLastWordFound) into tWordOffset
if tWordOffset = 0 then -- no more found, exit but change last word found.
set the textStyle of word tLastWordFound of field "text" to "italic"
exit repeat
end if
set the textStyle of word tLastWordFound of field "text" to "italic"
add tWordOffset to tLastWordFound
end repeat
unlock screen
end mouseUp
BUT it will also italicize TITLE in your comment.
To achieve what your are after I would need to understand better what "TITLE" is. Apparently you know the complete title and the title is on a line on its own.
then you can use lineOffset
Code: Select all
on mouseUp
put "TITLE1,TITLE2" into tTitleList
set the caseSensitive to true
lock screen
repeat for each item aTitle in tTitleLIst
put 0 into tLineOffset
put 0 into tLastLIneFound
repeat
put lineOffset(aTitle,field "text",tLastLIneFound) into tLineOffset
if tLineOffset = 0 then -- no more found, exit but change last line found.
set the textStyle of line tLastLIneFound of field "text" to "italic"
exit repeat
end if
set the textStyle of line tLastLIneFound of field "text" to "italic"
add tLineOffset to tLastLIneFound
end repeat
end repeat
unlock screen
end mouseUp
The bad news is that currently 6.7RC1 and 7.0RC1 do not work with "italic". Probably a bug.
Kind regards
Bernd
Re: Question about wordOffset
Posted: Fri Sep 12, 2014 9:17 am
by Thierry
... is that currently 6.7RC1 and 7.0RC1 do not work with "italic". Probably a bug.
Thanks Bernd,
I am doing massive html translation with LC7 and you saved me a lot of time
with this information
Freundliche GrĂ¼sse
Thierry
Re: Question about wordOffset
Posted: Fri Sep 12, 2014 9:30 am
by FredBeck
Hi,
I found somewhere this function :
(sorry I can't remember where...)
Code: Select all
function FullOffset pWord pText
local tList
local tOffset
repeat while tOffset <the number of words in pText
get wordOffset(pWord, pText, tOffset)
if it <> 0 then
add it to tOffset
put tOffset & cr after tList
else
exit repeat
end if
end repeat
return tList
end FullOffset
so you can just paste it in your main stack script (or a library stack) and use it in place of wordOffset
and then loop the resulting list. Could be easier to write if you have a lot of formatting to do.
Re: Question about wordOffset
Posted: Fri Sep 12, 2014 10:22 am
by bn
Hi Thierry,
I can not get italicize to work in 7.0 at all, not even when setting the htmlText. Only when using a font that is italic.
I don't know if it is a bug or has to do with the new font handling. Maybe if a font has no italic variant it will not work?
I am doing massive html translation with LC7
is this on a famous book from centuries ago?
Kind regards
Bernd
Re: Question about wordOffset
Posted: Fri Sep 12, 2014 10:37 am
by Thierry
bn wrote:Hi Thierry,
I can not get italicize to work in 7.0 at all,
not even when setting the htmlText. Only when using a font that is italic.
I don't know if it is a bug or has to do with the new font handling.
Maybe if a font has no italic variant it will not work?
I've noticed this doesn't work
and put aside some notes to work on it later.
Seems that I will have nothing to do.
is this on a famous book from centuries ago?
Well, even a bit older I guess..
Now, I'm doing some hard regex to deal with
right to left language injected in a left to right one..
By the way,
KUDOS to LC7 Unicode runrev developers
Regards,
Thierry
Re: Question about wordOffset
Posted: Fri Sep 12, 2014 11:04 am
by bn
Hi Thierry and all,
I just looked up Quality Control Center and there is a bug report from Colin Holgate regarding italic
Bug 13392
Mark Waddingham answered:
I suspect this is to do with the font you are using.
We've upgraded Mac to use CoreText which doesn't support synthesized text styles unlike QuickDraw did.
The default Mac interface font (Lucida Grande) does *not* have an italic variant, hence why italic has no effect. (You can see exactly the same effect in Text Edit - if you attempt to italicize that font, it has no effect, and no Italic style is listed in the font inspector).
and further down
I have changed this report to an enhancement request so that we can look into changing the way the selection of font styles is presented.
I should have looked this up earlier.
So this means that one currently has to use a font that supports italic. But which ones do?
Thierry, you can go on working once you have found a font that supports plain and italic
I just tried on my Mac and these fonts work with italicize
Courier
Garamond
Helvetica
Helvetica Neue
Lucida Sans Regular
Arial
Verdana
many others might also work but I did not try all. Just the default font on Mac "Lucida Grande" does not work with italic.
Kind regards
Bernd
Re: Question about wordOffset
Posted: Fri Sep 12, 2014 11:10 am
by Thierry
bn wrote:
I just looked up Quality Control Center and there is a bug report from Colin Holgate regarding italic
Bug 13392
Mark Waddingham answered:
I suspect this is to do with the font you are using.
I just tried on my Mac and these fonts work with italicize
Courier
Garamond
Helvetica
Helvetica Neue
Lucida Sans Regular
Arial
Verdana
many others might also work but I did not try all. Just the default font on Mac
"Lucida Grande" does not work with italic.
Thanks Bernd for this useful information!
Regards,
Thierry