AlanZhang
05-15-2008, 12:34 PM
I hope I can share something that can be avoided and improved in future in the Flexsim coding.
In Flexsim script, when you use the commands rank, setnodenum, setnodestr, set ect., if the node does not exists, the rest of the coding below the line of setnodenum will be quietly ignored. I am not sure if this is a designed feature but it is a very annoying, making debugging very hard if you are not aware of that. If you want to test this, try following lines in the script window:
pd(1);pr();
setnodenum(NULL,1);
pd(2);pr();
if you execute the code, the line 3 won't be executed without giving any error message (I do see something in System console. But first it is not an error message; and second so many messages are printed out in System console if it is open and I have no idea what they mean.). This is just an illustration. If you have hundreds lines of code, it would be hard to identify the problem since you may notice something else is wrong without knowing that it is the line of setting node number causing the rest of coding not executed. I know we could add a line if(objectexist(obj)) before line 2 to test if the node is exist or not. But I wonder how many people are using objectexist() every time when they need to use these node setting commands. Besides, if it is the rule that objectexist() should be used before these node setting commands, why not just put objectexist into these commands and give a clear message if the node does not exists?
Anyway, I wonder if there are other commands causing such problems. And I do not think the current way of handling these commands (quietly ignoring the rest of lines) is the right way.
By the way, I am using Flexsim 4.32.
In Flexsim script, when you use the commands rank, setnodenum, setnodestr, set ect., if the node does not exists, the rest of the coding below the line of setnodenum will be quietly ignored. I am not sure if this is a designed feature but it is a very annoying, making debugging very hard if you are not aware of that. If you want to test this, try following lines in the script window:
pd(1);pr();
setnodenum(NULL,1);
pd(2);pr();
if you execute the code, the line 3 won't be executed without giving any error message (I do see something in System console. But first it is not an error message; and second so many messages are printed out in System console if it is open and I have no idea what they mean.). This is just an illustration. If you have hundreds lines of code, it would be hard to identify the problem since you may notice something else is wrong without knowing that it is the line of setting node number causing the rest of coding not executed. I know we could add a line if(objectexist(obj)) before line 2 to test if the node is exist or not. But I wonder how many people are using objectexist() every time when they need to use these node setting commands. Besides, if it is the rule that objectexist() should be used before these node setting commands, why not just put objectexist into these commands and give a clear message if the node does not exists?
Anyway, I wonder if there are other commands causing such problems. And I do not think the current way of handling these commands (quietly ignoring the rest of lines) is the right way.
By the way, I am using Flexsim 4.32.