5 Replies Latest reply on Dec 23, 2013 1:15 AM by bartprins

    Question about loops again


      Hi there again a question but thanks for all the replies this is helping out great !!


      I've got a couple of tables which i fill with data i import from a text file into the fields of that tables.

      I have to add some extra fields to these tables and then export them back again into a textfile.


      There are relationships between these tables made, where a couple of these relations have a one to many type and i made them viewable via a portal.


      I made another couple of tables where i collect the data from the other tables and fill them on basis of the keyiD of the record.

      I used this code to fill the tables:


      Set variable [$Var Value:Table1::KeyId

      Go to Layout ["Layout"]

      New Record/Request

      Set Field [FollowUpTable::KeyId2;$Var]


      And i do this for every table in this script


      However there are a couple tables which have more than one record with the same KeyId which are in portals in the orginal tables.

      I probably have to do something with a loop where it checks the value of KeyId and makes a new record for that data, but don't know the code for this, i've been looking on google and the forum but can't find what i'm looking for. I think it should be something like this in poor English:


      Goto layout....


      Find the record which has the same KeyId as the others:

      make a variabele as $Var

      New record

      Set field

      End loop



      I hope this is clear enough?


      Thanks for reading


      Much obliged




        • 1. Re: Question about loops again

          I have made an example database to make my question more visible.


          When you go to the layout "Menu" you see fields for three tables which i import from a textfile including 2 portals, i then edit a couple of fields use an exportscript for that indidual record and collect this in the "Export" layout. This is an layout with with 2 portals and the other fields form where i collect this data into one field for export to a fixed filelenght without delimiters.


          The problem is that when i look at the collected data in the Exportfield i only get the data from the first portal rows. I think i have to do something with a loop again in the script but can't find out what.


          Thank you very much for helping me out !!



          • 2. Re: Question about loops again

            Hi Bart,


            From a quick look at your RG, i suspect you need to delete the link between Table_2 and Table_3 as it will become a Many to Many when there's more than one record with the same Keyid_Table_2. That will be why you are only seeing the first record in your Table_3 portal.


            Since you've made the portals in the layout based on Import_Table_1, I'd recommend that you link the Key_id_Table_3  to Keyid_Table_1. So long as Keyid_Table_1 is unique you will overcome the Many to Many relationship and hopefully make it unnecessary for any looping construct.


            Good Luck!



            • 3. Re: Question about loops again

              Hi Bart,


              I am not sure what you are trying to accomplish here, I would think that you could export this straight from the menu layout, if you collect all the data in one field.

              I have altered your example to show how you could do that.


              If you only want to export the current record, you can use Show All Records + Hide Current Record + Show Ommitted Records



              Hope that helps,


              Best regards,


              Ruben van den Boogaard

              Infomatics Software




              PS.  you can email me in Dutch if that is easier.

              • 4. Re: Question about loops again

                Hi Ruben en John,


                Thank you very much for your replies, Ruben this works great again thank you !! I've send an mail via your site.

                Perhaps one little last question for you is it possible to count the records in the portal per record and display this in a field ? Cause when i use a count function on KeyId i get 1 as result?

                • 5. Re: Question about loops again

                  Still another question, when i use the substitute(List... function as used in the example from Ruben (Calculation is below)

                  I states the values great but lists them beside eachother per value of that field so for instance Field 7 = Appels, Pears, Bananas Field 8 = Chicken, Cow where i want it in this order: Field 7 = Appels, Field 8 = Chicken, Field 7 = Pears, Field 8 = Cow etc...etc...


                  Is this possible ?



                  This is the calculation field from Ruben:


                  KeyId_Table_1 & Example_Field_1 & Example_Field_2 & Example_Field_3 &

                  Substitute(List(Import_Table_2::Example_Field_4);"¶";"") &

                  Substitute(List(Import_Table_2::Example_Field_5);"¶";"") &

                  Substitute(List(Import_Table_2::Example_Field_6);"¶";"") &

                  Substitute(List(Import_Table_3::Example_Field_7);"¶";"") &