Must be doing something obvious wrong. As usual! I want to go through a
field and format lines depending on what they start with.
So to begin with I try the following, which works just fine, to make sure the
lines are being found and picked up:
set the itemDelimiter to
repeat for each
Bonsoir Peter,
Don't know if it will help, but:
Many times, it appears more efficient to set 'char 1 to -1 of line
line number to style
So, in your case:
local tNum, tText
-
lock screen
put 0 into tNum
put field test of stack Calendar into tText
repeat for each line tLine in tText
if
Happy New Year Peter,
I change this so as to do the formatting as follows:
set the itemDelimiter to
repeat for each line theLine in field test of stack Calendar
if item 1 of theLine is Sunday then
set the textStyle of theLine to bold
end if
end repeat
and get the error
Message execution
Peter, in the repeat for each structure, the loop variable -
theLine - is just that, a variable, so when you try to format it,
nothing happens to the line in the field of which it's a copy (and
you get an error, because you can't format text in a variable this
way, and in any case, you
Sorry Peter,
Try:
set the textStyle of line theLine of field test to bold
I forgot this was a repeat for each :-[
Try
set the itemDelimiter to
put 0 into lineCount
repeat for each line theLine in field test of stack Calendar
add 1 to lineCount
if item 1 of theLine is Sunday
When using repeat for each x in y you MUST consider each of the referenced
items (x and y) to be read only.
From the docs:
---
Important! In any of the for each loops, you should not change the
labelVariable or container in a statement inside the loop. Doing so will not
cause a script error,
I did not notice that ;-)
That's the main point.
Of course!
Le 2 janv. 09 à 18:40, Bill Marriott a écrit :
Additionally, you are trying to set the style of a variable, which
would
have no effect.
Best regards from Paris,
Eric Chatonet.
Ignoring all the other serious issues, I noticed :
Rob Cozens wrote:
I change this so as to do the formatting as follows:
set the itemDelimiter to
repeat for each line theLine in field test of stack Calendar
if item 1 of theLine is Sunday then
set the textStyle of theLine to bold
end if
Thanks so much for your help everyone! And Happy New Year to all. And
thanks not just for this, but for your continued willingness to help not
just me but other enquirers.
Peter
--
View this message in context:
http://www.nabble.com/conditional-formatting%2C-how-to-do-it-tp21253906p21262790