Shop OBEX P1 Docs P2 Docs Learn Events
Array — Parallax Forums

Array

SamTheManSamTheMan Posts: 43
edited 2009-06-07 10:15 in General Discussion
will this work?

Que var byte (16)
temp var byte (16)

Que()=temp()

or do I have to do:

for x=0 to 15
Que(x)=temp(x)
next


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

Comments

  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-05-31 18:05
    I know that experimenting on one's own isn't considered cool or hip or sexy, but it is fun -- you should give it a try!

    PUT array2, array1(0) TO array1(15)
    


    ...moves the contents of array1 into array2
  • SamTheManSamTheMan Posts: 43
    edited 2009-06-01 11:55
    Dear Jonny,

    it did not work!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • T&E EngineerT&E Engineer Posts: 1,396
    edited 2009-06-01 12:37
    What version of SX/B do you have. I beleive what JonnyMac is stating requires 2.0 beta.
  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-06-01 13:27
    It does in fact work with the latest version of SX/B -- I tested before posting.
  • SamTheManSamTheMan Posts: 43
    edited 2009-06-01 16:04
    I'm using Ver. 2.00

    I used the SXsim

    Dear Jonny,

    I tried this program:

    i=0


    do
    · x(i)=1
    · inc i
    loop until i=16


    ·put x, y(0) to y(15)
    end

    the result was:

    only two bytes has changed to 0

    X(0)· -->0
    x(1) -->0


    x(2) -->1

    .

    ..

    x(15) --->1

    what did I do wrong?



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-06-01 17:34
    Are you using the latest version of SX/B (2.00.24)? I am -- I've attached my code and [noparse][[/noparse]partial] screen shot to show you that it does in fact work in SX/Sim (I tested using an actual chip in Debug mode).
    1024 x 768 - 290K
  • SamTheManSamTheMan Posts: 43
    edited 2009-06-07 10:15
    Dear JonnyMac and Bean,

    I'm unsing latest version of SX/B (2.00.24)

    I tried your code and it worked fine. BUT mine( below) did not work!!

    in my code, since I'm using many subs, I had to move my SUB definitions·inside the interrupt area (based on Bean's recommendations) because the compiler complained when I had them before the interrupt code.

    I checked the ASM code of my program and I found that the compiler translated the PUT command differently !!

    What do you think?



    ID············· "Master"
    DEVICE········· SX28, OSCXT2, BOR22
    FREQ··········· 20_000_000


    '
    ' I/O Pins
    '

    '
    ' Constants
    '
    Int_Req···CON·5
    Ext_Req···CON·4
    No_Req···CON·2

    '
    ' Variables
    '

    QUE··VAR·byte (16)
    Temp··VAR·Byte (16)
    password·var·word
    tmp··VAR·Byte··' work vars
    Cam_time·Var·byte··' Wating time after Cam-on
    Stop_time·Var·byte··'wating time before closing the Cam/door
    Light_timer·var·tmp
    Last_flr·var·byte
    'camfail_cnt·VAR·byte
    Slow_timeout·var·byte
    fast_timeout·var·byte
    Que_cntr·VAR·Byte
    Crnt_flr·VAR·byte
    collective_opt·var·bit··'0= full collective, 1=Down collective
    Door_option·Var·bit··'0=normal·1=Automatic
    dir··VAR·bit··'0=down··1=up
    light_flag·VAr·bit··'0=light is off·1=lights is on




    '
    ·INTERRUPT
    '
    goto ISR_Start

    ' =========================================================================
    ' Subroutine / Function / Task Declarations
    ' =========================================================================
    TX_byte··SUB·1,1,Byte
    RX_byte··FUNC·1,1
    LCD_INIT·SUB·0···' initialize LCD
    LCD_BLIP·SUB·0···' blip LCD "E" pin
    LCD_CMD··SUB·1, 1, Byte··' send LCD command
    LCD_OUT··SUB·1, 1, Byte··' print char on LCD
    LCD_STR··SUB·2, 2, Word··' print string on LCD
    LCD_SET_CRSR·SUB·1, 1, Byte··' set cursor mode

    DELAY_MS·SUB·2, 2, Word, Word·' shell for PAUSE
    DELAY_US·SUB·2, 2, Word, Word·' shell for PAUSEUS

    GET_REQUESTS·SUB·1,1,Byte
    GET_DIR··SUB·0

    ISR_Start:
    ·WKPND_B=tmp


    ISR_Exit:
    WKEN_B = %10011110····'enable interrupt @ pin 0,5,6 (fork, Maint1,Maint2)
    · RETURNINT

    ' =========================================================================
    · PROGRAM Start
    ' =========================================================================

    Start:

    Main:
    tmp=0
    do
    ·que(tmp)=no_req
    ·inc tmp
    loop until tmp=16

    GET_REQUESTS Int_Req
    end

    SUB·GET_REQUESTS
    put temp, que(0) to que(15)
    endsub


    sub TX_byte
    endsub
    FUNC RX_byte
    endfunc
    sub LCD_INIT····' initialize LCD
    endsub
    sub LCD_BLIP····' blip LCD "E" pin
    endsub
    sub LCD_CMD····' send LCD command
    endsub
    sub LCD_OUT····' print char on LCD
    endsub
    sub LCD_STR····' print string on LCD
    endsub
    sub LCD_SET_CRSR···' set cursor mode
    endsub
    sub DELAY_MS··' shell for PAUSE
    endsub
    sub DELAY_US··' shell for PAUSEUS
    endsub

    sub GET_DIR
    endsub
    end


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


    Post Edited (SamTheMan) : 6/7/2009 10:20:26 AM GMT
Sign In or Register to comment.