Wildcards. Do they exist in Relevance language?

I’m not a coder (obviously), but I understand what wildcards do, and was very surprised to learn that IEM’s relevance language didn’t really have them. I read the whole guide (two hours of my life I will never get back…) and not once was the word wildcard even mentioned. I’m trying to use a wildcard in a file path, because the PCs I’m am subjecting this code to all have different file paths.

Q: if (name of operating system starts with "Win") then if exists folder (descendants whose(name of it as lowercase Begins with "FileMaker Pro") of folders "FileMaker" of folders then version of regapp "FileMaker Pro.exe" as string else "Not Installed" else if (name of operating system starts with "Mac") then if exists folder "/Applications/FileMaker Pro.app" then version of folder "/Applications/FileMaker Pro.app" as string else "Not Installed" else "N/A"
E: This expression could not be parsed.

FileMaker installs it’s junk to C:\Program Files (x86)\FileMaker\FileMaker <version number>\ Since I am trying to determine how many poor souls are using FileMaker out there and what versions they are on, the install paths would be different. The usual options of * and # don’t work. How can I place the path in there, with a wildcard? Above is my latest attempt. I apologize for the snark, and for the sarcasm, but I am really frustrated and tired. Tired of spending hours and days getting IEM to do the most basic of tasks.

This doesn’t work either…

Q: if (name of operating system starts with "Win") then if exists file "C:\Program Files (x86)\FileMaker\" & FileMaker Pro & "\FileMaker Pro.exe" then version of file "FileMaker Pro.exe" as string else "Not Installed" else if (name of operating system starts with "Mac") then if exists folder "/Applications/FileMaker Pro.app" then version of folder "/Applications/FileMaker Pro.app" as string else "Not Installed" else "N/A"
E: The operator "filemaker pro" is not defined.

Same with this…

Q: if (name of operating system starts with "Win") then if exists value "Publisher" whose ((it = "FileMaker, Inc.") of (it as string as version)) of key "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" of registry then version of value "DisplayVersion" as string else "Not Installed" else if (name of operating system starts with "Mac") then if exists folder "/Applications/FileMaker Pro.app" then version of folder "/Applications/FileMaker Pro.app" as string else "Not Installed" else "N/A"
A: Not Installed
T: 0.231 ms

And again…

Q: if (name of operating system starts with "Win") then if (exists folder "C:\Program Files (x86)\FileMaker") AND (exists folder whose ((it starts with "FileMaker Pro" and it contains file "FileMaker Pro.exe") of (name of it as lowercase))) then version of "FileMaker Pro.exe" as string else "Not Installed" else if (name of operating system starts with "Mac") then if exists folder "/Applications/FileMaker Pro.app" then version of folder "/Applications/FileMaker Pro.app" as string else "Not Installed" else "N/A"
E: The operator "folder" is not defined.

Thanks

You are correct that there are no “wildcards” in relevance.

But you can use other constructs to perform a similar function.

exists folder whose (name of it as string as lowercase = "filemaker") of (program files x32 folder; program files x64 folder)

or, more along the lines of what you seem to be trying to do …

exists folder whose (name of it as string as lowercase contains "filemaker pro") of folder whose (name of it as string as lowercase = "filemaker") of (program files x32 folder; program files x64 folder)

If FileMaker Pro registers itself correctly, this is a much faster, less computationally expensive method …

exists regapp whose (name of it as string as lowercase contains "filemaker pro")

Part of the problem you seemed to be having was keeping the phrases straight. To help me when I write long, complicated phrases, I start with the ‘framework’ for the phrase.

if () then () else ()
exists folder whose (true) of ()

I make sure that I use parentheses so that I can better control evaluation of the Relevance. In your first phrase you posted, you had mis-matched parentheses (you were missing a right, or closing parentheses). The Windows based Fixlet Debugger is great for spotting these mistakes. I even use it when I write relevance for other Operating Systems because it catches the syntactical errors before I start to pull my hair out.

Great examples! Thanks

How do I get the version out of the application?

Q: if (name of operating system starts with "Win") then if exists folder whose (name of it as string as lowercase contains "filemaker pro") of folder whose (name of it as string as lowercase = "filemaker") of (program files x32 folder; program files x64 folder) then version of "FileMaker Pro.exe" as string else "Not Installed" else if (name of operating system starts with "Mac") then if exists folder "/Applications/FileMaker Pro.app" then version of folder "/Applications/FileMaker Pro.app" as string else "Not Installed" else "N/A"
E: The operator "version" is not defined.

The regapp approach didn’t work.

Q: exists regapp whose (name of it as string as lowercase contains "filemaker")
A: False
T: 35.572 ms

Tried this too, but no dice…

Q:if (exists folder whose (name of it as string as lowercase contains "filemaker pro") of folder whose (name of it as string as lowercase = "filemaker") of (program files x32 folder; program files x64 folder)) then version of file "FileMaker Pro.exe" as string
E: This expression could not be parsed.

The “regapp” should work on both systems

I can do

version of regapp "wordpad.exe" 

on Windows

And on Mac I can do

version of regapp "Notes.app"

You have to get the case right of course. On a machine you know that the application is installed on just type “regapps” in a QnA window and see if you can see what you need

2 Likes

This doesn’t work because the then version of file "FileMaker Pro.exe" as string lacks the context of which folder to find the file in. This would be the same as doing the following:

Q: version of file "FileMaker Pro.exe"

This will do what you are looking for:

files "FileMaker Pro.exe" of folders whose (name of it as string as lowercase contains "filemaker pro") of folders whose (name of it as string as lowercase = "filemaker") of (program files x32 folders; program files x64 folders)

Use plurals instead of IF-THEN-ELSE, it is more concise and efficient.

1 Like

Tried it, but no luck. The Mac part doesn’t work either, no surprise there. Macs with installs of Filemaker are reporting as “Not Installed”

Q: if (name of operating system starts with “Win”) then if exists files “FileMaker Pro.exe” of folders whose (name of it as string as lowercase contains “filemaker pro”) of folders whose (name of it as string as lowercase = “filemaker”) of (program files x32 folders; program files x64 folders) else “Not Installed” else if (name of operating system starts with “Mac”) then if exists folder “/Applications/FileMaker Pro.app” then version of folder “/Applications/FileMaker Pro.app” as string else “Not Installed” else "N/A
E: This expression could not be parsed.

The regapp approach didn’t work for Windows.

Q: version of regapp "FileMaker Pro.exe"
E: Singular expression refers to nonexistent object.

It would’ve been really cool if it did.

@Jasonrw, I’ll see if I can clarify some of this with a slightly different example …

I use a small utility called GreenShot to capture screen shots and manage what I do with them (save as a file, send to a program, etc).

On my 64bit system I use the 64bit version of the tool so it exists under C:\Program Files\Greenshot. The following Relevance will detect it’s existence…

exists file "greenshot.exe" of folder whose (name of it as string as lowercase contains "greenshot") of (program files x32 folder; program files x64 folder)

the following also works …

 version of file "greenshot.exe" of folder whose (name of it as string as lowercase contains "greenshot") of (program files x32 folder; program files x64 folder)

I used this example because it doesn’t involve looking down two levels of folders like you were doing with the Filemaker Pro example, but you should be able to do something like this (I don’t have Filemaker Pro so I can’t test this) …

exists file "FileMaker Pro.exe" of folders whose (name of it as string as lowercase contains "filemaker pro") of folders whose (name of it as string as lowercase = "filemaker") of (program files x32 folders; program files x64 folders)

and

version of file "FileMaker Pro.exe" of folders whose (name of it as string as lowercase contains "filemaker pro") of folders whose (name of it as string as lowercase = "filemaker") of (program files x32 folders; program files x64 folders)

Combine them with an IF () THEN () ELSE () structure and you get …

IF (exists files "FileMaker Pro.exe" of folders whose (name of it as string as lowercase contains "filemaker pro") of folders whose (name of it as string as lowercase = "filemaker") of (program files x32 folders; program files x64 folders)) THEN (version of files "FileMaker Pro.exe" of folders whose (name of it as string as lowercase contains "filemaker pro") of folders whose (name of it as string as lowercase = "filemaker") of (program files x32 folders; program files x64 folders)) ELSE (nothing)

NOTE: I prefer using nothing rather than something like “N/A” or “N/I”. It should result in less data stored in the database and faster processing of client reports.
NOTE: I used “files” as a best practice even though you would expect only one instance of FileMaker Pro to be installed, because it prevents errors if there are multiple instances of FileMaker Pro.exe in the searched locations.

Try this and nothing else:

files "FileMaker Pro.exe" of folders whose (name of it as string as lowercase contains "filemaker pro") of folders whose (name of it as string as lowercase = "filemaker") of (program files x32 folders; program files x64 folders)

Your issue is you’re combining it into more complicated relevance that has syntax errors. Get the basics working first for each OS separately before combining it.

I need you to give me the result for exactly the relevance in this post. If it doesn’t work, I can debug it. It is much harder to debug it when you combine it with a bunch of other stuff right away.

This won’t parse. I’m just trying to see if FileMaker is installed on either a Mac or PC. I use this for relevance. If a computer has FileMaker installed, they’ll show up as relevant in the analysis.

Q: if (name of operating system starts with "Win") then if exists file "FileMaker Pro.exe" of folders whose (name of it as string as lowercase contains "filemaker pro") of folders whose (name of it as string as lowercase = "filemaker") of (program files x32 folders; program files x64 folders) else if (name of operating system starts with "Mac") then if exists regapp "FileMaker Pro.app" then "Installed" else "Not Installed"
E: This expression could not be parsed.

Remember my tip about starting with a framework when writing Relevance?

IF () THEN () ELSE ()

It looks like you have a mis-matched IF/THEN/ELSE. Part of the reason to do it this way is that for each IF, there must be a THEN and an ELSE.

I believe you are looking for a phrase similar to this (I haven’t tested it on a Mac but my Win desktop returns “Not Installed”) …

if (name of operating system starts with "Win") then (if exists file "FileMaker Pro.exe" of folders whose (name of it as string as lowercase contains "filemaker pro") of folders whose (name of it as string as lowercase = "filemaker") of (program files x32 folders; program files x64 folders) THEN ("Installed") ELSE ("Not Installed")) else (if (name of operating system starts with "Mac") then (if (exists regapp "FileMaker Pro.app") then ("Installed") else ("Not Installed")) else ("Wrong OS"))

I don’t know your environment, but you might want to change the “Wrong OS” to “Not Installed” or better yet nothing.

I understand what you are trying to do, but please tell me if this works as is on windows in the debugger or a property:

files "FileMaker Pro.exe" of folders whose (name of it as string as lowercase contains "filemaker pro") of folders whose (name of it as string as lowercase = "filemaker") of (program files x32 folders; program files x64 folders)

It will not return a result or an error on the Mac, but that is totally fine. You need to start here, get it to work on one OS all by itself, then the other, and only then combine them.

You are starting with them combined and having issues, you need to break it down and work your way back up.

I don’t understand why you can’t just try it as is and provide the result and go from there.

If your goal is to eventually create a single property to report info from many different OSes, then I suggest making many many properties, each handling a small piece and getting progressively more complicated. Once you have everything working and combined into a final product, only then do you put that into a final property into probably a completely different analysis where it belongs.

The code runs, but it produces no output, just the time.

Q:files "FileMaker Pro.exe" of folders whose (name of it as string as lowercase contains "filemaker pro") of folders whose (name of it as string as lowercase = "filemaker") of (program files x32 folders; program files x64 folders)
T: 6.442 ms

Then there is an issue somewhere in that relevance. I don’t have filemaker pro to actually test it, so I don’t know exactly what the file names and folder paths are to write the relevance against.

Is this the “correct-ish” path:

C:\Program Files (x86)\FileMaker\FileMaker 1.2.3\FileMaker Pro.exe

If so, then try this:

files "FileMaker Pro.exe" of folders whose (name of it as string as lowercase contains "filemaker") of folders whose (name of it as string as lowercase = "filemaker") of (program files x32 folders; program files x64 folders)

That path is correct for FileMaker Pro. The suggested code just returns a time value.

Q:files "FileMaker Pro.exe" of folders whose (name of it as string as lowercase contains "filemaker") of folders whose (name of it as string as lowercase = "filemaker") of (program files x32 folders; program files x64 folders)
T: 6.394 ms

Tried to get the version with this, but it wasn’t having it. I know notepad.exe is in C:\Windows\System32. I don’t have FileMaker installed on my desktop either.

Q:version of file "notepad.exe" of folder whose (name of it as string as lowercase contains "system32") of (program files x32 folder; program files x64 folder)
E: Singular expression refers to nonexistent object.

Sorry I came late to the discussion and have only skimmed through the posts.

There are two inspectors for file search that actually work with wildcards.
Both “*” for match all and “?” for matching single character will work.

The inspectors are cross platform and will work on Mac OS X, Linux, etc

find files "*.txt" of folder "c:\temp"
find folders "program*" of folder "c:\"

For notepad, you would do the following: (it is not in program files)

files "notepad.exe" of (system folders; system x64 folders)

On a 64bit system you will get 2 results because there are actually 2 different copies of notepad.exe on the system, one 32bit, the other 64bit.

You can collapse the identical results using unique values

unique values of versions of files "notepad.exe" of (system folders; system x64 folders)

So there is no match for Filemaker in just “regapps” at all? The inspector goes through the uninstall entries of the registry so if the application was installed and can be uninstalled then it should be there.

1 Like

I’m not sure @jasonrw ever used it by itself like this:

regapps whose(name of it as lowercase contains "filemaker")

It just produces the time it took to run.
Q: regapps whose(name of it as lowercase contains “filemaker”)
T: 82.494 ms

This didn’t work either.
Q: versions of regapps whose(name of it as lowercase contains “filemaker”)
T: 72.193 ms