<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto">Hello Emile,<div><br></div><div>I wrote a similar script, maybe it‘s of some use:</div><div><br></div><div><a href="https://forum.makemusic.com/default.aspx?f=11&m=474054">https://forum.makemusic.com/default.aspx?f=11&m=474054</a></div><div><br></div><div>Best,</div><div><br></div><div>Harald</div><div><br><br><div dir="ltr"><div><span style="background-color: rgba(255, 255, 255, 0);">-- </span></div><div><span style="background-color: rgba(255, 255, 255, 0);">___________________________________<br>Harald Schollmeyer<br><a href="x-apple-data-detectors://28/1" dir="ltr" x-apple-data-detectors="true" x-apple-data-detectors-type="address" x-apple-data-detectors-result="28/1" style="-webkit-text-decoration-color: rgba(0, 0, 0, 0.258824);">Wesmarstr. 3a, 45659 Recklinghausen</a><br>Telefon: <a href="tel:+4923614879188" dir="ltr" x-apple-data-detectors="true" x-apple-data-detectors-type="telephone" x-apple-data-detectors-result="28/2" style="-webkit-text-decoration-color: rgba(0, 0, 0, 0.258824);">+4923614879188</a> und <a href="tel:+491773125084" dir="ltr" x-apple-data-detectors="true" x-apple-data-detectors-type="telephone" x-apple-data-detectors-result="28/3" style="-webkit-text-decoration-color: rgba(0, 0, 0, 0.258824);">+491773125084</a><br>E-Mail: <a href="mailto:hschollm@gmx.net" dir="ltr" x-apple-data-detectors="true" x-apple-data-detectors-type="link" x-apple-data-detectors-result="28/4" style="-webkit-text-decoration-color: rgba(0, 0, 0, 0.258824);">hschollm@gmx.net</a></span></div></div><div dir="ltr"><br><blockquote type="cite">Am 16.09.2020 um 13:49 schrieb Emile Meuffels <e.meuffels@gmail.com>:<br><br></blockquote></div><blockquote type="cite"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi all,<div><br></div><div>I am trying to write a program which calculates the slide positions for a trombone and calculates the total slide length for the selected notes. As there are some notes with alternative positions, I want to create a table where each row has a possible combination of positions. In column 0 there will be the total slide length per row, so I can find the combination with the smallest total slide length.</div><div>If there is an alternative position possible for a note, it creates new rows and copies the previous values. But for some reason, when I try to copy a cell in the next for-loop, that value is always nil, although it was filled in the previous loop...</div><div> </div><div>I am a total newbie to Lua and to some degree to programming in general, so I might not be doing this the most elegant way, but if I insert some print lines, the program does everything I want. So ugly as it might be, it works, it just doesn't seem to remember the values...</div><div><br></div><div>I have added the relevant code under this message. Any suggestions are appreciated!</div><div><br></div><div>All the best,</div><div><br></div><div>Emile</div><div><br></div><div><div>column = 1</div><div>totallength = 0</div><div>i = 1</div><div>c = 1</div><div>imax = 1</div><div>k = 1</div><div>for entry in eachentrysaved(finenv.Region()) do</div><div>    local highestnote = entry:CalcHighestNote(nil)</div><div>    if highestnote then</div><div>        midi = highestnote:CalcMIDIKey()</div><div>                -- the slide position is calculated, deleted here for clarity</div><div>                for i= 1, imax do</div><div>                    table[i]={}</div><div>                    table[i][c] = position</div><div>                    -- the slide length is calculated, deleted here for clarity</div><div>                    table[i][0] = totallength</div><div>                end</div><div><br></div><div>                if Alternation(midi) then -- determines if there is an alternative position</div><div>                    for k = imax+1, imax*2 do -- new rows are being created</div><div>                        table[k]={}</div><div>                        for d = 1, c-1 do -- and the input of the last rows is copied</div><div>                            table[k][d] = table[k-imax][d] -- this should copy the value of the previous rows to the new rows, but it always give a nil value...</div><div>                        end</div><div>                        -- the alternative position is calculated, deleted for clarity</div><div>                        table[k][c]= position -- here the new value is added</div><div>                        -- and the new length is calculated, deleted for clarity</div><div>                        table[trumpet][k][0] = totallength</div><div>                    end</div><div>                    imax = imax*2</div><div>                end</div><div>        end</div><div>    c = c + 1 -- end</div><div>end</div></div></div></div></div>
<span>_______________________________________________</span><br><span>JWLua mailing list</span><br><span>JWLua@jwmusic.nu</span><br><span>http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu</span><br></div></blockquote></div></body></html>