Announcement

Collapse
No announcement yet.

INI to Paragraph

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

  • INI to Paragraph

    Hello everyone again.. can i get some little help.. i already took a days for this but i cannot accomplish. My problem is getting the values from INI and write it on paragraph..

    Quiz1 = INIFile.GetValue(_TempFolder.."\\Setting.ini", "Correct Answer", "Quiz1");
    Quiz2 = INIFile.GetValue(_TempFolder.."\\Setting.ini", "Correct Answer", "Quiz2");
    Quiz3 = INIFile.GetValue(_TempFolder.."\\Setting.ini", "Correct Answer", "Quiz3");

    Paragraph.SetText("Answer", Quiz1.."\r\n");
    Paragraph.SetText("Answer", Quiz2.."\r\n");
    Paragraph.SetText("Answer", Quiz3.."\r\n");


    it only result the last last value which the Quiz3

    i also try to make a loop but no success...

  • #2
    No native 'append' attribute on Paragraph objects, so easier to use a Listbox.
    Like this:
    Code:
    tValueNames = INIFile.GetValueNames(_TempFolder.."\\Setting.ini", "Correct Answer");
    for k,v in pairs (tValueNames) do
        sValue = INIFile.GetValue(_TempFolder.."\\Setting.ini", "Correct Answer", v);
        ListBox.AddItem("ListBox1", sValue, "");
    end
    But if you really want to use Paragraph object, then custom function will make it possible.
    Like this:
    Code:
    function Paragraph.Append(Object, Text)
        local CurrentText = Paragraph.GetText(Object);
        if (CurrentText == "") then
            Paragraph.SetText(Object, Text);
            Paragraph.SetScrollPos(Object, Paragraph.GetScrollRange(Object, true).Max, true);
            else
            Paragraph.SetText(Object, CurrentText.."\r\n"..Text);
            Paragraph.SetScrollPos(Object, Paragraph.GetScrollRange(Object, true).Max, true);
        end
    end
    
    tValueNames = INIFile.GetValueNames(_TempFolder.."\\Setting.ini", "Correct Answer");
    for k,v in pairs (tValueNames) do
        sValue = INIFile.GetValue(_TempFolder.."\\Setting.ini", "Correct Answer", v);    
        Paragraph.Append("Answer", sValue);
    end

    Comment


    • #3
      Hello Bio,, here we are again... Thanks for quick response..
      i used both code you share but it result empty to my paragraph and ListBox..

      In this project paragrapht is my best option to display the Answer from INI file...

      Comment


      • #4
        sorry for the respone its no error anymore..

        Comment


        • #5
          No worries. Here's an APZ with both codes, anyway. Would've posted it for you earlier, but was literally on my way out the door at the time.

          Just a couple of things to note:
          • We can simplify the function a bit. The Paragraph.SetScrollPos commands aren't really needed - you can just omit those 2 lines of code if the Paragraph's scrollbars are turned off.
          • And credit for the function actually goes to Sakuya, not me. (Is an old piece of code he wrote, years ago).
          Glad you got it working.
          Attached Files

          Comment


          • #6
            Thanks for that Bio... as always you are helping a lot...

            Comment

            Working...
            X
            😀
            🥰
            🤢
            😎
            😡
            👍
            👎