User Tag List

Page 3 of 5 FirstFirst 1 2 3 4 5 LastLast
Results 21 to 30 of 44

Thread: INI ++ 1.5

  1. #21
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    CruddyBuddy's Avatar
    Join Date
    May 2010
    Posts
    154
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Jax View Post
    Is this so the INI file looks in a particular way when users or other programs view it?
    Hi Jax. Yes, this would be mostly for formatting purposes. From a scripting perspective, it really helps to be able to format an ini similarly to other coding languages for ease of use and readability. The indented subgroups is a really nice feature which helps with organization, but being able to have multi-line strings would be a huge addition. I realize it wouldn't be useful for everyone in every situation, but there are many times when it would be useful.

    Consider this example:

    CURRENT STRING USING DELIMITERS:

    [group1]
    item1=string1$string2$string3$string4$string5

    PROPOSED OPTIONAL CHANGE:

    [group1]
    item1=
    string1
    string2
    string3
    string4
    string5

    When processing this string in Fusion, one could use NewLine$ as a delimiter instead of $ (or whatever else is being used). I know it takes more space to do it this way, but it is MUCH easier to read, especially with a really long string with multiple delimiters. Combine this with tabs (which Fusion can already read from a INI++ string) and the formatting would be superb!

    I don't know exactly how much would be required in making a change like this, but something where the extension looks for an "=" or [groupname] on the next line and if it doesn't find them it knows that next line is still part of the previous line string. I would imagine an option to enable this feature would also keep existing programs from breaking, as it would have to be manually enabled.

    If this is at all possible, it would seriously be amazing.

  2. #22
    Clicker Multimedia Fusion 2 Developer
    Jax's Avatar
    Join Date
    Jul 2006
    Location
    UK
    Posts
    702
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I'm afraid I don't have my environment set up anymore to do any extension coding very easily. However, I wonder if you could do something like this:

    1. Load the file into a string (using the File object or something?)
    2. Perform a regular expression on the whole string, something like ([^=]+)=(\n[^=]*)+ , and replace each match with the matched string having a simple replacement of \n to (however you want newlines to be represented). Repeat the until there are no more to be found.
    3. Load that into the INI object

    But it feels a bit complicated and I don't really know how you'd do step 2 inside Fusion (I don't have Fusion installed anymore, I think I might have lost my copy of it. I do have Multimedia Fusion 2 installed by with no extensions). I think there was a Lua and a Python extention at some point, which feels like it could be possible to write a function in - but again, I don't have these installed.

    Sorry I can't be of more help immedaitely.

  3. #23
    Clicker Multimedia Fusion 2 Developer
    Jax's Avatar
    Join Date
    Jul 2006
    Location
    UK
    Posts
    702
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    It turns out Fusion 2.5 is free right now so I was able to download it (I swear I've bought it at some point but I can't find anything in my emails about it). Here is an example of using the Lua object to convert some text from CruddyBuddy-INI form to standard the INI form (except using escape characters too): https://drive.google.com/file/d/1xp1...ew?usp=sharing
    I haven't done the saving bit, but I think it should be easier (although probably still want to use the Lua object since it turns out the regular expression object is pro-only)

    Another thing I tried was setting the newline character to NewLine$ + NewLine$, and then, providing you are happy with two-line-spacing between everything, you can have a single new-line in your comments. That's a bit easier.

  4. #24
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    CruddyBuddy's Avatar
    Join Date
    May 2010
    Posts
    154
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Wow, this is a great reply! I'm very appreciative of your help. I've not had experience with Lua so it's all new to me, although I have the Dev version of Fusion 2.5+ so I'm not limited by extension options. Am I right in understanding that all of the Lua scripts are contained within the extension itself?

    The example you provided works for the first item with multiple lines, but if the next item has multiple lines it treats it as separate lines again rather than injecting the\n delimiter. I'm not sure if there is a parameter I can change to fix this.

    I'll try your idea to change NewLine$ to NewLine$+NewLine$ and see how that works out. Would have liked to avoid an option like this just so I didn't have to go back and change a bunch of existing scripts.

    Quote Originally Posted by Jax View Post
    It turns out Fusion 2.5 is free right now so I was able to download it (I swear I've bought it at some point but I can't find anything in my emails about it). Here is an example of using the Lua object to convert some text from CruddyBuddy-INI form to standard the INI form (except using escape characters too): https://drive.google.com/file/d/1xp1...ew?usp=sharing
    I haven't done the saving bit, but I think it should be easier (although probably still want to use the Lua object since it turns out the regular expression object is pro-only)

    Another thing I tried was setting the newline character to NewLine$ + NewLine$, and then, providing you are happy with two-line-spacing between everything, you can have a single new-line in your comments. That's a bit easier.

  5. #25
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    CruddyBuddy's Avatar
    Join Date
    May 2010
    Posts
    154
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I am thinking maybe if I can figure out how to replace all strings between two delimiters $NewLine and "=", then it could at least detect when it's truly a new item because it would recognize the "=" in the line.

  6. #26
    Clicker Multimedia Fusion 2 Developer
    Jax's Avatar
    Join Date
    Jul 2006
    Location
    UK
    Posts
    702
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Opps sorry. If you go to the Lua object and look at the script property (which is its only property) you can change it to this:

    function helper(x,y)
    return "`" .. x .. y:gsub("`","\\n") .. "`"
    end
    function fix(a)
    local b="`" .. a:gsub("\r?\n","`") .. "`"
    return b:gsub("([^=`]+%=)`([^=%[]*)`",helper):gsub("`","\r\n")
    end


    (which is identical except for a backtick on the one-from-last line, which I convinced myself was needed but actually isn't). I hadn't actually used the Lua object before, but it's pretty cool actually - although I swear the Lua pattern language doesn't do the right thing sometimes. I couldn't find the Python object in the manager.

  7. #27
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    CruddyBuddy's Avatar
    Join Date
    May 2010
    Posts
    154
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Wow! I tried it out and it works great! I realize INI++ would destroy my formatting if I tried to save back, but seeing as I use a different file for saving purposes, and I only needed in a read-only format, it works great! Thank you so much for taking the time to help me with this.

    One final question, if you don't mind, seeing as I know nothing about Lua, would you know how I could modify the script to remove TABs? Essentially I would like to format the ini like this:

    [group]
    item=
    _____thing1
    _____thing2
    _____thing3

    In this example, I'm just using underscores to simulate tabs, but in my ini I would actually be using a TAB character.

    I could probably filter the ini strings through a string replacer and just replace all (TAB)s with "" but if I'm using this nice Lua script it makes sense just to include something that removes all TABS so INI++ can read everything cleanly but I can use TABS for formatting and reading purposes.

    EDIT: You know what, I think TABs are automatically ignored, so it might not be necessary?
    EDIT2: Well, it sort of does, but if the TAB is a part of a string, which it would be in this case, the TAB is not filtered out, so I would need to have TABs removed.

    Quote Originally Posted by Jax View Post
    Opps sorry. If you go to the Lua object and look at the script property (which is its only property) you can change it to this:

    function helper(x,y)
    return "`" .. x .. y:gsub("`","\\n") .. "`"
    end
    function fix(a)
    local b="`" .. a:gsub("\r?\n","`") .. "`"
    return b:gsub("([^=`]+%=)`([^=%[]*)`",helper):gsub("`","\r\n")
    end


    (which is identical except for a backtick on the one-from-last line, which I convinced myself was needed but actually isn't). I hadn't actually used the Lua object before, but it's pretty cool actually - although I swear the Lua pattern language doesn't do the right thing sometimes. I couldn't find the Python object in the manager.

  8. #28
    Clicker Multimedia Fusion 2 Developer
    Jax's Avatar
    Join Date
    Jul 2006
    Location
    UK
    Posts
    702
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I think replacing

    return "`" .. x .. y:gsub("`","\\n") .. "`"

    with

    return "`" .. x .. y:gsub("`","\\n"):gsub("\t","") .. "`"

    will do - unless you only want to remove tabs at start of lines but still allow them inside. If that's the case, then:

    return "`" .. x .. y:gsub("`\t*","\\n"):gsub("^\t*","") .. "`"

    Should do it, at the cost of being a little more complex.

    This Lua object is actually really cool. Good work Donald May (is that Vortex2?)

    [Edit 1: Actually in the latter case, merely return "`" .. x .. y:gsub("`\t*","\\n") .. "`" should work for the reason you previously mentioned about white-space being ignored)]
    [Edit 2: Forgot to actually change the code in Edit 1]

  9. #29
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    CruddyBuddy's Avatar
    Join Date
    May 2010
    Posts
    154
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Yes, that did the trick! Wow, amazing help! And yeah, I didn't know Lua could do all of this (well, I didn't even know what Lua was). I might need to delve deeper into this scripting. It could cut back on some of the extra work I have to do to get certain elements to play nicely with my ini files.

    Thank you again so much for your help!

    Quote Originally Posted by Jax View Post
    I think replacing

    return "`" .. x .. y:gsub("`","\\n") .. "`"

    with

    return "`" .. x .. y:gsub("`","\\n"):gsub("\t","") .. "`"

    will do - unless you only want to remove tabs at start of lines but still allow them inside. If that's the case, then:

    return "`" .. x .. y:gsub("`\t*","\\n"):gsub("^\t*","") .. "`"

    Should do it, at the cost of being a little more complex.

    This Lua object is actually really cool. Good work Donald May (is that Vortex2?)

    [Edit: Actually in the latter case, merely return "`" .. x .. y:gsub("`\t*","\\n"):gsub("^\t*","") .. "`" should work for the reason you previously mentioned about white-space being ignored)]

  10. #30
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    CruddyBuddy's Avatar
    Join Date
    May 2010
    Posts
    154
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Sorry to bother you again. Would you be able to help me with one more thing? I've been able to replace the \n with a delimiter I use ($), but I can't seem to get the script modified to allow me to do something like this:

    [group]
    item=string
    _____thing1
    _____thing2
    _____thing3


    And have it come out looking like this:

    [group]
    item=string$thing1$thing2$thing3


    Quote Originally Posted by Jax View Post
    I think replacing

    return "`" .. x .. y:gsub("`","\\n") .. "`"

    with

    return "`" .. x .. y:gsub("`","\\n"):gsub("\t","") .. "`"

    will do - unless you only want to remove tabs at start of lines but still allow them inside. If that's the case, then:

    return "`" .. x .. y:gsub("`\t*","\\n"):gsub("^\t*","") .. "`"

    Should do it, at the cost of being a little more complex.

    This Lua object is actually really cool. Good work Donald May (is that Vortex2?)

    [Edit 1: Actually in the latter case, merely return "`" .. x .. y:gsub("`\t*","\\n") .. "`" should work for the reason you previously mentioned about white-space being ignored)]
    [Edit 2: Forgot to actually change the code in Edit 1]

Page 3 of 5 FirstFirst 1 2 3 4 5 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •