Copying one array to another


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2010
    Posts
    50

    Default Copying one array to another

    Maybe a dumb question, but here goes anyway:
    Is there a way to copy bit one array to another?

    I know this method:

    g VAR bit[8]
    h VAR bit[8]

    for i=0 to 7
    h(i)=g(i)
    next i

    I looked at the ARRAYWRITE command, but it says from one byte array to another.

    What would be the result of: h=g ?
    I tried the h=g method in my code, but I don't think it is working. If anyone can help...Thanks.

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Since your bit array is a byte long use the byte instead.

    G VAR BYTE
    H VAR BYTE


    G = H

    Byte H now is equal to Byte G and you can extract the bits indexing the byte

    G bit 0 = G.0
    G bit 1 = G.1
    .
    .
    .
    .
    .
    G bit 7 = G.7

    Naturally the same apply to byte H.

    Cheers


    Al.
    All progress began with an idea

  3. #3
    Join Date
    Sep 2010
    Posts
    50


    Did you find this post helpful? Yes | No

    Default

    Al,
    That's how I started, and then I changed to the bit array so that I could do the following:

    for i=0 to 7
    out_sig=g(i)
    pauseus 450
    out_sig=g(i+1)
    pauseus 50
    next i

    not sure how to do the same with a byte array, since when using the byte array I can't use a variable to reference the bits .... g.0-g.7 can't be expressed as g.(i)...
    Thoughts? Thanks for the reply!

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default

    Hi,
    Code:
    G VAR BYTE
    i VAR BYTE
    
    For i = 0 to 7
    out_sig = G.0[i]
    NEXT
    I think that should do it.

    /Henrik.

  5. #5
    Join Date
    Sep 2010
    Posts
    50


    Did you find this post helpful? Yes | No

    Default

    Looks like that works!

    Da VAR BYTE
    Ea VAR BYTE
    i VAR BYTE
    Da=%10011100

    Ea=Da

    FOR i=0 to 6 STEP 2
    out_sig=Ea.0(i)
    PAUSEUS 100
    out_sig=Ea.0(i+1)
    pauseus 100
    NEXT i

    Thanks for you help!

Members who have read this thread : 1

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts