File version in if-then-else relevance clause

I have a relevance clause like
if (condition) then (value) else (version of file “HealthService.dll” of folder (value “InstallDirectory” of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Setup” of native registry as string))

When I test the “else” value in QnA tool, it works fine, but when I use it in a analysis’ property, it reports error “incompatible types”. And it makes that not only for servers falling into the “else” category, but to all servers in the relevant "if"
Originally the “else” value was just simple text “unknown version”, which I decided to replace with the value stated in the file.
The property displays version of a software update based on the file version in the “else” value. There are several dozens of if-then-else conditions inside one another on several levels, the whole clause has nearly 4,5 thousand of characters (including spaces). It’s like “if version of file is xxx, then “URx”, else if version of file is yyy, then “URy”, else if…” Where could be the problem?

Every result from an if…then…else clause must be of the same data type. You can’t have some “thens” that are stings along with “elses” that are versions.

Try casting your version result " as string" to coerce it to the same datatype.

Thanks. I thought I had it as a string, but I forgot one “as string” in the clause. By the way, could you please look at my question here, as I didn’t get any answer there?
https://forum.bigfix.com/t/script-ending-with-exit-code-1?source_topic_id=31689