INI Data

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • markstaylor
    Indigo Rose Customer
    • Oct 2003
    • 296

    INI Data

    I know how to get all the section names from a file, but how can I accumulate values from within the same file. For example in this file I want to add all the WalMart= values (in this example it would be 350). But I want to add all the others the same way in all the sections. The ticker is the "Walmart" or "Target" names are need to be read in from a seperate file into a table then search the INI file for these values.

    [05/05/2004]
    Walmart=100
    Walmart Disc=10
    Walmart School Disc=1
    Walmart Family Disc=9
    Target=500
    Target Disc=20
    Target School Disc=10
    Target Family Disc=15
    [05/06/2005]
    Walmart=250
    Walmart Disc=20
    Walmart School Disc=3
    Walmart Family Disc=18
    Target=50
    Target Disc=2
    Target School Disc=1
    Target Family Disc=8
    Last edited by markstaylor; 05-08-2005, 08:02 PM.
    SELECT * FROM Users WHERE IQ > 0;
    o rows Returned
  • bule
    Indigo Rose Customer
    • May 2005
    • 1116

    #2
    using for loop
    Never know what life is gonna throw at you. ZubTech

    Comment

    • bule
      Indigo Rose Customer
      • May 2005
      • 1116

      #3
      more precisely:


      dat = "path to your ini file";
      sekc = INIFile.GetSectionNames(dat);
      total=0;
      for count = 1, Table.Count(sekc) do
      total = total + INIFile.GetValue(dat, sekc[count], "Walmart");
      end
      Never know what life is gonna throw at you. ZubTech

      Comment

      • TJ_Tigger
        Indigo Rose Customer
        • Sep 2002
        • 3159

        #4
        Originally posted by bule
        more precisely:


        dat = "path to your ini file";
        sekc = INIFile.GetSectionNames(dat);
        total=0;
        for count = 1, Table.Count(sekc) do
        total = total + INIFile.GetValue(dat, sekc[count], "Walmart");
        end
        You may want to make sure the string exists and is not blank. The INIFile.GetValue returns a string and returns "" if there is an error. You could also wrap the INIFile.GetValue in a String.ToNumber to change the value to a number and if there is an error with that it returns 0 (zero) which would not hurt the addition.

        Code:
        dat = "path to your ini file";
        sekc = INIFile.GetSectionNames(dat);
        total=0;
        for count = 1, Table.Count(sekc) do
        	total = total + String.ToNumber(INIFile.GetValue(dat, sekc[count], "Walmart"));
        end
        TJ-Tigger
        "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
        "Draco dormiens nunquam titillandus."
        Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

        Comment

        • markstaylor
          Indigo Rose Customer
          • Oct 2003
          • 296

          #5
          I didn't see the responce before I reposted sorry...

          Your example works great, but I need it to do more....

          my INI files are as follows

          History.INI

          [05/09/2005 - 10]
          Walmart=25
          Walmart Disc=1.25
          Walmart School Disc=0.125
          Walmart Family Disc=1.125

          [05/09/2005 - 11]
          Foodlion=100
          Foodlion Disc=10
          Foodlion School Disc=1
          Foodlion Family Disc=9

          [05/09/2005 - 12]
          Target=250
          Target Disc=25
          Target School Disc=2.5
          Target Family Disc=22.5

          [05/09/2005 - 13]
          McKays=450
          McKays Disc=90
          McKays School Disc=9
          McKays Family Disc=81

          [05/09/2005 - 14]
          Walmart=25
          Walmart Disc=1.25
          Walmart School Disc=0.125
          Walmart Family Disc=1.125

          Retail.INI
          [Walmart]
          [Target]
          [Radio Shack]
          [Piggly Wiggly]
          [Food Lion]
          [Mckays]


          I need to read the History.ini file and total all the values in seperate variables.
          and put them in a paragraph like this..


          Walmart - 50 Disc - 2.50 School - .250 Family - 2.250
          Target - 250 Disc - 25 School - 2.5 Family - 22.5
          etc..
          etc..

          Radio Shack for example would not be included because there is no data in the History.ini file.

          I just can figure this darn thing out...A loop in a loop ????
          SELECT * FROM Users WHERE IQ > 0;
          o rows Returned

          Comment

          • bule
            Indigo Rose Customer
            • May 2005
            • 1116

            #6
            more like a if in a loop...
            Never know what life is gonna throw at you. ZubTech

            Comment

            • markstaylor
              Indigo Rose Customer
              • Oct 2003
              • 296

              #7
              dat = "path to your ini file";
              sekc = INIFile.GetSectionNames(dat);
              total=0;
              for count = 1, Table.Count(sekc) do
              total = total + String.ToNumber(INIFile.GetValue(dat, sekc[count], store));
              end

              I cannot figure out how to use this example with a variable to total all the value's data. I'm trying to read in all the value names in each section and create a total. PLEASE Help
              SELECT * FROM Users WHERE IQ > 0;
              o rows Returned

              Comment

              • TJ_Tigger
                Indigo Rose Customer
                • Sep 2002
                • 3159

                #8
                Here give this a try and see if it does what you want it to do.

                Tigg
                Attached Files
                TJ-Tigger
                "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
                "Draco dormiens nunquam titillandus."
                Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

                Comment

                • markstaylor
                  Indigo Rose Customer
                  • Oct 2003
                  • 296

                  #9
                  TJ_Tigger,

                  I need that plus adding all the other like values for each retail location.

                  Walmart Disc totals
                  Walmart School Totals
                  etc..

                  Thats where I'm totally stumped.

                  Nice example though
                  SELECT * FROM Users WHERE IQ > 0;
                  o rows Returned

                  Comment

                  • bule
                    Indigo Rose Customer
                    • May 2005
                    • 1116

                    #10
                    you mean this?

                    Code:
                    dat = "path to your ini file";
                    sekc = INIFile.GetSectionNames(dat);
                    total1=0;
                    total2=0;
                    total3=0;
                    total4=0;
                    for count = 1, Table.Count(sekc) do
                    total1 = total1 + INIFile.GetValue(dat, sekc[count], "Walmart");
                    total2 = total2 + INIFile.GetValue(dat, sekc[count], "Walmart Disc");
                    total3 = total3 + INIFile.GetValue(dat, sekc[count], "Walmart School Disc");
                    total4 = total4 + INIFile.GetValue(dat, sekc[count], "Walmart Family Disc");
                    end
                    Never know what life is gonna throw at you. ZubTech

                    Comment

                    • TJ_Tigger
                      Indigo Rose Customer
                      • Sep 2002
                      • 3159

                      #11
                      So you want to add all Walmart sections together no matter else is after the store name?
                      TJ-Tigger
                      "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
                      "Draco dormiens nunquam titillandus."
                      Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

                      Comment

                      • markstaylor
                        Indigo Rose Customer
                        • Oct 2003
                        • 296

                        #12
                        Havent had a chance to try Bule's example, but instead of "Walmart Disc", Walmart School" and so on I need these to be variables since I don't know what the store name will be. I want to get all the stores from the retail.ini file. and substitute "Walmart" with the variable.

                        TJ_Tigger -

                        I basically want to add all the "Disc" totals from all the "Walmarts" then add in a seperate value all the "School" values from "Walmart" and so on.. I want to get a total of all the values from the same store

                        Walmart=50
                        Walmart Disc=2.5
                        Walmart School=3

                        then Display all the Target info just like the Walmart (not added to "Walmart"), then get the next store from the retail file and get all the info for that store. The problem is like I said above. I won't know the stores, they will be added to the retail.ini file as Sections. I must read this file into a table and use these values as the "Walmart" and "Target".
                        SELECT * FROM Users WHERE IQ > 0;
                        o rows Returned

                        Comment

                        • TJ_Tigger
                          Indigo Rose Customer
                          • Sep 2002
                          • 3159

                          #13
                          So are Walmart, Walmart Disc and Walmart School considered the same store? If I understood what you wanted the above project did just that. Each entry in the Retail.ini file will be used to sum the prices from all sections of the History.ini file. You end up with a list of all the stores and their prices. It is all dynamic based on those two files, you could have 500 stores and it would work the same way.

                          Tigg
                          TJ-Tigger
                          "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
                          "Draco dormiens nunquam titillandus."
                          Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

                          Comment

                          • markstaylor
                            Indigo Rose Customer
                            • Oct 2003
                            • 296

                            #14
                            Well Walmart,Walmart Disc etc are in the same store but I need to have a total of each Walmart, Walmart Disc. etc. from each section that is walmart.This way I can have a total of all the disc in walmart, a total of all the school donations "Walmart School". There will be numerous entries of each store and I simply want the total for each store the total Disc, the total School, the toal family etc.

                            Sorry if I'm not making this clear.
                            SELECT * FROM Users WHERE IQ > 0;
                            o rows Returned

                            Comment

                            • TJ_Tigger
                              Indigo Rose Customer
                              • Sep 2002
                              • 3159

                              #15
                              This is the code I may be tired and not understanding but it appears to do what you want it to do.

                              Code:
                              --Get Retail Stores from the retail ini file
                              tbRetail = INIFile.GetSectionNames("AutoPlay\\Docs\\Retail.INI")
                              --Get History sections from the history file
                              tbHistory = INIFile.GetSectionNames("AutoPlay\\Docs\\History.INI");
                              --initialize the details this is used to display all values by store at the end of the for loop
                              strDetails = "";
                              --for each item in the retail section do the following
                              for index,store in tbRetail do
                              	--initialize and reset value for each store in the list
                              	value = 0;
                              	--for each section in history do the following
                              	for i,section in tbHistory do
                              		--Add the value to the existing value if the value does not exist the String.ToNubmer will make the value 0
                              		value = value + String.ToNumber(INIFile.GetValue("AutoPlay\\docs\\History.INI", section, store));
                              	end	
                              	--Add to the details for display
                              	strDetails = strDetails .. store .. " - " .. value .. "\r\n"
                              end
                              Dialog.Message("INI Details", strDetails);
                              the value is reset for each store as you loop through the list of stores. the strDetails is used for display purposes only. you could output to a table if you wanted.

                              I hope you find the solution you need.

                              Tigg
                              TJ-Tigger
                              "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
                              "Draco dormiens nunquam titillandus."
                              Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

                              Comment

                              Working...
                              X