# How a template detects that another template is in the application

**URL:** <https://forums.softvelocity.com/t/how-a-template-detects-that-another-template-is-in-the-application/257>\
**Category:** Knowledge Base\
**Tags:** templates, unverified\
**Created:** [November 9, 2026, 12:25am UTC](https://forums.softvelocity.com/t/how-a-template-detects-that-another-template-is-in-the-application/257 "2026-11-09T00:25:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rzaunere](https://avatars.discourse-cdn.com/v4/letter/r/f14d63/32.png) [@rzaunere](https://forums.softvelocity.com/u/rzaunere)\
**Post date:** [November 9, 2026, 12:25am UTC](https://forums.softvelocity.com/t/how-a-template-detects-that-another-template-is-in-the-application/257/1 "2026-11-09T00:25:20Z")

</div>

**Applies to:** the thread names no Clarion version and no template chain.

**Problem**

Template B should generate code conditionally, depending on whether template A has been added to the procedure or application.

**Solution**

Loop over `%ActiveTemplate`, compare the name in upper case, set a flag and leave the loop. The poster's own flag name here is `%FOUND`:

```auto
#SET(%FOUND,%FALSE)
#FOR(%ActiveTemplate)
#IF(UPPER(%ActiveTemplate) = 'WHATEVER(WHATEVER)')
#SET(%FOUND,%TRUE)
#BREAK
#ENDIF
#ENDFOR

```

Replace `WHATEVER(WHATEVER)` with the template's name and its parenthesised chain as it appears in the template registry, in capitals because the test uses UPPER. The original poster reported that this worked.

**Caveats**

- A second poster offered a shorter form, but its code was lost from the archived text, so it is not reproduced here.
- The first poster said a shorter form had failed for him some years earlier and he no longer used it; he could not recall when or why.
- The thread says nothing about reading `%ActiveTemplate` from a global extension versus a procedure; it does not settle which scope the loop sees.

**Today (2026)**

Not re-tested. `%ActiveTemplate` is a long-standing template symbol and the loop likely still works; check it on your build before relying on it.

**Sources:** Leonid C. (Jan 2008, the question), Lee W. (Jan 2008), Mike H. (Jan 2008) in softvelocity.clarion.templates.
