Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method RecursiveDeleteSnapshots ( 
 | 
  LibOpt_Snapshot snapshot, 
 | 
  Number number_to_delete 
 | 
) as Number 
 | 
{ 
 | 
  Description: 
 | 
  [* 
 | 
    Recursively walk the list of snapshots starting from the provided `LibOpt_Snapshot` and find snapshots that can be deleted. 
 | 
    A snapshot that can be deleted is a snapshot without grand children. 
 | 
    This is because deleting a child `LibOpt_Snapshot` would leave incomplete information underneath the parent `LibOpt_Snapshot`. 
 | 
  *] 
 | 
  TextBody: 
 | 
  [* 
 | 
    // benlong Mar-28-2022 (created) 
 | 
    if( snapshot.CanAutoDelete() ) 
 | 
    { 
 | 
      snapshotsBeforeDelete := this.Snapshot( relsize ); 
 | 
      snapshot.Delete(); 
 | 
      snapshotsAfterDelete := this.Snapshot( relsize ); 
 | 
       
 | 
      number_to_delete := number_to_delete - ( snapshotsBeforeDelete - snapshotsAfterDelete ); 
 | 
    } 
 | 
    else 
 | 
    { 
 | 
      traverse( snapshot, Children, child, number_to_delete > 0 ) 
 | 
      { 
 | 
        number_to_delete := this.RecursiveDeleteSnapshots( child, number_to_delete ); 
 | 
      } 
 | 
    } 
 | 
    return number_to_delete; 
 | 
  *] 
 | 
} 
 |