Add Vars via Command Line Interface

Ok, cudos on the CLI. Works pretty much as advertised.

I know there are a gajillion people out there that have been waiting for this and yes it’s here. You can now use your command prompt to add a boat load of vars at one time.

I have done so with Excel, created about 600 vars and then using the /f switch dumped them into Pac Control 9.6a no problem. I found that going into your Win10 config you can add environment vars to make your paths to both Pac Control 9.6 and your project path easier to deal with. Don’t for get to put the path in quotes (if it has spaces and it probably does) and I put the path in quotes inside the windows env vars as well which allowed me to use %pac96% %Tunnel% together these open the project then using the /f switch and a txt file that I paste all the CLI commands into starting with “/av” on each line.

Pac control has to be closed when you use this and the CSV file that gets generated every time you run the script also has to be closed.

I’m sorry for the mistake, I misread the docs or just had a senior moment…CLI does do timers.

I haven’t tried 9.6 yet. I’m definitely interested in checking out the command line options.

Have you checked out my post on using autohotkey? - It can do all PAC variables.

1 Like

Fantastic Phil. Thanks, that’s just what I was looking for.

Nice work Phil, the ahk worked like a charm. I noticed that if you already have a var in Pac that the routine will stop on a message that it needs a longer timer value which means it timed out because the configure variable dialog responded with an error message.

In the CSVImport.ahk file, near the top, there is a variable called DialogWait. You will need to increase the value for your machine. I have it set to 0.5 on mine (an 8 year old machine) and it works fine, can’t imagine your machine being much slower, but try increasing the value and see if it works for you.

The downside to increasing the DialogWait variable is that AHK will wait longer to time out when their is an already existing variable, so if you are adding new variables to an already existing CSV file, it will wait that much longer for each one that already exists.

The script is supposed to detect the error that the var already exists and skip over it. It will then open a text document showing you all the variables it was not able to create.

Yes and what I did was just restart the same csv file with the first couple of entries taken out (vars already created) and it worked without any mods to the timer.
This PC is only 2-3 years old running a gen6 i7 4970 with dual nvidia 970 cards, so it’s still pretty fast.

That machine will definitely outperform my desktop here. I wonder if it has to do with your strategy - does it already have a lot of variables and charts? I was only testing the script on an empty strategy - and it’s conceivable that adding variables slows down when a strategy grows.

I was thinking it might still be a timing issue since this PC is still pretty fast, I suspect it was outrunning the script. The tunnel program is in infant stages but probably already has over a thousand vars. I’m doing the entire fan control via pointers. There are 20 - 60hp fans and each fan has 8 RTDs that I’m doing hihi,hi, lo, lolo set points for so there are 640 alarm points just for motor temp…

Okay, found the bug, the balloon popup on newer versions of PAC Control that indicates a duplicate variable now gets the focus, so when the AHK script sends the ESC key, it dismisses the balloon and not the add variable dialog as the script is expecting. I modified the script to detect this. I tested it on 9.3 and 9.5. Updated the AHK.zip with the new script.

@philip, found another little bug with your excellent AHK script. Persistent variables do not have initial values anymore. Must have been a relatively recent change? The script trips up with persistent variables. I adjusted to the script to skip the initial value entry if the initialization mode is persistent.

Excellent tool though! It would be nice if we didn’t have to do a sneaky work-around…

Excellent tool! It would be nice if we didn’t have to do a sneaky work-around…

Surely it would be a very simple tool for Opto22 to produce as it would be the similar to the I/O tool already existing…

Hi Michael, welcome to the forums!

The CLI has matured and seen many updates over the past 5 years since this forum thread was first started.
It may well be worth your time to more fully check it out if you are looking for ‘a simple tool that Opto22 has produced’ to do this sort of thing.

If you use this tool with Excel, you can do pretty much anything with vars which includes writing scripts by the thousands and pasting them into a script block.
Set up your env vars in win10 and then leave a notepad file on your desktop with the a windows batch file. Then just paste the script from Excel into the notepad file, and execute the batch file. Whala, you now have 1000 new vars created in Pac Control.
Another benefit of this is naming convention, getting all the vars to adhere accurately to your convention.
If you’re not familiar with scripting in Excel, just copy a line of script from a script block, then paste into Excel, then using that example, create the same script on the next line using text concatenation in a column to the right that refers to columns on the left…=a1&b1&c1, etc. then put the appropriate text or numbers in each cell to the left to reproduce the example. In the column on the right, you will end up with a formula that displays as an exact replica of your script. Now, then copy a list of your vars and paste them in the appropriate cell to the left and whala, you now have as many lines of script created as you could possibly need.