Import/Includes and globals?

About Monkey 2 Forums Monkey 2 Programming Help Import/Includes and globals?

This topic contains 21 replies, has 7 voices, and was last updated by  Richard Betson 2 years, 6 months ago.

Viewing 15 posts - 1 through 15 (of 22 total)
  • Author
    Posts
  • #2427

    EdzUp
    Participant

    Having

    in a separate monkey2 file and then using #Import or #Include to add it into the main source file so you can call the variable from numerous different monkey2 files for example I get the error ‘MyVar not found’ its in there and the whole thing compiles to that point. Anyone have any idea how to import globals into another source file as I dont want to have all the source in one file but instead put all Global declarations in a separate file.

    #2428

    impixi
    Participant

    Does this not work for you?

    globals.monkey2

    Global MyVar := 1.0

    start.monkey2

    [/crayon]
    #2430

    EdzUp
    Participant

    Nope I get Error : Identifier ‘MyVar’ not found

    im currently using the binary v1.0.0

    #2431

    impixi
    Participant

    Interesting.

    I’m using 1.0.2 (latest git clone zip) and don’t see that error…

    #2432

    wiebow
    Participant

    Are you using namespaces? Make sure to reference these if you are.

    #2433

    EdzUp
    Participant

    The example impixi up also fails

    #2436

    peterigz
    Participant

    It’s possible something was fixed since v1.0.0 if that code doesn’t work. As Weibow says, either have no namespace at all in each file, or make sure you do have one in each file.

    #2440

    EdzUp
    Participant

    peterigz: Tried and still results in a error :/

    #2444

    ImmutableOctet
    Participant

    @edzup: These examples work here for me, and I’m still on 1.0.1. It even works without declaring a namespace.

    You are sure the file’s named correctly, right? Same file extension, too?

    #2445

    EdzUp
    Participant

    Yeah even made sure the files are in the same directory etc.

    #2448

    peterigz
    Participant

    I can recreate this if I use “#include”, instead of “#import”, only works with “#import” (Not sure include exists in monkey2).

    Maybe paste or attach the code here?

    #2453

    EdzUp
    Participant

    Here ya go

    From impixi’s post above

    #2454

    peterigz
    Participant

    Only other thing I can think of is try rebuilding mx2cc, in ted go Build>Scripts>Rebuild mx2cc. If you pulled the latest version from git I think you need to do that as well as the rebuild mods. Otherwise it’s a bit of an odd one that, maybe an OS issue of somekind?

    #2455

    EdzUp
    Participant

    Im gonna download v1.0.2 and put the source into monkey and rebuild to see if that fixes this issue, to me its a weird issue to be honest.

    #2457

    EdzUp
    Participant

    Right a update to v1.0.2 has fixed this issue after recompiling the whole thing it works fine now.

    @Mark: I would update the binary to 1.0.2 so this doesnt rear its head again as it does make a brilliant product look bad which is a shame to be honest.

Viewing 15 posts - 1 through 15 (of 22 total)

You must be logged in to reply to this topic.