FolderItem.Launch with Params bug?

Today I built a helper app based on a desktop project without any window (console apps spew horrible black terminal windows across the desktop). I needed to pass 4 parameters to the application in the form of “1 1 1290 0” and to test that’s what I placed in the Command Line Arguments field under debug in Shared build settings. To turn the System.CommandLine data into args() I use:

Dim args() As String = Split(System.CommandLine) Dim arg1 As String = args(args.Ubound - 3) Dim arg2 As String = args(args.Ubound - 2) Dim arg3 As String = args(args.Ubound - 1) Dim arg4 As String = args(args.Ubound)

This allows me to ignore any/all spaces in the path of the executable file.

This worked during debugging and when launching from the command line however failed when the helper was launched from the main project. I found that this failure was due to the parameters having trailing spaces when using folderitem.launch(“1 1 1290 0”). The simple solution was to change the first line above to:

Dim args() As String = Split(Trim(System.CommandLine))

So does FolderItem.Launch have a bug? And how does the IDE which launches debug articles avoid this problem? Or should we be able to emulate a launch by adding a helper flag to the Debug section of Shared Build properties which would then include these trailing spaces?

split is ill suited for most cmd line parsing as arguments may include spaces (say a file path that has spaces in names etc)
Being able to parse the cmd line better would probably deal with this issue

Maybe try one of the options mentioned in

I had got around the file path including spaces and knowing the number & order of the arguments makes it easy. Why is there a difference between debugging & executing from the command prompt and launching from another Xojo app?

Not sure