This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

multiple identical scripts
#1
I want to ask the opinion of the expert minds in source code ...

Sometimes we find ourselves in an installation that requires a large number of scripts and they are all the same, with the only difference that we only have to change the last numbers of the group address.

For this case it has occurred to me to do it like this, I have tried it and it works. I share it with you!


Code:
--ID Zone
i = 6

--Setpoint temperature control object
TC = '2/2/'.. i

--Fan speed control object AUTO MODE
FAN = '2/3/20'.. i

--COOL / HEAT mode thermostat status
Modo = '2/5/10'.. i

--ECO MODE control object
ECO = '3/5/'.. i

--Temperature object ECO MODE-COLD
TEC = '40/0/1'

--Temperature object ECO MODE-HEAT
TEH = '40/0/2'
Reply
#2
It is usually  project specific but I would recommend to play alias game. When you ignore the groups and focus on objects names then you can write universal scripts for many projects. You only need to stick to same object naming convention which is usually the case. 
https://forum.logicmachine.net/showthrea...0#pid20520
Reply
#3
Another option is to wrap your code into a function, add it to common functions. Then call this function from scripts passing the required parameters. Optionally you can attach your script to a tag and calculate parameters based on calling group address.
Reply


Forum Jump: