Lua create/read/write file

Home Forums General Programming Lua create/read/write file

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #22827
    angus
    Participant
      • Topics: 1
      • Replies: 1
      • Total: 2

      Hello,

      First of all, I want to say that I am new here, I have been using Ctrlr for a few months and this is my first comment in this forum. I would like to congratule the developers on their work and also all the people participating on this forum, through which I have been able to solve many of my doubts and problems about programming.

      I am now finishing one panel, but I am unable to implement the last functionality for it, that is creating presets.
      The panel controls a reverb processor. The reverb algorithm is composed of a number of parameters that are controlled by the panel. What I am trying to do is to save and load presets (the current value of the parameters in the panel), to make the users able to store their favorite algorithm´s configurations.

      When using the panel, I store the values of the parameters in a table (array), so that the table contains all the values of the modulators that represent the parameters. (when a modulator changes its value, the table is updated).

      Thus, I have thought that the best way to achieve this is to create an external file for each preset in which the table will be saved. A preset would be loading the panel with a particular table (values for the parameters)

      My question is, how to create a file from a lua method, and how to read/write on it? I need a method in which a .txt (for example) file is created and written with the current table, and another one in which an existing file is read in order to update panel´s data.

      I would be very grateful if anyone could help me with particular code to write/read/create a txt file from a lua method. Also, giving some examples of other panels doing this or suggestions about how to achieve it would be a great help.

      Thank you!

      #22906
      atom
      Keymaster
        • Topics: 159
        • Replies: 2945
        • Total: 3104
        • ★★★★★

        There is a DEMO panel called DEMO – Files (it should be installed in the Ctrlr installation directory) it demonstrates how to read/write files.

        If everything fails you should be able to use native lua calls to do file I/O, consult the Lua manual for that http://www.lua.org/pil/21.1.html

        #22931
        angus
        Participant
          • Topics: 1
          • Replies: 1
          • Total: 2

          Ok I hadn´t seen that demo panel, I think that´s all I need.

          Thank you Atom

        Viewing 3 posts - 1 through 3 (of 3 total)
        • The forum ‘Programming’ is closed to new topics and replies.
        There is currently 0 users and 62 guests online
        No users are currently active
        Forum Statistics
        Threads: 2,495, Posts: 17,374, Members: 77,605
        Most users ever online was 12 on January 22, 2019 3:47 pm
        Ctrlr