Shop OBEX P1 Docs P2 Docs Learn Events
@@ only works in object where data is? — Parallax Forums

@@ only works in object where data is?

Trying to use new features of Spin2 to split one giant main spin2 file into a few smaller ones, to make things easier to work with...

For one of these things, I'm putting something like a structure of data into a separate file and some of the elements in the structure are pointers to embedded bitmap file data.

This was working fine when I used the @@ operator to get the actual address.
But now that it's in a different file from the one using the data, it doesn't work...
I don't think the reason why is mentioned in the Spin2 Documentation.

Anyway, it used to work like this:
fTitle:=@@long[p][6]

This doesn't work anymore, but workaround was to create a "GetAddress" method in the object where the data is and then do:
fTitle:=app.GetAddress(long[p][6])

Where GetAddress is just this:

PUB GetAddress(p):pAdd
  return @@p

This had me concerned for a minute, but guess easily fixed...

Comments

  • RaymanRayman Posts: 13,700

    I'm also about to try using method pointers and wondering if will see same issue?
    But, I think not because they are intended to be shared between objects?

  • This makes a lot of sense when you know what the @@ operator does: Add the current object's PBASE to the value (PBASE being where the code and DAT data shared by all instances of the object ends up). So what you can do is get PBASE itself by doing @@0 and adding that yourself in interpreted spin2 that will be faster. In flexspin you can just use the @@@ operator in the data itself to get a real pointer.

  • RaymanRayman Posts: 13,700

    Ok, glad to know it's a real issue, or something to keep in mind anyway.

    BTW: I'm trying your idea of having a "config.spin2" file with all the pin settings and stuff in it.
    Seems to work. Guess this is because of the Spin2 feature of being able to access CON section defines in a subobject...

Sign In or Register to comment.