Hello,
I'm facing a bit of a challenge here. My task is to be able to pass arguments to a LabVIEW executable and have it be recognized in the appropriate format. Using the latest version of Windows and LabVIEW.
I've tried following the guide on the NI website on how to do this. However, there is a problem with this - the arguments always get interpreted as a string array. If, say, I wanted to pass arguments '2' and '2' in order for the .exe to add them and result in '4', I would have to parse the string and convert from a string to an int within the LabVIEW program. This isn't scalable - if I have 50 executables, I'd have to make a subVI to accommodate for each one, as they take in different data types and different numbers of arguments.
Because of this, I've tried a different approach. I wrote a PowerShell script that intakes parameters, converts them from a string to an integer, and launches a LabVIEW executable. The challenge I've hit is being able to take there converted arguments and passing them to the LabVIEW .exe. For example, I want to pass '2' to Control X and '2' to Control Y in order for the indicator to result in '4'. So far, I haven't been able to find any way to do this. I would greatly appreciate the help.
PowerShell script code below:
#Intaking Arguments "`n Arguments Entered: `n" for([int]$i = 0; $i -lt $args.Count; $i++){ try{ [int]$parameterAsDecimal = [convert]::ToInt32($args[$i], 10) " $i - $parameterAsDecimal" }catch{ [string]$parameterAsString = $args[$i] " $i - $parameterAsString" } } "`n Number of arguments passed: $($args.Count)" #Starting LabVIEW executable Set-Location C:\Users\[user]\Desktop\LabVIEWProjects\builds\passing_parameters_proj\IntAddition Start-Process IntAddition.exe "-------------------------------------------------------------------------------------------------------"
#In Command Prompt, initially, 'cd Desktop\PowerShell_scripts' #Call with 'powershell.exe -file passing_arguments.ps1 [input parameters here]'
Thank you,
Sav