Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched.
Close
You can create a functionblock with "variable" amount of input by using an array and an index number
FUNCTION_BLOCKVarInputVAR_INPUT
Β Β awInput:ARRAY[0..255] OFWORD; (*255 free asignable inputs*)
Β Β byAmount:BYTE; (*for use in a for loop to know when to stop, for example*)END_VAR
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Can anyone tell me how I can create a function block that has a variable number of inputs? For example, in the online documentation for V2.3 it says:
Is it possible for me to create a function in my own library that has the same type of functionality, where the user can select the number of inputs?
No impossible as the compiler looks at how many inputs are used.
There is a work around it.
when using AND for example
You can make your own functionblock with many inputs and the unused ones fill with true.
result:=inp1 and inp2 and inp3 etc.
you must declare all inputs
inp2:bool:=true; will not work.
You can create a functionblock with "variable" amount of input by using an array and an index number