repeat loop and formatting question

Mark Swindell mdswindell at cruzio.com
Mon Nov 17 22:20:38 EST 2008


Yes, this is a much more efficient direction to take things.  Given  
over 90 different digraphs and blends, it's a lot less code than I was  
using.

  Thanks.
Mark

On Nov 17, 2008, at 8:41 AM, Robert Brenstein wrote:

>> Actually, you can type less by eliminating the <font> tags:
>>
>> put fld 1 into tText
>> replace "ck" with "<b>ck</b>" in tText
>> replace "ch" with "<b>ch</b>" in tText
>> replace "oa" with "<u>ch</u>" in tText
>> replace "oo" with "<u>oo</u>" in tText
>>
>
> Or in a more generic way -- more code but easier to maintain
>
> put fld 1 into tText
> set the caseSensitive to true
> put "ck ch" into vChunksToBold
> repeat for each word w in vChunksToBold
>  replace w with "<b>" & w & "</b>" in tText
> end repeat
> put "ch oo" into vChunksToUnderline
> repeat for each word w in vChunksToUnderline
>  replace w with "<u>" & w & "</u>" in tText
> end repeat
> set the caseSensitive to false
> put tText into fld 1
>
> And if think you may need more style in the future, even more  
> generic way would be to use an array
>
> put fld 1 into tText
> set the caseSensitive to true
> put "ck ch" into vChunksToMark["b"] --  bolds
> put "ch oo" into vChunksToMark["u"] --  underlines
> repeat for each line k in the keys of vChunksToMark
>  put "<" & k & ">" into vMarkBeg
>  put "</" & k & ">" into vMarkEnd
>  repeat for each word w in vChunksToMark[k]
>    replace w with vMarkBeg & w & vMarkEnd in tText
>  end repeat
> end repeat
> set the caseSensitive to false
> put tText into fld 1
>
> Robert
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution




More information about the use-livecode mailing list