Shop OBEX P1 Docs P2 Docs Learn Events
Passing array as an argument — Parallax Forums

Passing array as an argument

at_jayat_jay Posts: 16
edited 2013-07-17 18:28 in Propeller 1
Hi,
Just a confusion, as I am new to spin ...I have an Array A of type Long and 800 values in Object A. I want that some PUB function in Object A passes this Array A as an argument to some PUB function in Object B.

Please advice me the spin sytax.

Cheers
Jay

Comments

  • Dave HeinDave Hein Posts: 6,347
    edited 2011-08-11 05:45
    Object A would look something like this:
    obj
      B : "ObjectB"
    var
      long A[800]
    
    pub main
      B.meth(@A)
    
    and object B would be
    pub meth(ptr) | i
      repeat i from 0 to 799
        long[ptr][i] := ...
    
  • frank freedmanfrank freedman Posts: 1,983
    edited 2013-03-15 23:40
    Thank you Dave, this was just the hint I needed.

    Hey Parallax, please include an expansion on this topic in the next version of Prop manual and PEK
    Thx,
    FF
    Dave Hein wrote: »
    Object A would look something like this:
    obj
      B : "ObjectB"
    var
      long A[800]
    
    pub main
      B.meth(@A)
    
    and object B would be
    pub meth(ptr) | i
      repeat i from 0 to 799
        long[ptr][i] := ...
    
  • JonTitusJonTitus Posts: 193
    edited 2013-07-17 14:31
    It does not help newcomers when you post code snippets without comments that could help them understand what goes on.
  • tonyp12tonyp12 Posts: 1,951
    edited 2013-07-17 18:28
    > code snippets without comments

    I added some comments and attached it as a Archive of the two object file.
    obj
      B : "ObjectB"        'load the ObjectB and now refer to it as B
    var
      long A[800]          'Reserve 800 longs
    
    pub main
      B.my_method(@A)      'Call the my_method in the B Object, pass along the address of A  
      repeat               'Pause forever
    
Sign In or Register to comment.