If you create a query it contains FIND ... WHERE and you can call that query anywhere you want using DISPLAY QueryName.
If however you have a complex query that you need to build on the fly there is no way to display this.
I have a query which usually has one criteria in it, but sometimes has two or more, e.g.
FIND Job WHERE EXISTS JobMechanic WHERE (JobMechanic.obJob=Job AND JobMechanic.Name = 'Jacob'
Sometimes there are jobs that require two mechanics and the first query can't handle that, so it would need to be
FIND Job WHERE EXISTS JobMechanic WHERE (JobMechanic.obJob=Job AND JobMechanic.Name = 'Jacob')
AND EXISTS JobMechanic WHERE (JobMechanic.obJob=Job AND JobMechanic.Name = 'Carl')
Mostly the query will be one mechanic, sometimes it may be two, in outlier cases it might be three.
I can't see a way to build that inside a query and you can't use EXEC_SCRIPT in a query formula to build the FIND statement outside the query place it into a non persisted BO and then EXEC_SCRIPT TempBO.QString.
You can use
DISPLAY Job WHERE EXISTS JobMechanic WHERE (JobMechanic.obJob=Job AND JobMechanic.Name = 'Jacob')
AND EXISTS JobMechanic WHERE (JobMechanic.obJob=Job AND JobMechanic.Name = 'Carl')
But that results in a table of Job instances that is randomised and not meaningful and the operation on records is not controllable (and defaults to EDIT).
What would be useful is to be able to define the layout of a query and then be able to use
DISPLAY Job WHERE EXISTS JobMechanic WHERE (JobMechanic.obJob=Job AND JobMechanic.Name = 'Jacob')
AND EXISTS JobMechanic WHERE (JobMechanic.obJob=Job AND JobMechanic.Name = 'Carl')
USING MyQuery
to override the query's FIND and insert the BOs that you've brought into context with the DISPLAY statement but laid out in the format of MyQuery.
Unless anyone else has encountered a way to make this happen another way.