private int nextDigitalSegment(int box0){
            // next adc
            int nextAdc = nBoxes;
            boolean endFound = false;
            boolean test = true;
            int ii = box0;
            while(test){
                if(this.adcs[ii]){
                    nextAdc = ii;
                    test = false;
                 }
                 else{
                    ii++;
                    if(ii>=nBoxes)test = false;
                }
            }

            // next dac
            int nextDac = nBoxes;
            test = true;
            ii = box0;
            while(test){
                if(dacs[ii]){
                    nextDac = ii;
                    test = false;
                }
                else{
                    ii++;
                    if(ii>=nBoxes){
                        test = false;
                        endFound = true;
                    }
                }
            }
            if(endFound)nextDac = nBoxes-1;
            if(nextAdc<nextDac)throw new IllegalArgumentException("Two consecutive ADCs with no intervening DAC");
            this.nSeg++;
            this.segments.add(new Integer(0));
            this.segments.add(new Integer(nextDac));
            this.segments.add("digital");
            BlackBox bb = this.combineSegment(0, nextDac);
            this.segments.add(bb);

            return nextDac + 1;
    }