Shop OBEX P1 Docs P2 Docs Learn Events
Another Array Question: Passing the address — Parallax Forums

Another Array Question: Passing the address

bdickensbdickens Posts: 110
edited 2008-11-06 14:32 in Propeller 1
If I have one object with a VAR Servo[noparse][[/noparse]10] and later in the code, I call an object with this NewCall(@Servo[noparse][[/noparse]5) I rather presume that the servo gets the address of the 6th element in the array. Is that true ?

By way of explanation; I travel a lot and the prop hardware usually gets me strange looks at airport security, so I end up doing a lot of software work during the week and hardware work on the weekends. I'd like to test it all and find out myself, but thats just too long. So I apologize for a lot of seemingly basic questions.
Thanks

Post Edited (bdickens) : 11/4/2008 5:54:32 PM GMT

Comments

  • bdickensbdickens Posts: 110
    edited 2008-11-04 14:30
    Sorry for that fun font. I should have previewed first
  • SRLMSRLM Posts: 5,045
    edited 2008-11-04 16:50
    You can use the pencil icon in the upper right hand corner to edit your post.
  • BradCBradC Posts: 2,601
    edited 2008-11-04 16:59
    bdickens said...

    By way of explanation; I travel a lot and the prop hardware usually gets me strange looks at airport security

    That's an interesting one. I also travel frequently and tend to carry a prop proto-board in my carry on. Mine has a 2x16 LCD and a USB lead wired to it and I carry it in a small plastic lunchbox with a clip-on lid.

    I've only been asked once and then I pointed out the USB cable and told them it was a naked usb widget. Got waved straight through.
    I use the USB cable to power it when I'm on a flight, but I think having it attached permanently tends to give them something they understand to look at rather than a board with nasty looking electronics on it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Pull my finger!
  • bdickensbdickens Posts: 110
    edited 2008-11-04 17:55
    I hadn't thought of that one. Making it sound like a naked USB port would probably work. Good tip. Thanks
  • bdickensbdickens Posts: 110
    edited 2008-11-05 16:37
    Any comments on the original array address passing (Lest I hijack my own thread)
  • T ChapT Chap Posts: 4,223
    edited 2008-11-05 17:39
    bdickens said...
    Any comments on the original array address passing (Lest I hijack my own thread)

    That's the way it works. Then you easily access the var in the obj as Long[noparse][[/noparse]Servo(5)]



    Use a [noparse][[/noparse] (insert space) Number ] to avoid crazy text when using brackets, even when posting code I think it is required to insert the space before the number.
  • Marc GebauerMarc Gebauer Posts: 60
    edited 2008-11-05 22:11
    I just did this last night.

    
        'compile RTC bytes
        getRTCbyte(5,@mdy_dat,%1)                           'month
        getRTCbyte(4,@mdy_dat[noparse][[/noparse]3'],%11)                       'day
        getRTCbyte(6,@mdy_dat[noparse][[/noparse]6'],%1111)                     'year
    
    PRI getRTCbyte(index,ptr,mask)
    
    'parse RTC byte and convert to ASCII, store in dat string
    
        byte[noparse][[/noparse]ptr][noparse][[/noparse]0'] := RTC[noparse][[/noparse]index'] >> 4 & mask + "0"
        byte[noparse][[/noparse]ptr][noparse][[/noparse]1'] := RTC[noparse][[/noparse]index'] & %1111 + "0"
    
    
    
    above I used pointers that were offset by index and it worked. So I would say that @servo[noparse][[/noparse]5'] would make a pointer to the 6th element.
    
    



    * In order to make the index items show up in my post I had to place the second bracket after a single quote. But now you see single quotes that are not supposed to be part of the code.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Post Edited (Marc Gebauer) : 11/5/2008 11:03:59 PM GMT
  • bdickensbdickens Posts: 110
    edited 2008-11-06 14:32
    Thanks. That will work. Appreciate everyones input
Sign In or Register to comment.