0

The below form calc script stops after first iteration.

Following lines not perform: // Uncheck the checkbox of the inserted row // Update row count after insertion // Skip to the next row after insertion

Following lines not perform: // Uncheck the checkbox of the inserted row // Update row count after insertion // Skip to the next row after insertion

 form1.Button.Button8::click - (FormCalc, client)

var rowCount = Table1.Row1.instanceManager.count;
var i = 0;

while (i < rowCount) do
    if (Table1.Row1[i].Subform01.CheckBox1.rawValue == 1) then
        // Insert a new row after the checked row
        var newRow = Table1.Row1.instanceManager.insertInstance(i + 1);

        // Copy values from the checked row to the new row
        newRow.Subform02.Text01.rawValue = Table1.Row1[i].Subform02.Text01.rawValue;
        newRow.Subform02.Text02.rawValue = Table1.Row1[i].Subform02.Text02.rawValue;
        newRow.Subform02.Image01.rawValue = Table1.Row1[i].Subform02.Image01.rawValue;
        newRow.Quantity.rawValue = Table1.Row1[i].Quantity.rawValue;
        newRow.Unit.rawValue = Table1.Row1[i].Unit.rawValue;
        newRow.UnitPrice.rawValue = Table1.Row1[i].UnitPrice.rawValue;
        newRow.TotalPrice.rawValue = Table1.Row1[i].TotalPrice.rawValue;

        // Uncheck the checkbox of the inserted row
        Table1.Row1[i].Subform01.CheckBox1.rawValue = 0;

        // Update row count after insertion
        rowCount = rowCount + 1;
        i = i + 1; // Skip to the next row after insertion
    else
        i = i + 1;
    endif
endwhile

1 Answer 1

0

The "update row count after insertion" comment is followed by a line that increments i by one.

But you've added a new row that doesn't seem to have a checkbox, and when you increment i by one, that's the new row it points to. It should probably change the increment of i to i = i + 2 in the first case (but leave it i+1 in the "else" case) in order to work properly.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.