save file without window?

Home Forums General Programming save file without window?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #69217
    Possemo
    Participant
      • Topics: 14
      • Replies: 638
      • Total: 652
      • ★★★

      how do you save a file to disk, to for example:

      fileToWrite = utils.saveFileWindow(“Save content as data”,File.getSpecialLocation(File.userHomeDirectory),”*.bin”,true)

      but “quiet” without the FileWindow and with a defined filename? I think I saw this somewhere in a panel but I don’t remember which one it was.

      #69219
      Possemo
      Participant
        • Topics: 14
        • Replies: 638
        • Total: 652
        • ★★★

        I tried this but it does nothing. It don’t gives an error either:

        function saveit()

        getPanelValues()
        PatchDatas=table.concat(PatchDataValuesTable,” “,1,279)

        dataToWrite=MemoryBlock(PatchDatas)

        fileToWrite = File(“c:\\myfile.syx”)
        fileToWrite:create()
        fileToWrite:replaceWithData(dataToWrite)

        end

        #69228
        Possemo
        Participant
          • Topics: 14
          • Replies: 638
          • Total: 652
          • ★★★

          I found out a way that works:

          path = “C:\eclipse”
          fileToWrite = File(path..”/”..”init.ini”)
          fileToWrite:create()
          fileToWrite:replaceWithData(dataToWrite)

          For some reason it won’t work with path = “C:\test” and a rootdir like “C:\” won’t work either. Moreover, fileToWrite = File(“C:\eclipse”..”/”..”init.ini”) is not working too. You have to define a variable for “C:\eclipse”.

          That’s it.

          #69456
          goodweather
          Participant
            • Topics: 45
            • Replies: 550
            • Total: 595
            • ★★★

            Hi Possemo, is the create() line really needed?
            Looking in Juce API doc, the File() function is doing the creation of the file object (fileToWrite) if what you have within () is a valid full path…
            https://www.juce.com/doc/classFile#ab803ce7daf2eb1194a562a7912d96967
            Did you try without?

            #69457
            Possemo
            Participant
              • Topics: 14
              • Replies: 638
              • Total: 652
              • ★★★

              yes I guess you are right. create() may be superfluous.

            Viewing 5 posts - 1 through 5 (of 5 total)
            • The forum ‘Programming’ is closed to new topics and replies.
            There is currently 0 users and 101 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