Nested numeric lists that include number of parent list item

Niggemann, Bernd Bernd.Niggemann at uni-wh.de
Tue Feb 11 20:10:32 EST 2020


I am not aware that listStyle decimal can show other then 1. No further sub numbering.

However one could hack it. Although I know you are not particularly fond of those hacks...

The code assumes that the listStyle of a field is set (any) will be "skip" afterwards and list depth is also set.


----------------------------------
on mouseUp
   local tDepthValue, tTab, tDepth, tLastDepthValue
   local tIndex, tLeadingSpaces
   lock screen
   put space & space into tLeadingSpaces
   put numToCodePoint(9) into tTab -- not used

   put 0 into tDepthValue
   put 0 into tLastDepthValue

   set the listStyle of line 1 to -1 of field 1 to "skip"

   repeat with i = 1 to the number of lines of field 1
      if line i of field 1 is empty then next repeat
      put the listDepth of line i of field 1 into tDepth
      add 1 to item tDepth of tDepthValue
      if tDepth < the number of items of tLastDepthValue then
         delete item tDepth + 1 to -1 of tDepthValue
      end if
      put tDepthValue into tIndex
      replace comma with "." in tIndex
      put "." after tIndex
      put tIndex & tLeadingSpaces before line i of field 1
      put tDepthValue into tLastDepthValue
   end repeat
end mouseUp
------------------------------------

to remove the hack

---------------------------------
on mouseUp
   set the itemDelimiter to "." & space & space
   lock screen
   repeat with i = 1 to the number of lines of field 1
      if the number of items of line i of field 1 > 1 then
         delete item 1 of line i of field 1
      end if
   end repeat
   unlock screen
end mouseUp
---------------------------------

It prepends the text with a decimal index. I started with tab as separator but it does not look well. Now it is two spaces. One could use non-breaking spaces as separators.

Kind regards
Bernd



>Trevor wrote


>I would like to get the following output but I'm not seeing a property that
>enables it. Am I missing something or is not possible using listStyle and
>listDepth?

>1. asdf ajsdf asf
>       1.1. adsfasdfasdf
>              1.1.1. asdfasdfasdf





More information about the use-livecode mailing list