Question about wordOffset
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Question about wordOffset
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
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
- Attachments
-
- wordOffset.zip
- wordOffset
- (823 Bytes) Downloaded 178 times
Last edited by Jellobus on Fri Sep 12, 2014 6:09 pm, edited 1 time in total.
-
- VIP Livecode Opensource Backer
- Posts: 3901
- Joined: Sat Mar 24, 2007 2:54 am
- Location: Palo Alto
Re: Question about wordOffset
Great sample!
Here you go:
that words-to-skip always messes with me.
Mind you that makes italics out of any word that contains "title'
Simon
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
Mind you that makes italics out of any word that contains "title'
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Question about wordOffset
Wow Thanks Simon!!
-
- VIP Livecode Opensource Backer
- Posts: 4003
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: Question about wordOffset
Hi Louis,
try this:
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
The bad news is that currently 6.7RC1 and 7.0RC1 do not work with "italic". Probably a bug.
Kind regards
Bernd
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
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
Kind regards
Bernd
Re: Question about wordOffset
Thanks Bernd,... is that currently 6.7RC1 and 7.0RC1 do not work with "italic". Probably a bug.
I am doing massive html translation with LC7 and you saved me a lot of time
with this information
Freundliche Grüsse
Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
Re: Question about wordOffset
Hi,
I found somewhere this function :
(sorry I can't remember where...)
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.
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
and then loop the resulting list. Could be easier to write if you have a lot of formatting to do.
-
- VIP Livecode Opensource Backer
- Posts: 4003
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: Question about wordOffset
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?
Kind regards
Bernd
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?
is this on a famous book from centuries ago?I am doing massive html translation with LC7
Kind regards
Bernd
Re: Question about wordOffset
I've noticed this doesn't workbn 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?
and put aside some notes to work on it later.
Seems that I will have nothing to do.
Well, even a bit older I guess..is this on a famous book from centuries ago?
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
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
-
- VIP Livecode Opensource Backer
- Posts: 4003
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: Question about wordOffset
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:
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
I just looked up Quality Control Center and there is a bug report from Colin Holgate regarding italic
Bug 13392
Mark Waddingham answered:
and further downI 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).
I should have looked this up earlier.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.
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
Thanks Bernd for this useful information!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 just tried on my Mac and these fonts work with italicizeI suspect this is to do with the font you are using.
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.
Regards,
Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!