Numbering of lines in a field

Mark Schonewille m.schonewille at economy-x-talk.com
Mon Apr 28 07:49:37 EDT 2014


Hi Charles,

What does "without any success" mean exactly" Do you get wrong results? 
No result at all? Do you get any error messages?

I have made a very tiny change to the script by adding a cr after 
myNewLines every time a line is added:

constant dot = "."
function lineNumbering theLines
   put 0 into myCounter
   repeat for each line myLine in theLines
     if "CHC" is word 1 of myLine then
       put 0 into myCounter
       put myLine & cr after myNewLines
     else
       add 1 to myCounter
       put myCounter & dot && myLine & cr after myNewLines
     end if
   end repeat
   return char 1 to -2 of myNewLines
end lineNumbering

I put this function at card or stack level and create a new field with 
some data like

chc
sdfdf
dsfdsf
dfds
chc
sdfdsfds
fdsfds
fdsfdsf
dsfds
chc
sfdsf
dsfdsf
dsfdsf
dsfdsf
dsfdsf
ds
chc

I type

   put lineNumbering(fld 1)

in the message box and get the following result:

chc
1. sdfdf
2. dsfdsf
3. dfds
chc
1. sdfdsfds
2. fdsfds
3. fdsfdsf
4. dsfds
chc
1. sfdsf
2. dsfdsf
3. dsfdsf
4. dsfdsf
5. dsfdsf
6. ds
chc

Isn't that what you want?

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
KvK: 50277553

Installer Maker for LiveCode:
http://qery.us/468

Buy my new book "Programming LiveCode for the Real Beginner" 
http://qery.us/3fi

LiveCode on Facebook:
https://www.facebook.com/groups/runrev/

On 4/28/2014 13:35, Charles Szasz wrote:

> Mark,
>
> I greatly appreciate your script suggestion!!  However, I spent several hours trying to implement your function without any success. The lines I want to number are in the scrolling field “recommendations”.    Can you provide me with more information on how to implement this script?
>
> Charles Szasz
> cszasz at mac.com




More information about the Use-livecode mailing list