2D Byte Array Command


+ Reply to Thread
Results 1 to 4 of 4

Thread: 2D Byte Array Command1476 days old

  1. #1
    Prolific Poster pic-ignorant's Avatar
    Join Date
    Oct 2007
    Posts
    2,942
    Thumbs Up
    Received: 26
    Given: 31
    Total Downloaded
    926.61 MB

    0 Not allowed!

    Default 2D Byte Array Command

    Les,
    Would it be difficult to create a 2D Byte Array command as used in C?
    Something like this.

    Dim My2DArray [2][8] as byte

    {0x10, 0x18, 0xc3, 0x33, 0x02, 0x08, 0x00, 0x94},
    {0x10, 0x61, 0xef, 0x33, 0x02, 0x08, 0x00, 0x43}
    };

    I think you posted some code to implement this a while ago, but I can't find it. I would be very nice to have it as a command as above though.

    Thank You
    John

  2. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #2
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,704
    Thumbs Up
    Received: 361
    Given: 173
    Total Downloaded
    2.08 GB

    0 Not allowed!

    Default Re: 2D Byte Array Command

    I'm sure the 2 dimensional macros are installed with the compiler. In its includes directory. However the code below is what is contained in the two_dim_array.inc file. They are very easy, and very efficient to use:

    Code:
    $ifndef _Two_Dim_Array_inc_
    $define _Two_Dim_Array_inc_
    '
    '
    ' 2 dimensional arrays macros
    '
    ' Allows the creation and access of global two dimensional signed or unsigned Byte, Word, Dword, and Float arrays.
    ' Note that the arrays must be made global because the preprocessor has no knowledge of procedures and local variables
    '
    '----------------------------------------------------------------------------
    ' Create a 2 dimensional unsigned byte array
    ' Input     : pArrayName holds the name of the array
    '           : pDimX holds the Row index
    '           : pDimY holds the Column index
    ' Output    : None
    ' Notes     : None
    '
    $define Declare_ByteArray2(pArrayName, pDimX, pDimY) '
        Dim pArrayName[pDimX * pDimY] As Byte            '
        Symbol pArrayName##YLength = pDimY
    '
    '----------------------------------------------------------------------------
    ' Create a 2 dimensional signed byte array
    ' Input     : pArrayName holds the name of the array
    '           : pDimX holds the Row index
    '           : pDimY holds the Column index
    ' Output    : None
    ' Notes     : None
    '
    $define Declare_SByteArray2(pArrayName, pDimX, pDimY) '
        Dim pArrayName[pDimX * pDimY] As SByte            '
        Symbol pArrayName##YLength = pDimY
    '
    '----------------------------------------------------------------------------
    ' Access a 2 dimensional signed or unsigned byte array
    ' Input     : pArrayName holds the name of the array
    '           : pDimX holds the Row index
    '           : pDimY holds the Column index
    ' Output    : The contents of the array's element
    ' Notes     : None
    '
    $define ByteArray2(pArrayName, pDimX, pDimY) pArrayName[pDimY + (pDimX * pArrayName##YLength)]
    '
    '----------------------------------------------------------------------------
    ' Create a 2 dimensional unsigned word array
    ' Input     : pArrayName holds the name of the array
    '           : pDimX holds the Row index
    '           : pDimY holds the Column index
    ' Output    : None
    ' Notes     : None
    '
    $define Declare_WordArray2(pArrayName, pDimX, pDimY) '
        Dim pArrayName[pDimX * pDimY] As Word            '
        Symbol pArrayName##YLength = pDimY
    '
    '----------------------------------------------------------------------------
    ' Create a 2 dimensional signed word array
    ' Input     : pArrayName holds the name of the array
    '           : pDimX holds the Row index
    '           : pDimY holds the Column index
    ' Output    : None
    ' Notes     : None
    '
    $define Declare_SWordArray2(pArrayName, pDimX, pDimY) '
        Dim pArrayName[pDimX * pDimY] As SWord            '
        Symbol pArrayName##YLength = pDimY
    '
    '----------------------------------------------------------------------------
    ' Access a 2 dimensional signed or unsigned word array
    ' Input     : pArrayName holds the name of the array
    '           : pDimX holds the Row index
    '           : pDimY holds the Column index
    ' Output    : The contents of the array's element
    ' Notes     : None
    '
    $define WordArray2(pArrayName, pDimX, pDimY) pArrayName[pDimY + (pDimX * pArrayName##YLength)]
    '
    '----------------------------------------------------------------------------
    ' Create a 2 dimensional unsigned dword array
    ' Input     : pArrayName holds the name of the array
    '           : pDimX holds the Row index
    '           : pDimY holds the Column index
    ' Output    : None
    ' Notes     : None
    '
    $define Declare_DwordArray2(pArrayName, pDimX, pDimY) '
        Dim pArrayName[pDimX * pDimY] As Dword            '
        Symbol pArrayName##YLength = pDimY
    '
    '----------------------------------------------------------------------------
    ' Create a 2 dimensional signed dword array
    ' Input     : pArrayName holds the name of the array
    '           : pDimX holds the Row index
    '           : pDimY holds the Column index
    ' Output    : None
    ' Notes     : None
    '
    $define Declare_SDwordArray2(pArrayName, pDimX, pDimY) '
        Dim pArrayName[pDimX * pDimY] As SDword            '
        Symbol pArrayName##YLength = pDimY
    '
    '----------------------------------------------------------------------------
    ' Access a 2 dimensional signed or unsigned dword array
    ' Input     : pArrayName holds the name of the array
    '           : pDimX holds the Row index
    '           : pDimY holds the Column index
    ' Output    : The contents of the array's element
    ' Notes     : None
    '
    $define DwordArray2(pArrayName, pDimX, pDimY) pArrayName[pDimY + (pDimX * pArrayName##YLength)]
    '
    '----------------------------------------------------------------------------
    ' Create a 2 dimensional float array
    ' Input     : pArrayName holds the name of the array
    '           : pDimX holds the Row index
    '           : pDimY holds the Column index
    ' Output    : None
    ' Notes     : None
    '
    $define Declare_FloatArray2(pArrayName, pDimX, pDimY) '
        Dim pArrayName[pDimX * pDimY] As Float            '
        Symbol pArrayName##YLength = pDimY
    '
    '----------------------------------------------------------------------------
    ' Access a 2 dimensional float array
    ' Input     : pArrayName holds the name of the array
    '           : pDimX holds the Row index
    '           : pDimY holds the Column index
    ' Output    : The contents of the array's element
    ' Notes     : None
    '
    $define FloatArray2(pArrayName, pDimX, pDimY) pArrayName[pDimY + (pDimX * pArrayName##YLength)]
    
    $endif  ' _Two_Dim_Array_inc_

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #3
    Member amateurtje's Avatar
    Join Date
    Aug 2008
    Posts
    136
    Thumbs Up
    Received: 4
    Given: 3
    Total Downloaded
    484.91 MB

    1 Not allowed!

    Default Re: 2D Byte Array Command

    I know it is an old thread and I searched the complete site (I think) but I do not get it to work. I can not find the file two_dim_array.inc anwywhere. also the wiki example code gives me troubles.. (http://www.protonbasic.co.uk/content...nsional-Arrays) while I do not ue the development board. So a lot of the variables are not defined and I do not know as what to define them.

    My main problem is that I need to receive (at this moment) about 600 bytes at 1 time. Fo my next challange, this will be more... (about max 150*16 = 2400)

    While I can not make an array of 600 byte, I was thinking about a 2 dimensional array.
    I know I can also use from a counter a new array but I do not know if that makes it easier, more readible and more efficient.

    Any ideas?

    What is the best and easiest to use?

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #4
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,704
    Thumbs Up
    Received: 361
    Given: 173
    Total Downloaded
    2.08 GB

    0 Not allowed!

    Default Re: 2D Byte Array Command

    A 2 dimensional array still takes the same amount of RAM as 2 arrays.

    The compiler allows an array to be as large as the RAM on the device will carry.

    I am working on adding multi-dimensional arrays to the compiler as standard, but it is on the bottom of the "To Do" list because thay are, generally, not needed. Unless copying and pasting from PC programs using C or C++, then the extra delay and bulk of manipulating the dimensions in the underlying asm code doesn't seems to matter, because the "copy and paste" user has no idea what is happening anyway. :-)

  8. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 2 users browsing this thread. (0 members and 2 guests)

     

Similar Threads

  1. Byte array terminating early
    By Jezsmith in forum Proton 24
    Replies: 8
    Last Post: 3rd November 2013, 10:57
  2. [SOLVED !] Byte Array to Bit
    By fgcity in forum Proton Plus Compiler v3
    Replies: 0
    Last Post: 3rd February 2012, 14:39
  3. Compressing a byte array
    By mhanley in forum The Lounge
    Replies: 3
    Last Post: 24th June 2010, 20:41
  4. 18F2550 string and byte array
    By sahin5002 in forum Proton Plus Compiler v3
    Replies: 0
    Last Post: 28th January 2010, 15:56
  5. Using an alias to a byte array element ? is it possible ?
    By Kapitan in forum Proton Plus Compiler v3
    Replies: 6
    Last Post: 12th March 2009, 13:39

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