Hello Lodovic,
The way I understand your application, you are trying to acquire a finite number of samples from each channel when a trigger pulse comes in, then repeat this for each trigger pulse. In other words, you want to program a retriggerable finite analog acquisition. This is exactly what the example I mentioned does. It generates a retriggerable finite pulse train, then uses this as the sample clock for a continuous analog input task.
Don't get confused by the fact that the analog input task is set for continuous. This simply ensures that the task continues to run until the user hits the stop button. There are still a finite number of samples being acquired on each channel per trigger. This is due to the fact that the sample clock is coming from a retriggerable finite pulse train.
I'm not sure how your current program is set up, but you should not have to explicitly clear the memory buffer assigned by DAQmx. Let me know if you still have any questions about this.
Best regards,