Hi, I have the following script which is inside a for loop. I like to continue the loop if table mydt is empty and skip lines below it.
I appreciate your help. Thanks
-------------------------------------------
mydt = Data Table( dt5 );
if((is empty(mydt)), continue());
mydtsummary = Data Table( dt5 ) << Summary(
Group( :BoardNo ),
Max( :starttime ),
statistics column name format( "stat of column" )
);
mydt << Update(
With( Data Table( mydtsummary ) ),
Match Columns( :BoardNo = :BoardNo ),
Add Columns from Update table( :Max of starttime )
);
mydt << select where( :starttime == :Max of starttime ) << invert row selection;
mydt << delete rows;
mydt << delete columns( "Max of starttime" );
Close( mydtsummary, nosave );
Close(mydt,save);
Why not just reverse the logic using "!" and stick all those lines in your if statement?
If( !Is Empty( mydt ),
mydtsummary = Data Table( dt5 ) << Summary(
Group( :BoardNo ),
Max( :starttime ),
statistics column name format( "stat of column" )
);
mydt << Update(
With( Data Table( mydtsummary ) ),
Match Columns( :BoardNo = :BoardNo ),
Add Columns from Update table( :Max of starttime )
);
mydt << select where( :starttime == :Max of starttime ) << invert row selection;
mydt << delete rows;
mydt << delete columns( "Max of starttime" );
Close( mydtsummary, nosave );
Close( mydt, save );
);
Thanks for quick feedback and solution. I tried it but I get an error in the update section.
missing argument{8} in access or evaluation of 'Data Table' , Data Table/*###*/(mydtsummary)
mydt << Update(
With( Data Table/*###*/(mydtsummary) ),
Looks like it is processing Update section when mydt is empty and it should not. Thanks
What are you using the Is Empty() function to do? If it is to check if the table itself has no data in it, you are using this function incorrectly. It will tell you if the variable mydt (not the data table it references) has no value or has the empty value. If you want to check if the data table has nothing in it, then do something like N Row(mydt) == 0 as your logical check.
Thanks Cameron. The issue is not whether the table is empty or has no value. the issue, if the condition is true, I want to skip all the lines below that and go to the next for loop index.
if (condition = True,
....
... skip all below
...
);
Thanks.
If( condition == true,
Break();
);
Thanks Jim.