[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  Unsure how to use diffrent things from different files.
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Unsure how to use diffrent things from different files.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Gtr   (38 posts)  [Biography] bio
Date Sat 10 Jul 2004 01:57 PM (UTC)

Amended on Sat 10 Jul 2004 01:58 PM (UTC) by Gtr

Message
Ahh, hey. I was wondering if anyone could expline to me how to use different things from different files. Like if I wanted to use things from track.c like 'int find_first_step'
and all the defines that go along with it if thats possible, but in another file, if anyone can help me out thanks.
[Go to top] top

Posted by Nick Cash   USA  (626 posts)  [Biography] bio
Date Reply #1 on Sat 10 Jul 2004 07:24 PM (UTC)
Message
It depends on if its locally defined (as in, for use only by that file) or globally (the entire mud). It its defined locally, there will be a prototype declaration at the top of the file. To make it global, delete that definition and put it in mud.h. Generally thats all there is to it. If the declaration is NOT there then it should work from other files anyways.

~Nick Cash
http://www.nick-cash.com
[Go to top] top

Posted by Greven   Canada  (835 posts)  [Biography] bio
Date Reply #2 on Sat 10 Jul 2004 09:40 PM (UTC)

Amended on Sat 10 Jul 2004 09:41 PM (UTC) by Greven

Message
Another option is to simply put declarations at the top of the new file. If you want to be able to call find_first_step else where, you can add:
int find_first_step(whatever the arguments for it is);
This says this is what is needed, but it will reference the function in another file.

If your using global variables declared in track.c, you can reference them with the "extern" prefix:
extern int num_room;


And if you need macros in another file, you can put them in mud.h as whiteknight says, or just copy and paste into your new file. If you willbe using it in only a few places, better individual files, but if more than a few, better to put them in mud.h

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
[Go to top] top

Posted by Gtr   (38 posts)  [Biography] bio
Date Reply #3 on Sat 10 Jul 2004 11:22 PM (UTC)
Message
Hrmm I see, thanks guys.
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


3,770 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]