the code below is for printing a command line based on the 2 sets
@echo off
rem Define lists of register addresses and values to write
set MY_REG_ADDRESSES=3 22 28 29 31 32 21 51 94 97 104 105 77
set MY_REG_VALUES=4 12000 450 40 100 40 1440 100 450 10000 0 0 1000
rem Write values to Modbus registers using the lists
set i=0
for %%a in (%MY_REG_ADDRESSES%) do (
set /a i=i+1
echo modpoll -r %%a -t 4 -4 1 COM3 !MY_REG_VALUES:~%i%,1!
)
I would expect the code to output lines that look like:
modpoll -r 3 -t 4 -4 1 COM3 4
but rather I am getting:
modpoll -r 3 -t 4 -4 1 COM3 !MY_REG_VALUES:~0,1!
I have tried using list[i] also but that returned nothing??