Hi, I need assistance with the development of a custom Function Block in plcNext engineering using ST if I am not wrong. This is my first time and don’t have experience. Copied a code in ST to the engineering after following the procedure to add new FB and has a lot or errors.
Thank you for your assistance in advance.
Randy
Hello!
As you make your code by advanced copy-paste method))) you meet with errors of undeclared variables and additional fb calls, that does not declared in Variables part of new fb structure.
So you have to declare new variables at first. And set it additional options, such as Input/output and data type…
This will fix most simple error warnings in this case
Ok, this is far from the ide declaring style.
* PLCNext Engineer does not support METHOD, VAR, BEGIN keywords in manner you try to copypaste. It seems to be more close to PASCAL or BASIC code sample. It have to be deletes from code.
* Using REPEAT UNTIL in this case (exit condition is determined by user input) will cause watchdog exception.
* There are additional FC/FB calls 'IsCellNumber()', 'ReadInputString()', which have to be declared in separate POU's
This sample have to be deeply refactored for using with PLCNext Engineer.
Ok, followed your suggestions. Please see below errors i get using CONCAT
Doc1.pdfLine 53
randomNumber is a string
The second part are bits converted to a string or at least that’s what i hope.
Ok, let’s try to deal with it…
line 52. For random generation you should use PBCL_SysRandom_1 from PLCnextBase library https://www.plcnextstore.com/world/app/2023. It will return LREAL 0..1, so you have to scale it up to 10 and make it INT or etc type you need. Use builtin function TO_INT(var);
line 53. You have to use builtin TO_STRING(var, ‘{0:d}’) for convert random variable to string variable.
line 60. There is no builtin TRIM() function. Also it will never be executed, because of previous RETURN statement.
Great, cleared the error, thank you.
Doc3.pdfAnother FB creation attached with error, looks like syntax error. Can’t figure out where i am going wrong.
Hello!
So, let’s take a look…
line 66. If DisplayMessage() already defined function block, parameter ‘msg’ have to be linked to STRING constant or STRING variable if it declared as input, and only STRING variable, if it declared as InOut. In this line, it is only suggestion of acceptable datatype now.
line 71. I can’t clarify, what is going on here. If it is fb or fc call, there is missed “( )”. This cause line 72 error.
line 73. You have use function CONCAT() and TO_STRING(var, ‘{0:f2}’) to operate with data as string. We discuss it previous sample.
Best regard.





