Sure, I can follow along the path where you started - splitting the registry key name on underscores and finding the middle section of it.
First it’s handy to understand the original error coming from the fixlet debugger:
q: exists keys whose ((preceding texts of firsts "_" of following texts of firsts "MSTeams_" of name of it) = "24060.2623.2790.8046" as version) of key "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\PackageRepository\Packages" of registry
E: A singular expression is required.
What’s happening here is that inside the whose() clause, we have a plural preceding texts of firsts "_" of following texts of firsts "MSTeams_" of name of it
, that is being compared to to the version string.
Because these are defined with plurals following text**s**
and first**s**
, this is like comparing (1;2) = 1. We can’t compare a plural value to a singular with an equals operator, because some of the comparisons might be true and some of them might be false.
Just to build the query a piece at a time, I’d start by finding the right key name:
q: names whose (it starts with "MSTeams_") of keys of key "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\PackageRepository\Packages" of native registry
A: MSTeams_24060.2623.2790.8046_x64__8wekyb3d8bbwe
Then I’d check my logic for splitting that to find the version number:
q: preceding text of first "_" of following text of first "MSTeams_" of names whose (it starts with "MSTeams") of keys of key "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\PackageRepository\Packages" of native registry
A: 24060.2623.2790.8046
Finally I’d add on my comparison, moving my string-split logic and value comparison into a whose() clause:
q: exists keys whose ((preceding text of first "_" of following text of first "MSTeams_" of name of it) = "24060.2623.2790.8046" as version) of key "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\PackageRepository\Packages" of native registry
A: True
–
As an alternative, you might ask 'In General, how can plurals be compared? Usually, we can change the equals operator into an 'exists (thing) whose (it compare-operator value)
, like
q: exists keys whose (exists (preceding texts of firsts "_" of following texts of firsts "MSTeams_" of name of it) whose (it = "24060.2623.2790.8046" as version)) of key "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\PackageRepository\Packages" of registry
A: True
You can of course change ‘exists’ to ‘not exists’ to mean “none of these match”; and for advanced forms you could use ‘conjunction of’ to mean “all of these match” or ‘disjunction of’ to mean ‘at least one of these match’. Conjunction and disjunction are used much less frequently than ‘exists’ though.