ID:1301733
 
(See the best response by Pirion.)
I'm doing some programming in DM, and I'm having trouble understanding linking different segments of code. For example, I have a .dm file called "variables" that lists all of the players stats, etc, real basic stuff.

Now what I don't understand is, how do I apply these variables to a different code file, say mob.dm

In C++ I would declare the variables in a header file, and then just include it in the main routine. But from DM code I've looked at it doesn't seem to link up that way (as in an "include" statement is unnecessary). And often I don't see a main routine either, just a bunch of .dm files such as "mob" "variabes" "turf" etc. Can anyone help me better understand this?
All variables defined in any .dm file in a .dme environment will apply throughout all of the other .dm files. You shouldn't have to use an include statement.
They're included automatically, assuming you have both the files ticked in the IDE, you can refrence any other file directly without needing to write any actual code.
Best response
The above statement by Darke is not technically true.

The way the IDE works it when you check a file, it adds a line in the [environment].dme file saying that the particular file is included in the compiled project. These includes can really be in any file, but the .dme is the place BYOND puts them.



As far as the main routine, I think that the world/New() is the closest you'll get.

Because this is a multi-entry point environment, you need to understand how the program flows.

When the world starts up, the process that is called is world/New(). This would be the equivalent of the main() function. Each map is loaded and atom/New() that exists are world New() are run too.

When a client connects to the game client/New() is called too. Each of these New procedures have built in actions associated with them, such as setting the locations and other things. User defined changes can be added too.



In response to Pirion
I think it was pretty implied that it has to be checked, especially with Rushnut's comment above.
Sorry, I was talking specifically about "You shouldn't have to use an include statement."

The Op asked if an include statement is needed, the answer is yes, even though the IDE puts it in.