2 Replies Latest reply on Nov 18, 2014 7:57 AM by gchammer

    Loop with == works but !== does not

    gchammer Level 1

      I have a process in es4 that loads data from a data base in to a form.

      The number of rows in not know.

      It loads in to a table fine.

      The use is to select one of the items to work on.

      This works if they delete 1 at a time.

      It would be faster to delete what they did not select.

      When I change the line to LicenseFeeDetailsId.rawValue !==fSelected all but the first is deleted no mater which is selected?

      How can I delete everyone that in not selected?




      var fSelected = this.rawValue; // selected fee id
      var vRows = FeeDetailsTable._Row1.count-1; //row count-1
      xfa.resolveNode("ChangeRequestForm.Table1.Row1.Cell1").rawValue = fSelected; //works
      for(var i=0;i>=vRows;i++){ // loop through table for(var i=vRows;i>=0;i--){
      if(FeeDetailsTable.resolveNode("Row1[" + i + "]").LicenseFeeDetailsId.rawValue ==fSelected ){ //find selected row --seems to loop reverse !== does not work.
      LicenseFeeRoot.FeeDetailsSub.numOfFees.rawValue = FeeDetailsTable.Row1.instanceManager.count; // good! up date fee count

        • 1. Re: Loop with == works but !== does not
          radzmar Adobe Community Professional & MVP



          there are 2 versions of the equal/not equal operators.

          == and != are the lazy ones that don't compare the types of the values you're testing.

          === and !== are the strict ones, that also compare the type.


          Here's a small example to demonstrate:


          var a = 1, b = true;
          if (a === b) {
            // Shown whenn == is used, because a is a number and b is interpreted as a number too
            // Here happens a implicit type conversion of the bolean value into a number
            xfa.host.messageBox("a is equal to b");
          } else {
            // Shown when === is used, because a is a number and b is a boolean value
            // The values are not comparable
            xfa.host.messageBox("a not equal to b");


          So your script may fail unexpected if when you use the strict versions without knowing the type of the values you compare.

          Try this script.


          var fSelected = this.rawValue,
               vRows = FeeDetailsTable._Row1.count-1;
               xfa.resolveNode("ChangeRequestForm.Table1.Row1.Cell1").rawValue = fSelected; //works
          for (var i = vRows; i >= 0; i -= 1) {
            var vNode = FeeDetailsTable.resolveNode("Row1[" + i + "]");
              if (vNode.LicenseFeeDetailsId.rawValue != fSelected) {
          • 2. Re: Loop with == works but !== does not
            gchammer Level 1

            Thanks, I go tit Solved