3-265
3 Functions of NB-Designer
NB-series Programmable Terminals NB-Designer Operation Manual(V106)
3-9 Mac
ro F
unc
tion
3
3-9-1 C
reate a
S
imple Macro Prog
ram
After editing the Macro in the procedure as the above, perform the test again. Then the result as follows
should be out.
Now the basic specification is completed. However, the Macro still have a problem. When entering “0”
into LW1 and executing the Macro, an error occurs and the error can affect the normal operation of the
system. In this case, a check should be entered into the operand.
Change the codes shown as below.
int MacroEntry()
{
//Judge whether LW1 is 0 or not in order to prevent “Divide-by-zero overflow” ;
if (LW1_R!=0)
//LW0 divides LW1and LW2 is obtained
LW2_W = (double)(LW0_R)/LW1_R;
return 0;
}
Execute it again. If the divisor is 0, the Macro will not execute division. Therefore, the program safety
will be improved.
Summary of Contents for NB10W-TW01B
Page 4: ......
Page 10: ...Terminology 6 NB series Programmable Terminals NB Designer Operation Manual V106 ...
Page 528: ...8 Web Interface 8 10 NB series Programmable Terminals NB Designer Operation Manual V106 ...
Page 544: ...Appendices A 16 NB series Programmable Terminals NB Designer Operation Manual V106 ...
Page 546: ...Revision 2 NB series Programmable Terminals NB Designer Operation Manual V106 ...
Page 547: ......