2D Byte Array Command


+ Reply to Thread
Results 1 to 2 of 2

Thread: 2D Byte Array Command1305 days old

  1. #1
    Prolific Poster pic-ignorant's Avatar
    Join Date
    Oct 2007
    Posts
    2,938
    Thumbs Up
    Received: 25
    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,513
    Thumbs Up
    Received: 318
    Given: 152
    Total Downloaded
    1.99 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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 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. [SOLVED !] 18F2550 string and byte array
    By sahin5002 in forum Proton Plus Compiler v3
    Replies: 0
    Last Post: 28th January 2010, 15:56
  5. [SOLVED !] 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