Lua function returning a table as a nice formatted string

!!! Please ensure, that your contribution or question is placed into the relevant section !!!
Questions about rolling stock, for example, do not belong in "Questions about the Forum". Following is perhaps the right area where your question will be better looked after:
General questions to EEP , Splines, rolling stock, Structures in EEP, landscape elements, Signalling system and controlling, designers, Europe-wide EEP meetings , Gossip
Your cooperation to keep the forum clear is appreciated.
  • Hi,

    I created a function to return a table as a nice formatted string.

    I also included an iterator to sort the table.

    Windows 10 Pro 64bit, Intel i9 9900k 8 cores @ 3.6 GHz, 32GB RAM, NVidia GeForce RTX 20280 Ti 11GB

    McAfee Internet Security 16.0 / SecurityCenter 18.5

    Started in 2017 with EEP13, now using EEP16

    Groeten, Peter Nelissen :af_1:

    The post was edited 1 time, last by icke: edit to lua script ().

  • Hi Peter,

    I did something similar and showed the code in several messages starting here. The main differences to your code are:

    • I didn't worry about sorting.
    • I cared about re-creating the table from its textual representation.
    • And some more detailled stuff.

    By reading your source code, I expect some problems (not tested):

    • What, if a string itself contains an apostrophe?
    • What, if a table references itself (directly or indirectly)? Minimalistic example: a = {}; a[1] = a;
    • Tha name of your parameter full is somewhat misleading. sorted might be a better name?

    Nevertheless, a good start.



    PC: Intel i7-7700K; 64bit; 4,2 GHz; 32GB RAM; GeForce GTX 1080 (8 GB); Win 10; EEP 6, 13.2 Plugins 1+2, 14.1 (Dev), 15 (Dev); HomeNOS 14 (Dev)
    Laptop: Intel i5 3230M; 64bit; 2,6 GHz; 8GB RAM; GeForce GT740M (1 GB); Win 8.1; EEP 6, 13.2 Plugins 1+2; HomeNOS 13 (User)