6 Replies Latest reply on Jun 27, 2008 11:00 AM by (Mikhail_Shpilko)

    Indexed variables or array.

      I have to store big set of fields to the variables,
      and then use them to assign to appropriate group of fields
      in another PDF.
      Is it possible to accomplish this task by using something
      like array?
        • 1. Re: Indexed variables or array.
          MarkWalsh Level 4
          Are the fields named the same in both documents?
          • 2. Re: Indexed variables or array.
            Level 1
            Unfortunately not.
            • 3. Re: Indexed variables or array.
              MarkWalsh Level 4
              Well, that would have certainly made things much easier.

              Unfortunately, now you're gonna have to find some way to associate the field name in the source document with the field name in the target document. Probably your best bet would be to create an array of strings where you separate the source and target names in each string with a character that would not be used in the field names (possibly a pipe '|' character)

              var fieldNameArray = new Array ("SourceFieldName1|TargetFieldName1", "SourceFieldName2|TargetFieldName2", "SourceFieldName3|TargetFieldName3"...etc...);

              Then loop through the elements of your array, separating the source field name and the target field name into variables. If source field exists in source document, and target field exists in target document, set value of target field to value of source field.
              • 4. Re: Indexed variables or array.
                Level 1
                Thank You, Mark.<br /><br />I create following code and when I trace it<br />following message showed up:<br />"cb is not a function"<br /><br />Could You explin why I got this message.<br />Thanks.<br /><br />//Calculate family size in source PDF<br />var famtot = 0 ;<br />for (var j = 1; j<10; j++){<br />var cl_child="DOB_"+String(j)+"a" ;<br /><br />if (this.getField(cl_child).value != "")<br />{<br /> famtot = famtot+1 ;<br />}<br />}<br />//Store fields values to arrays<br />if (famtot>0)<br />{<br />var cb = new Array();<br />var cr = new Array();<br />var ch = new Array();     <br />var cf = new Array();<br />var cl = new Array();<br />var cm = new Array();<br />for (var j = 1; j<famtot; j++){<br />var k = String(j) ;<br />var i = j-1 ;<br />cl_child="DOB_"+k+"a" ;<br />cb(i) = this.getField(cl_child).value ;<br /><br />cl_child="RELATIONSHIP_" + k ;<br />cr(i) = this.getField(cl_child).value ;<br /><br />cl_child = "ChckBox_HEALTH_WANT_Yes_" + k ;<br />ch(i) = this.getField(cl_child).value ;<br /><br />cl_child="NAME_F" + k ;<br />cf(i)= this.getField(cl_child).value ;<br /><br />cl_child="NAME_L" + k ;<br />cl(i)= this.getField(cl_child).value ;<br /><br />cl_child="NAME_M" + k ;<br />cm(i)= this.getField(cl_child).value ;<br />}<br />}<br /><br />// Import from Array<br />if (famtot>0)<br />{<br />var f2 = app.openDoc("/c/PDF/1_Origin/form2.pdf") ;<br /><br />for (var j = 1; j<famtot; j++){<br />var k = String(j) ;<br />var i = j-1 ;<br />cl_child="DOB_"+k ;<br />f2.getField(cl_child).value=cb(i);<br /><br />cl_child="RELATE_" + k ;<br />f2.getField(cl_child).value=cr(i);<br /><br />cl_child="HEALTH_Yes_" + k ;<br />f2.getField(cl_child).value=ch(i);<br /><br />cl_child="NAME_F" + k ;<br />f2.getField(cl_child).value=cf(i);<br /><br />cl_child="NAME_L" + k ;<br />f2.getField(cl_child).value=cl(i);<br /><br />cl_child="NAME_M" + k ;<br />f2.getField(cl_child).value=cm(i);<br />}<br />}
                • 5. Re: Indexed variables or array.
                  Bernd Alheit Adobe Community Professional & MVP
                  Use [i] not (i) for accessing array elements.
                  • 6. Re: Indexed variables or array.
                    Level 1
                    Thank You, Bernd

                    It's help.