Lua stack traceback

!!! 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.
In the case of pictures that are attached to the article, the source must also be stated. This also applies to your own pictures, which were taken by you. Pictures without source information will be deleted!
  • Hi,


    Let's make your code easier to debug.


    Suppose we have the next code:



    This will generate the following error message:


    Error running function 'EEPMain': [string "EEP Script"]:6: attempt to perform arithmetic on a string value (local 'seconds')


    This will give us information about where the program failed (in function 'TimeString'), but not who caused it ('EEPMain').

    To be able to debug our program easier, we would like to have information about the stack traceback.

    The Lua function xpcall makes this possible:



    This will generate the following error message:


    Error running function 'EEPMain': [string "EEP Script"]:26: [string "EEP Script"]:6: attempt to perform arithmetic on a string value (local 'seconds')

    stack traceback:

    [string "EEP Script"]:6: in function <[string "EEP Script"]:1>

    [C]: in function 'xpcall'

    [string "EEP Script"]:17: in upvalue 'Execute'

    [string "EEP Script"]:26: in function 'EEPMain'


    Now with the calling function ('EEPMain')


    Nice, isn't it.

    Windows 10 Pro 64bit

    Intel i9 9900k 8 cores @ 3.6 GHz, 32GB RAM

    NVidia GeForce RTX 2080 Ti 11GB

    Started in 2017 with EEP13, now using EEP17 (LUA expert)


    Groeten, Peter Nelissen :af_1:

    The post was edited 2 times, last by OmeNelis ().