6 Replies Latest reply on Jun 15, 2015 4:28 AM by JohnnyBQue

    Keep getting a syntax error that I can't resolve...I can't see it due to the forest....

    JohnnyBQue Level 1

      I keep getting a SyntaxError: syntax error 160: at line 161,,,,I've tried everything things but I'm sure it's simple thing that I can't see because of the forest.... see the Red text at the bottom of the code

       

       

      var dialog = {

                DueValue: "",

      WorkOrderValue: "",

         QuantityValue: "",

      IssueDateValue: "",

          IssueToValue: "",

                cb1Value:false,

                cb2Value:false,

                cb3Value:false,

                cb4Value:false,

                cb5Value:false,

       

              initialize:function(dialog)

       

              {

              var diginit=

              {

       

              "Chk1":this.cb1Value,

              "Chk2":this.cb2Value,

              "Chk3":this.cb3Value,

              "Chk4":this.cb4Value,

              "Chk5":this.cb5Value,

       

              };

              dialog.load(diginit);

              },

              commit:function (dialog) // called when OK pressed

              {

              var results = dialog.store();

              this.DueValue = results["tx1"];

              this.WorkOrderValue = results["txt2"];

              this.QuantityValue = results["txt3"];

              this.IssueDateValue = results["txt4"];

              this.IssueToValue = results["txt5"];

       

              var oRslt=dialog.store();

              this.cb1Value=oRslt["Chk1"];

              this.cb2Value=oRslt["Chk2"];

              this.cb3Value=oRslt["Chk3"];

              this.cb4Value=oRslt["Chk4"];

              this.cb5Value=oRslt["Chk5"];

       

                      },     

                      description:

                      {

            

                      name: "Control Stamp Information",    // Dialog box title

                      elements:

                                              [      

                                              {      

                                                      type: "view",

                                                      elements:

                                              [      

                                              {      

                                                      name: "Due: ",

                                                      type: "static_text",

                                              },     

                                              {      

                                                      item_id: "txt1",

                                                      type: "edit_text",

                                                      multiline: true,

                                                      width: 100,

                                                      height: 30

                                              }, 

                                              {      

                                                      name: "W/O#: ",

                                                      type: "static_text",

                                              },     

                                              {      

                                                      item_id: "txt2",

                                                      type: "edit_text",

                                                      multiline: true,

                                                      width: 100,

                                                      height: 30

                                              }, 

                                              {      

                                                      name: "QTY: ",

                                                      type: "static_text",

                                              },     

                                              {      

                                                      item_id: "txt3",

                                                      type: "edit_text",

                                                      multiline: true,

                                                      width: 100,

                                                      height: 30

                                              },

                                              {      

                                                      name: "Issue Date: ",

                                                      type: "static_text",

                                              },     

                                              {      

                                                      item_id: "txt4",

                                                      type: "edit_text",

                                                      multiline: true,

                                                      width: 100,

                                                      height: 30

                                              },

                                              {      

                                                      name: "Issue To: ",

                                                      type: "static_text",

                                              },     

                                              {      

                                                      item_id: "txt5",

                                                      type: "edit_text",

                                                      multiline: true,

                                                      width: 100,

                                                      height: 30

                                              },                                        [

                                              {

                                                      type: "view",

                                                      char_height: 10,

                                                      elements:

                                              [

                                              {

                                                      type: "static_text",

                                                      item_id: "stat",

                                                      name: "Check What applies",

                                                      char_width: 15,

                                                      alignment: "align_fill",

                                                      font: "dialog",

                                              },

                                              {

                                                      type: "view",

                                                      char_width: 8,

                                                      char_height: 8,

                                                      align_children: "align_top",

                                                      elements:

                                              [

                                              {

                                                      type: "view",

                                                      char_width: 8,

                                                      char_height: 8,

                                                      elements:

                                              [

                                              {

                                                      type: "check_box",

                                                      item_id: "Chk1",

                                                      name: "1st, 10th, Last",

                                              },

       

                                              ]

                                              },

                                              ] 

                                              },

                                              ]

                                              },

       

                                              {                                                  

                                                      type: "ok_cancel",

                                                      ok_name: "Ok",

                                                      cancel_name: "Cancel"

                                              },     

                                              [

                                              },

                                          ]   I;ve tried " {   },  [   " none of these worked      SyntaxError here....

                                              }

                                              };

       

      if(event.source.forReal && (event.source.stampName == "#TabIjeb2ZLdGVyiRhzvfNA"))

       

        {

        if ("ok" == app.execDialog(dialog))

        {

        // var cMsg = dialog.DueValue;

         // event.value = "\n" + cMsg;

         // event.source.source.info.ControlStamp = cMsg;

       

          cMsg = "\n" + dialog.DueValue;

          this.getField("Due").value = cMsg;

       

          cMsg = "\n" + dialog.WorkOrderValue;

          this.getField("WorkOrder").value = cMsg;

       

          cMsg = "\n" + dialog.QuantityValue;

          this.getField("Quantity").value = cMsg;

       

          cMsg = "\n" + dialog.IssuesDateValue;

          this.getField("IssueDate").value = cMsg;

       

          cMsg = "\n" + dialog.IssuesToValue;

          this.getField("IssueTo").value = cMsg;

       

          this.getField("cb1").checkThisBox(0, DiaBOx.cb1Value);

       

         // this.getField("cb1").value=dialog.cb1Value?"Yes"."Off";

       

        }

      }

        • 1. Re: Keep getting a syntax error that I can't resolve...I can't see it due to the forest....
          JohnnyBQue Level 1

          I'm not going to post the whole code again but I got the error to advance further down the code

           

             }, 

                                                  {      

                                                          type: "ok_cancel",

                                                          ok_name: "Ok",

                                                          cancel_name: "Cancel"

                                                  },     

                                                  [      

                                                  ]    

                                                  ]      

                                                  }       Removed this

                                                  };      Removed this

           

           

          if(event.source.forReal && (event.source.stampName == "#TabIjeb2ZLdGVyiRhzvfNA"))

          NOW I GET >>> "missing ] after element list" at line 165 which should be the line right above this....this line

          {

            if ("ok" == app.execDialog(dialog))

            {

             // var cMsg = dialog.DueValue;

             // event.value = "\n" + cMsg;

             // event.source.source.info.ControlStamp = cMsg;

           

              cMsg = "\n" + dialog.DueValue;

              this.getField("Due").value = cMsg;

          • 2. Re: Keep getting a syntax error that I can't resolve...I can't see it due to the forest....
            Karl Heinz Kremer Adobe Community Professional

            It is important that you get matching pairs of (), {} and [] - the best way to make sure that things match up is to use an editor that can provide JavaScript syntax highlighting, Javascript reformatting and identify the corresponding opening or closing parenthesis, bracket or curly brace. What you are dealing with is nothing specific to Acrobat JavaScript, it's just plain old JavaScript.

            • 3. Re: Keep getting a syntax error that I can't resolve...I can't see it due to the forest....
              Karl Heinz Kremer Adobe Community Professional

              I took a quick look at your dialog structure, and there are problems with mismatching brackets and curly braces, but you also have a problem with mixing elements and an array. Look for this sequence:

               

              },
              [
              

               

              You cannot do that. If you want to start a new view, the view would also be enclosed in { }.

               

              This may not be what you wanted as far as the layout goes, but at least it does create a dialog popup (this is just the description part of the dialog definition):

               

              description: {
                      name: "Control Stamp Information", // Dialog box title
                      elements: [{
                          type: "view",
                          elements: [{
                                  name: "Due: ",
                                  type: "static_text",
                              }, {
                                  item_id: "txt1",
                                  type: "edit_text",
                                  multiline: true,
                                  width: 100,
                                  height: 30
                              }, {
                                  name: "W/O#: ",
                                  type: "static_text",
                              }, {
                                  item_id: "txt2",
                                  type: "edit_text",
                                  multiline: true,
                                  width: 100,
                                  height: 30
                              }, {
                                  name: "QTY: ",
                                  type: "static_text",
                              }, {
                                  item_id: "txt3",
                                  type: "edit_text",
                                  multiline: true,
                                  width: 100,
                                  height: 30
                              }, {
                                  name: "Issue Date: ",
                                  type: "static_text",
                              }, {
                                  item_id: "txt4",
                                  type: "edit_text",
                                  multiline: true,
                                  width: 100,
                                  height: 30
                              }, {
                                  name: "Issue To: ",
                                  type: "static_text",
                              }, {
                                  item_id: "txt5",
                                  type: "edit_text",
                                  multiline: true,
                                  width: 100,
                                  height: 30
                              },
              
              
                              {
                                  type: "view",
                                  char_height: 10,
                                  elements: [{
                                      type: "static_text",
                                      item_id: "stat",
                                      name: "Check What applies",
                                      char_width: 15,
                                      alignment: "align_fill",
                                      font: "dialog",
                                  }, {
                                      type: "view",
                                      char_width: 8,
                                      char_height: 8,
                                      align_children: "align_top",
                                      elements: [{
                                          type: "view",
                                          char_width: 8,
                                          char_height: 8,
                                          elements: [{
                                              type: "check_box",
                                              item_id: "Chk1",
                                              name: "1st, 10th, Last",
                                          }, ]
                                      }, ]
                                  }, ]
                              }, {
                                  type: "ok_cancel",
                                  ok_name: "Ok",
                                  cancel_name: "Cancel"
                              },
                          ]
                      }]
                  }
              
              
              
              
              • 4. Re: Keep getting a syntax error that I can't resolve...I can't see it due to the forest....
                JohnnyBQue Level 1

                KK again you are spot on....pasted the code in word so I could color every [ and } and found the miss matches right off the bat....the code now is error free to a point

                 

                at the end of my code I was using two options to populate a "Check Box" the first option

                 

                this.getField(cb1").checkThisBox(0, DiaBox.cb1Value);        Using the line of code the check box did not show an 'X" in it after the stamp was applied (this could be another issues haven't researched it yet...)

                 

                The second options

                 

                this.getField("cb1").value=dialog.cb1Value?"Yes"."Off";     This give me a SyntaxError: missing name after.operator    not sure what name they are referencing here.....

                 

                I have 4 more check boxes to add but was just trying to get one to work then duplicate....

                • 5. Re: Keep getting a syntax error that I can't resolve...I can't see it due to the forest....
                  George_Johnson MVP & Adobe Community Professional

                  This line:

                   

                  this.getField("cb1").value=dialog.cb1Value?"Yes"."Off";  

                   

                  should be:

                   

                  this.getField("cb1").value = dialog.cb1Value ? "Yes" : "Off";  

                  • 6. Re: Keep getting a syntax error that I can't resolve...I can't see it due to the forest....
                    JohnnyBQue Level 1

                    Morning George......I change the line of Code but I still don't get a check in my check box, after checking the box in my dialog box...do I need to set a "format" of the check box it's self such as the Export Value to...."YES, NO, 0, 1"....???...or the "Action" ??...