Odd behavior casting filepath as a variable

Hi Folks,
I’ve been utilizing this excellent script posted by @smohler from a prior thread for dynamic filepathing / worklist assigning (Thank you Sam!)

I’ve been trying to accomplish something similar by firing off a python script (called by a .bat script) using the “run program” utility and capturing stdout as a global variable. That routine returns the filepath of the most recently modified .csv file in a static directory so I can cast that to a global variable and avoid needing to prompt the user to use the file selector to pick the file (in theory).

This is where things get weird: the global variable established in Sam’s script always works whereas the filepath fed by the python script always throws a “cannot open file in path…” error: As far as I can tell the strings that are generated by the two different methods are IDENTICAL.

User pause prompts with =filePath variables assigned in both manners in screenshots below:

I’ve checked for whitepsace things like trailing / leading spaces and newline / carriage return characters etc. and come up with nothing. I’ve even tried declaring a new global variable with the value captured by the python script step but that doesn’t help either.

Has anybody else run into something like this? I think I ran into the same problem ~6-7 years back on an FXp running Biomek 3.XX version software and never figured it out / have always just accepted a few more clicks on the user’s end to get around this behavior.

It could be about where the starting directory of the batch script or where biomek is executing Python from.

Not sure how you verify this, but you could get fancy and force starting directories in the .bat script by inserting cd statements.

This may become a theme of my posts: I figured this one out by going back and questioning my priors:

It WAS whitespace issues: bringing the command line output into the biomek software by clicking this option (see screenshot below) adds a newline and/or carriage return no matter what you do on the script side to generate the output.

I cleared this up with a VBscript script step on the biomek software side of things (wlfile was the output variable from the run program step) and now things work as I was intending!

Dim fpath

fpath = Replace(wlfile, vbCrLf, "")

World.Globals.PropertyChanger.SetGlobal "SelectedFilePath", fpath

@smohler : thank you for the reply and prompting me to think about this again with fresh eyes!


Good grief I forgot that the BioMek software feels like a terrible UX game of Mad Libs