Announcement

Collapse
No announcement yet.

Pleassse helpp :( Just one minute from your time

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Pleassse helpp :( Just one minute from your time

    I made a kinda notepad that you can change the font properties, i finished coding that when you click save the application save the text on the input as a value and load it even if you closed the app, but i need to save the input props as a value , i tried several codes but didn't work idk how there it is

    On Click (Button1)
    Code:
    -- save input props
    cac = Input.GetProperties("Input1")
    tProperties = Application.SaveValue("tProperties", "tProps", cac);
    On Preload
    Code:
     -- load input props
    props = Application.LoadValue("tProperties", "tProps");
    if (Application.GetLastError() == 0) then
     Input.SetProperties("Input1", props)
     end

  • #2
    The result of Input.GetProperties is a table, however Application.SaveValue expects a string as value. There are several ways you could do this:

    - Store every single key in the properties table separately
    - Serialize the table into some format of string (json / xml) and save that result
    - Don't use Application.SaveValue, but the INIFile functions to create a config file. Application.SaveValue uses the registry

    You cannot simply save 'cac' with Application.SaveValue, 'cac' is a table containing a lot of values:
    Code:
    Debug.ShowWindow();
    for key, value in pairs(cac) do 
      Debug.Print(tostring(key).." = "..tostring(value).."\r\n");
    end
    Bas Groothedde
    Imagine Programming :: Blog

    AMS8 Plugins
    IMXLH Compiler

    Comment


    • #3
      Originally posted by Imagine Programming View Post
      The result of Input.GetProperties is a table, however Application.SaveValue expects a string as value. There are several ways you could do this:

      - Store every single key in the properties table separately
      - Serialize the table into some format of string (json / xml) and save that result
      - Don't use Application.SaveValue, but the INIFile functions to create a config file. Application.SaveValue uses the registry

      You cannot simply save 'cac' with Application.SaveValue, 'cac' is a table containing a lot of values:
      Code:
      Debug.ShowWindow();
      for key, value in pairs(cac) do
      Debug.Print(tostring(key).." = "..tostring(value).."\r\n");
      end
      How to load it?

      Comment


      • #4
        What do you mean how to load it? How do you save it?
        Bas Groothedde
        Imagine Programming :: Blog

        AMS8 Plugins
        IMXLH Compiler

        Comment


        • #5
          Bffffff,, please, sry for that , i mean i want to save the properties of the input as an application value or anything when the user clicks the (SAVE) Button, and when he close the program, and open it again the on preload/show command that load the input properties on the input like it's bold or not, italic or not, size, color, the command fire up when he open the program

          Comment


          • #6
            Originally posted by ItzMagdy View Post
            Bffffff,, please, sry for that , i mean i want to save the properties of the input as an application value or anything when the user clicks the (SAVE) Button, and when he close the program, and open it again the on preload/show command that load the input properties on the input like it's bold or not, italic or not, size, color, the command fire up when he open the program
            Yes I know what you're asking for, see my initial response. You have to iterate through the properties table and save each pair if you want to use Application.SaveValue. Then when you load it, you have to determine which keys to load yourself or use the Registry functions to enumerate the keys.

            That's why I said that maybe using an INI file is more flexible. You can then just store the keys to a file and later enumerate all the keys in a section.
            Bas Groothedde
            Imagine Programming :: Blog

            AMS8 Plugins
            IMXLH Compiler

            Comment


            • #7
              Originally posted by Imagine Programming View Post

              Yes I know what you're asking for, see my initial response. You have to iterate through the properties table and save each pair if you want to use Application.SaveValue. Then when you load it, you have to determine which keys to load yourself or use the Registry functions to enumerate the keys.

              That's why I said that maybe using an INI file is more flexible. You can then just store the keys to a file and later enumerate all the keys in a section.
              I give up, i am such an idiot, thanks for your help ^^

              Comment


              • #8
                Originally posted by ItzMagdy View Post

                I give up, i am such an idiot, thanks for your help ^^
                Don't give up, just take it slow. Read about Lua tables, and read about 'for key, value in pairs(tableVariable) do' and see what you can do. Never give up
                Bas Groothedde
                Imagine Programming :: Blog

                AMS8 Plugins
                IMXLH Compiler

                Comment


                • #9
                  Originally posted by Imagine Programming View Post

                  Don't give up, just take it slow. Read about Lua tables, and read about 'for key, value in pairs(tableVariable) do' and see what you can do. Never give up
                  Oh okay i gonna check it out, thanks

                  Comment


                  • #10
                    Here's a very extended example using MemoryEx. This example can be used to save a table in many formats, because it is using (somewhat, not quite, because it's iterative) a decorator pattern. It also includes an LH module for a ChooseColor and ChooseFont dialog. See the code in Globals, On Show and On Click of each button.

                    The included storage providers for the PersistentTable class: INIStorageProvider, MemoryStorageProvider, BinaryFileStorageProvider, JSONStorageProvider

                    In the example the JSONStorageProvider and BinaryFileStorageProvider are used to save the properties of Input1 to a json file. You could also replace JSONStorageProvider with MemoryStorageProvider and save to a .bin file. You could use only one provider as well, INIStorageProvider. Aside from that, you can extend the functionality by invoking StorageProvider:Extend

                    Anyhow, in before I'm going to enlist full documentation here; see if the example does what you want.
                    Attached Files
                    Bas Groothedde
                    Imagine Programming :: Blog

                    AMS8 Plugins
                    IMXLH Compiler

                    Comment


                    • #11
                      Originally posted by Imagine Programming View Post
                      Here's a very extended example using MemoryEx. This example can be used to save a table in many formats, because it is using (somewhat, not quite, because it's iterative) a decorator pattern. It also includes an LH module for a ChooseColor and ChooseFont dialog. See the code in Globals, On Show and On Click of each button.

                      The included storage providers for the PersistentTable class: INIStorageProvider, MemoryStorageProvider, BinaryFileStorageProvider, JSONStorageProvider

                      In the example the JSONStorageProvider and BinaryFileStorageProvider are used to save the properties of Input1 to a json file. You could also replace JSONStorageProvider with MemoryStorageProvider and save to a .bin file. You could use only one provider as well, INIStorageProvider. Aside from that, you can extend the functionality by invoking StorageProvider:Extend

                      Anyhow, in before I'm going to enlist full documentation here; see if the example does what you want.
                      You are wow
                      Thank you very much, ♥ i am really appreciated, i can't thank you enough for that
                      you are a life saver thanks

                      Comment


                      • #12
                        Originally posted by Imagine Programming View Post
                        Here's a very extended example using MemoryEx. This example can be used to save a table in many formats, because it is using (somewhat, not quite, because it's iterative) a decorator pattern. It also includes an LH module for a ChooseColor and ChooseFont dialog. See the code in Globals, On Show and On Click of each button.

                        The included storage providers for the PersistentTable class: INIStorageProvider, MemoryStorageProvider, BinaryFileStorageProvider, JSONStorageProvider

                        In the example the JSONStorageProvider and BinaryFileStorageProvider are used to save the properties of Input1 to a json file. You could also replace JSONStorageProvider with MemoryStorageProvider and save to a .bin file. You could use only one provider as well, INIStorageProvider. Aside from that, you can extend the functionality by invoking StorageProvider:Extend

                        Anyhow, in before I'm going to enlist full documentation here; see if the example does what you want.
                        But sorry there's a problem, your project worked and it's memoryex plugin worked but on my project nuthin work, i coppied the global function codes, the other codes, the input1-settings.json file, and the plugin file and the docs files and it says memoryex plugin is missing or a nil value, i reinstalled the plugin, and still not working

                        Comment


                        • #13
                          Please share the project with the problem, so I can help you out. The best way of adding a plugin is using the Action Plugins dialog
                          Bas Groothedde
                          Imagine Programming :: Blog

                          AMS8 Plugins
                          IMXLH Compiler

                          Comment


                          • #14
                            Originally posted by Imagine Programming View Post
                            Please share the project with the problem, so I can help you out. The best way of adding a plugin is using the Action Plugins dialog
                            :') ♥
                            Thanks very much

                            Comment


                            • #15
                              Originally posted by Imagine Programming View Post
                              Here's a very extended example using MemoryEx. This example can be used to save a table in many formats, because it is using (somewhat, not quite, because it's iterative) a decorator pattern. It also includes an LH module for a ChooseColor and ChooseFont dialog. See the code in Globals, On Show and On Click of each button...
                              .
                              You weren't kidding when you said you aimed to demonstrate the versatility of MemoryEx! Nicely done, sensei! Awesome as ever. This one's going straight to the poolroom.

                              PS.
                              Didn't know you were a Simon & Garfunkel fan.
                              .....................

                              @IItzMagdy
                              You'll get help and feedback considerably faster if you start uploading the project.apz when you encounter these kinds of problems.

                              Comment

                              Working...
                              X