ATTENTIONThis FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices. |
flexsim.com |
#1
|
|||
|
|||
some problem about tonum command
code like these:
treenode kkk=tonode(234); double jjjj=tonum(kkk); pf(jjjj); pr(); I do not konw why jjjj=234;because kkk==NULL,jjjj shoud be 0 or some else. the description say use a pointer,but that is not correct. tonum(thing) Description:Assert type as an arithmetic number. Only serves a real purpose in C++, but is encouraged to use in flexscript to ensure cross-compatibility between flexscript and C++. You will use this often for returning a pointer to an object or node in a field that should return a number, which applies to all triggers and combobox fields in Flexsim. |
#2
|
||||
|
||||
This is because the features of C++ pointer
1.FlexScript: somenode = tonode(address) 2.FlexScript: address = tonum(somenode) Last edited by Cao Guoquan; 10-31-2013 at 05:09 PM. |
#3
|
||||
|
||||
kkk isn't NULL. It is 234. You assigned it to 234.
If you do tonode(234) == NULL, you'll find that the result is 0 (false). If you do tonode(234) == 234, the result is 1 (true). tonode(234) returns 234, not NULL. A pointer is just a memory address. It is a number. jjjj is 234 because you assigned it to 234. When you set a treenode value, you are setting a number that is the memory address. If you explicitly set it to 234, then it is pointing at memory address 234. Code:
using namespace std; class Foo { }; int _tmain(int argc, _TCHAR* argv[]) { Foo* foo = new Foo(); cout << foo << endl; foo = (Foo*) 9; cout << foo << endl; system("pause"); return 0; } |
The Following 2 Users Say Thank You to Phil BoBo For This Useful Post: | ||
Steven Hamoen (11-01-2013) |
Thread | Thread Starter | Forum | Replies | Last Post |
Problem with a coordinated task sequence. Could somebody please help spotting the problem? | Vadim Fooks | Q&A | 1 | 08-27-2012 03:26 PM |
family command? | zhang xin | Q&A | 0 | 01-14-2010 06:33 PM |
Command getnextnetnodeoutport | Martijn van Oostenbrugge | Q&A | 0 | 02-22-2008 05:42 AM |
releaseitem command | AlanZhang | Q&A | 3 | 10-04-2007 10:11 AM |