Announcement

Collapse
No announcement yet.

How to populate listbox1 from ini file

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

  • How to populate listbox1 from ini file

    How to populate listbox1 from ini file

    I flipped through almost all the pages and did not find the solution for myself

    My setup.ini looks like this:

    Code:
    [1_NAME]
    NAME=Paris
    
    [2_NAME]
    NAME=London
    
    [3_NAME]
    NAME=Madrid
    :
    :

    Below can be more names.

    How can i populate all the names to listbox1 ?​

  • #2
    Something like this?
    Attached Files
    Bas Groothedde
    Imagine Programming :: Blog

    AMS8 Plugins
    IMXLH Compiler

    Comment


    • #3
      Originally posted by Imagine Programming View Post
      Something like this?
      Thank you
      Exactly what i need. it works perfectly even if you make till 100 names.
      I would like to make a small project installer so i use this setup.ini file like this:

      Code:
      [1_NAME]
      NAME=Paris
      RUN=name1.exe
      
      [2_NAME]
      NAME=London
      RUN=name2.exe
      
      [3_NAME]
      NAME=Madrid
      RUN=name3.exe
      Page on preload:
      Code:
      local sections = INIFile.GetSectionNames(_SourceFolder.."\\Install\ \Setup.ini");
      if (sections) then
      for _, section_name in ipairs(sections) do
      local value = INIFile.GetValue(_SourceFolder.."\\Install\\Setup. ini", section_name, "NAME");
      ListBox.AddItem("ListBox1", value, section_name);
      end
      end

      The setup.ini i moved to folder Install and there are also 3 simple setup files for test
      name1.exe name2.exe name3.exe
      The button "install" with this code but by clicking on button nothing happens.
      It doesn't work at all
      Code:
      local tChecked = ListBox.GetChecked("ListBox1", BST_CHECKED);
      if tChecked then
      for i = 1, #tChecked do
      local sWorkDir = ListBox.GetItemData("ListBox1", tChecked[i]);
      _getArgs = function (s)
      assert(type(s) == 'string')
      local tRet = {};
      s = String.TrimLeft(s, nil);
      local nPos = String.Find(s, ' ');
      if (nPos ~= -1) then
      return String.Mid(s, 1, (nPos - 1)), String.Mid(s, (nPos + 1), -1);
      end
      return s;
      end
      File.RunEx = function (s)
      local sFileName, sArgs = _getArgs(s);
      if sArgs then
      File.Run(sWorkDir.."\\"..sFileName, sArgs, "", SW_SHOWNORMAL, true);
      else
      File.Run(sWorkDir.."\\"..sFileName, "", "", SW_SHOWNORMAL, true);
      end
      end
      ---
      local sRun1 = INIFile.GetValue(sWorkDir.."\\Setup.ini", "1_NAME", "RUN");
      if sRun1 ~= '' then
      File.RunEx(sRun1);
      end
      local sRun1 = INIFile.GetValue(sWorkDir.."\\Setup.ini", "2_NAME", "RUN");
      if sRun1 ~= '' then
      File.RunEx(sRun1);
      end
      local sRun1 = INIFile.GetValue(sWorkDir.."\\Setup.ini", "3_NAME", "RUN");
      if sRun1 ~= '' then
      File.RunEx(sRun1);
      end
      end
      end
      Maybe there is an easier way to make it work ?

      Comment

      Working...
      X