Results 1 to 7 of 7

Thread: Includes

  1. #1
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default Includes

    Alright, alright! Last question. (I swear, I hope it is atleast)

    If you're adding, and you split it up, and set global variables in the include file, will the global variables still be there to use in other files, or only that include file?

    I want to seperate things, so it's like this:

    RunMe--> (Get Task ----> Select Task) ---> (Fight Monster ---> Report to task when finished) ---> Go back to Task folder, and set it to None. Ect.

  2. #2
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Yeah.. Unless of course those vars are in a class.. If you have a var called X in a .Simba file.. When you include that file into your project, that var will still be there so you cannot re-declare it. Not sure if Simba has header guards so that you don't include things twice but I assume it does.
    I am Ggzz..
    Hackintosher

  3. #3
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default

    I tried to have the second file read a variable in the first file, turns out you can't do that. xD

  4. #4
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    If it didn't work, your not doing it right..

    See here:



    Notice the duplicate identifier? That is because X is already defined as an integer or another type in Meh.Simba.. Notice how I never made a variable called Y.. But yet I can use it? Why? Because Y is defined in Meh.Simba as well.

    Not only can you assign to X and Y in another file, but you can read it as well. I've done it.

    Think about this scenario: We've never defined MSCX and MSX1, etc in our scripts. Well how does our scripts know what values those are? They are defined in a headerfile that is included into our scripts when we do {$I SRL/SRL.Simba}. These are global variables and constants that do not change no matter what. Re-defining them will throw an error.
    I am Ggzz..
    Hackintosher

  5. #5
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default

    I want to add variables to the MAIN file, then have the included files read it, can I do that?

  6. #6
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Lol no.. Include files aren't actually ran. Include files are known otherwise as helper files or simplification files.

    We include files that hold functions or info we don't necessarily want to keep in our main file. Includes are there to be used over and over again from project to project. Think of it like a library and you just borrow books time and again. Imagine writing your own books and putting it in the library for future reference or future use. You don't exactly want to write that book again and again so you make a shelf that holds it for you. This is what an include does. It holds that data for you for future use. It's the same as functions almost. We make a function for things that we know will be ran multiple times. This way we don't keep repetitively writing the same code over and over again.

    One thing you can do though is write your variables to an ini file and do whatever you want there. Not exactly sure why you want the Include files to read it variables from your main. :S You can always pass the variables to the functions in the include or You can always get scar or another instance of Simba to run your include file as long as it has a Main..
    I am Ggzz..
    Hackintosher

  7. #7
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default

    Alright, thanks for clearing it up.

    So, the file that you INCLUDED it in, can use the global variables, but the included file can't read the main. Got it, thanks.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •