# Intermittent bug with #IF( %sym ) - %sym seems to be Null when it fails

**URL:** <https://clarionhub.com/t/intermittent-bug-with-if-sym-sym-seems-to-be-null-when-it-fails/9111>\
**Category:** questions\
**Tags:** templates, bugs\
**Created:** [May 17, 2026, 4:01am UTC](https://clarionhub.com/t/intermittent-bug-with-if-sym-sym-seems-to-be-null-when-it-fails/9111 "2026-05-17T04:01:46Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![RchdR](https://clarionhub.com/letter_avatar_proxy/v4/letter/r/d78d45/32.png) [@RchdR](https://clarionhub.com/u/RchdR)\
**Post date:** [May 17, 2026, 4:01am UTC](https://clarionhub.com/t/intermittent-bug-with-if-sym-sym-seems-to-be-null-when-it-fails/9111/1 "2026-05-17T04:01:46Z")

</div>

Found a situation, which has intermittently plagued me for several years now, reproducible in C6 and C11.

Simple `#IF( %sym )` which is being used to see if a value is present or not will resolve to false when it should resolve to true.

Its intermittent, could go weeks or months without seeing the problem and then suddenly I get it every time I run through a test and then it just starts working again. A reboot makes it work again.

When it resolves to false incorrectly, the actual value appears to be null and not zero.

Any suggestions?

TIA

---

<div class="post-metadata">

**Author:** ![vitesse](https://clarionhub.com/user_avatar/clarionhub.com/vitesse/32/837_2.png) [@vitesse](https://clarionhub.com/u/vitesse)\
**Post date:** [May 17, 2026, 6:42am UTC](https://clarionhub.com/t/intermittent-bug-with-if-sym-sym-seems-to-be-null-when-it-fails/9111/2 "2026-05-17T06:42:03Z")

</div>

That sounds a bit weird but I seem to recall struggling with something like that 25 or more years ago.

I seem to recall it was some scoping issue with #declare and it went away when I used #prompt instead.

Not sure if that is relevant but hope it helps.

Cheers

Geoff R

---

<div class="post-metadata">

**Author:** ![LANSRAD](https://clarionhub.com/user_avatar/clarionhub.com/lansrad/32/4519_2.png) [@LANSRAD](https://clarionhub.com/u/LANSRAD)\
**Post date:** [May 17, 2026, 9:45am UTC](https://clarionhub.com/t/intermittent-bug-with-if-sym-sym-seems-to-be-null-when-it-fails/9111/3 "2026-05-17T09:45:40Z")

</div>

> [@vitesse](#):
>
> I seem to recall it was some scoping issue with #declare and it went away when I used #prompt instead.

I think you are right on that one.

We use hidden #PROMPT statements instead of #DECLARE in many of our templates and as I recall it was to get rid of oddball problems like that.

Charles

---

<div class="post-metadata">

**Author:** ![RchdR](https://clarionhub.com/letter_avatar_proxy/v4/letter/r/d78d45/32.png) [@RchdR](https://clarionhub.com/u/RchdR)\
**Post date:** [May 17, 2026, 10:19am UTC](https://clarionhub.com/t/intermittent-bug-with-if-sym-sym-seems-to-be-null-when-it-fails/9111/4 "2026-05-17T10:19:38Z")

</div>

> [@vitesse](#):
>
> I seem to recall it was some scoping issue with #declare and it went away when I used #prompt instead

This is a #Prompt, its not a #Declare.

I’m going to see if I can use `IsNull( %sym )` in the #If() statement because I get nothing back, like a blank string when its should be zero.

I know not all clarion language functions can be used with template language code, but what appears to be a blank string using `#Error` could be the null like state of a variable.

That then means a 3rd state has been introduced to a True/False logic test and fails by defaulting to False. Technically its true or correct, but its not.

I might see what some Ai’s think to this idea and see what it comes up with.

Potentially its an attack vector, that DAB’s defensive coding wont pick up in a programming language, but this asserts the `%sym` is in a null state and IsNull may not always be available in a programming language.

Its causing an intermittent duplicate entry in my class writing template as highlighted in red.

 ![Screenshot 2026-05-17 112518](https://clarionhub-uploads.s3.dualstack.eu-north-1.amazonaws.com/original/2X/c/cedfcdd33e6610603d44ebcd3bcab016f33c620f.png)

---

<div class="post-metadata">

**Author:** ![KevinErskine](https://clarionhub.com/user_avatar/clarionhub.com/kevinerskine/32/711_2.png) [@KevinErskine](https://clarionhub.com/u/KevinErskine)\
**Post date:** [May 17, 2026, 3:34pm UTC](https://clarionhub.com/t/intermittent-bug-with-if-sym-sym-seems-to-be-null-when-it-fails/9111/5 "2026-05-17T15:34:46Z")

</div>

I think you need to add VAREXISTS(%MySymbol)

#IF(VAREXISTS(%MySymbol) AND %MySymbol)

---

<div class="post-metadata">

**Author:** ![RchdR](https://clarionhub.com/letter_avatar_proxy/v4/letter/r/d78d45/32.png) [@RchdR](https://clarionhub.com/u/RchdR)\
**Post date:** [May 18, 2026, 12:20am UTC](https://clarionhub.com/t/intermittent-bug-with-if-sym-sym-seems-to-be-null-when-it-fails/9111/6 "2026-05-18T00:20:00Z")

</div>

Well if its fails, I will still get a duplicate which is what I’m trying to avoid.

Its like a 3rd state ie Null is being added, so I have True, False & Null.

I could use VarExists() to flag an error has occurred, namely the Null state or Null condition has appeared.

---

<div class="post-metadata">

**Author:** ![KevinErskine](https://clarionhub.com/user_avatar/clarionhub.com/kevinerskine/32/711_2.png) [@KevinErskine](https://clarionhub.com/u/KevinErskine)\
**Post date:** [May 18, 2026, 12:58pm UTC](https://clarionhub.com/t/intermittent-bug-with-if-sym-sym-seems-to-be-null-when-it-fails/9111/7 "2026-05-18T12:58:37Z")

</div>

You could try this

```CLARION
#IF(VAREXISTS(%MySymbol))
    #CASE(%MySymbol)
      #OF %True
    #OROF %FALSE
          RETURN %MySymbol
    #ELSE
          RETURN Whatever -- You can RETURN %False if 'null' = False
    #ENDCASE
#ENDIF

```

---

<div class="post-metadata">

**Author:** ![RchdR](https://clarionhub.com/letter_avatar_proxy/v4/letter/r/d78d45/32.png) [@RchdR](https://clarionhub.com/u/RchdR)\
**Post date:** [May 18, 2026, 7:39pm UTC](https://clarionhub.com/t/intermittent-bug-with-if-sym-sym-seems-to-be-null-when-it-fails/9111/8 "2026-05-18T19:39:42Z")

</div>

I’m using

```auto
#IF( NOT VarExists(%sym))
#Error('some msg')
#Else
#IF(NOT %sym)
#Insert(%AddDefaults)
#EndIF
#EndIF

```

Its an intermittent bug which I havent got to the bottom of what causes it, so for now the message will be sufficient.

I only got to the bottom of the fact the %sym appears to be null just the other day so hopefully this should be sufficient, but the existence of VarExists() says alot about how symbols & scope are handled.
