4 Replies Latest reply on Nov 19, 2008 11:32 AM by goldensunflakes

    print number of copies designated in a field

    goldensunflakes

      Title

      print number of copies designated in a field

      Post

      I have a numeric field that will have a number, usually between 1 and 15, that will vary by record.  I would like to be able to print a form or layout for each record where the number of copies equals the number in this field.  So, lets say I find six records of interest.  This field has the following values across the six records: 1,1,3,1,5,3.  I would like to print my found set, and have it print one copy of the first, second, and fourth records, two copies of the third and sixth records, and five copies of the fifth record.  Is this doable?  i don't mind reading a reference or "how to" book if that is where I need to go to learn a solution if someone can point me the way.

       

      Thanks 

        • 1. Re: print number of copies designated in a field
          Orlando
            

          Hi Leight

           

          Welcome to the forum.

           

          This is doable, but you will need to write a script in ScriptMaker to accomplish this. What you will basicly need to do is go to each record, performing the Print step the required number of times using a loop and a counter. 

           

          The script will look something like this:

           

            #

            Print Setup [Restore; No dialog]

            Go to Record/Request/Page [First]

            # Here is where we loop through each record

            Loop

              Set Variable [$PrintCount; Value: 0]

              # Here is where we loop through and print the required number of times

              Loop

                Print [Restore; No dialog]*

                Set Variable [$PrintCount; Value: $PrintCount + 1]

                Exit Loop if [$PrintCount = Table:: PrintQuantityField]

              End Loop

              Go to Record/Request/Page [Next; Exit after last]

            End Loop

            #

           

          * With the Print script step you need to make sure you are printing the Current Record and not Record Being Browsed.

           

          Attach this to a print button on your layout and run when you are in your found set.

           

          I hope this does the trick, or gets you on the right track.

          • 2. Re: print number of copies designated in a field
            davidhead
              

            Just a small gotcha in that script Orlando ;)

             

               Exit Loop if [$PrintCount = Table:: PrintQuantityField]

             

            If one of the record copies had not been set or had purposely been set to zero copies, you would have an infinite loop there. So a slight re-write and re-arrangement will fix it:

             

            #

              Print Setup [Restore; No dialog]

              Go to Record/Request/Page [First]

              # Here is where we loop through each record

              Loop

                Set Variable [$PrintCount; Value: 1]

                # Here is where we loop through and print the required number of times

                Loop

                  Exit Loop if [$PrintCount > Table:: PrintQuantityField] 

                  Print [Restore; No dialog]*

                  Set Variable [$PrintCount; Value: $PrintCount + 1]

                End Loop

                Go to Record/Request/Page [Next; Exit after last]

              End Loop

              # 

            • 3. Re: print number of copies designated in a field
              Orlando
                

              Quite right David, thanks for spotting that.

               

              Although if at least one copy was required to be printed, then simpy substiture "=" with "≥".

               

                 Exit Loop if [$PrintCount  Table:: PrintQuantityField] 

              • 4. Re: print number of copies designated in a field
                goldensunflakes
                  

                Thank you both for the help.  I am a long time user, but definitely not in the Power-User club.  At one time I was headed in that direction, but demands of facutly-life have deterred me from that, and other "hobbies".  Its been a while, but I have done some scripting and believe I can implement your suggestion.  Thanks again.

                -L