Adapt, modify program in real time as function of workpiece configuration