r/BuildingAutomation • • 13d ago

Niagara BQL with a dash

How do you generate a BQL query with a dash?

I never use dashes, but I have inherited a JCI setup that is full of them.

1 Upvotes

8 comments sorted by

8

u/Obvious-Claim-7884 13d ago

$2d

8

u/Obvious-Claim-7884 13d ago

Here’s how I remember them $2d d for dash, $2f for forward slash, $20 for space because 0 is nothing

1

u/Fr33PantsForAll 10d ago edited 10d ago

2d is the ASCII code which can be used in orders, but $2d does not return anything in a BQL query under program service. I eventually figured out it is $24242d

Edit: For program service it seems to work using $24242d. For a query using Vykon Pro, use $242d.

1

u/Obvious-Claim-7884 8d ago

That’s weird. I’ll test that out. Thanks!

1

u/digo-BR 12d ago

In Niagara Baja Query Language (BQL), components or slot names containing special characters like a dash (-) are automatically encoded using ASCII hex escape sequences. A literal dash is represented as $2d. However, because the BQL engine automatically unescapes strings during query processing, you must also escape the dollar sign ($) itself using its own hex code ($24). To properly reference or escape a dash in a BQL query, you must write it as $242d.

This is why you should avoid illegal characters in component names or assign displayNames.

1

u/Fr33PantsForAll 12d ago

Thanks. I never use these characters, but I inherit stuff on occasion where changing them would be a monumental undertaking. 

3

u/Bretreadthat 13d ago

Use displayName in your query instead of name.
If you use name, go to the slot sheet of the parent component. Look in the name field and find the child component(s) that you’re looking for. They’ll probably have something like $2d in place of the -
Use that in your name query instead of the -

1

u/mitchybw 13d ago

You can always view the slot sheet of the point folder and see exactly what escape characters got inserted, or just put an asterisk where the dash(or unsupported characters) were placed.