ArrayWrite question


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107

    Default ArrayWrite question

    If I use the command:

    ARRAYWRITE TestArray,[SKIP N,$81,$CF,$4D....]

    Where N = $A,

    Will it start filling TestArray with $81 at location $A, and leave locations 0-9 untouched?
    Charles Linquist

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    ARRAYREAD has a SKIP modifier.
    ARRAYWRITE does not.

    Maybe you could ...
    Code:
    ARRAYWRITE TestArray,[STR TestArray\N,$81,$CF,$4D...]
    Which writes the first N bytes back to themselves.
    <br>
    DT

  3. #3
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    So, in the above example,

    ArrayRead [SKIP N,$81,$CF,4D...]

    Would give me an array with $81 in location $A, and locations 0-9 untouched?
    Charles Linquist

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    NO, that would give compile errors.
    ARRAYREAD gets data from an array. So you can't have constants as parameters.

    ARRAYWRITE puts data in an array.

    Consider the following program ...
    Code:
    TestArray  VAR BYTE[26]
    N VAR BYTE
    N = 9
    
        ARRAYWRITE TestArray,["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
        HSEROUT ["Before-",STR TestArray\26,13,10]
    
        ARRAYWRITE TestArray,[STR TestArray\N,"12345678"]
        HSEROUT ["After -",STR TestArray\26,13,10]
    The output would look like this, and the data can be moved by changing the value of N. ...
    Code:
    Before-ABCDEFGHIJKLMNOPQRSTUVWXYZ
    After -ABCDEFGHI12345678RSTUVWXYZ
    If the data is always going to be placed at the same location, you can do it this way...
    Code:
    TestArray  VAR BYTE[26]
    StartPos   VAR TestArray[9]
    
        ARRAYWRITE TestArray,["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
        HSEROUT ["Before-",STR TestArray\26,13,10]
    
        ARRAYWRITE StartPos,["12345678"]
        HSEROUT ["After -",STR TestArray\26,13,10]
    Resulting in the same thing ...
    Code:
    Before-ABCDEFGHIJKLMNOPQRSTUVWXYZ
    After -ABCDEFGHI12345678RSTUVWXYZ
    <hr>ADDED:
    You can also do the fixed position data like this ...
    Code:
    TestArray  VAR BYTE[26]
    
        ARRAYWRITE TestArray,["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
        HSEROUT ["Before-",STR TestArray\26,13,10]
    
        ARRAYWRITE TestArray(9),["12345678"]
        HSEROUT ["After -",STR TestArray\26,13,10]
    Unfortunately, you can not do it like this, which would be very handy...
    Code:
    TestArray  VAR BYTE[26]
    N VAR BYTE
    N = 9
    
        ARRAYWRITE TestArray,["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
        HSEROUT ["Before-",STR TestArray\26,13,10]
    
        ARRAYWRITE TestArray(N),["12345678"]
        HSEROUT ["After -",STR TestArray\26,13,10]
    hth,
    Last edited by Darrel Taylor; - 10th January 2010 at 21:43. Reason: Added:
    DT

  5. #5
    Join Date
    May 2007
    Location
    Republic Serbia
    Posts
    105


    Did you find this post helpful? Yes | No

    Thumbs up

    As our friend Darrel Taylor write

    Here is example :
    If you have array = "ABCDE"
    And you do next :
    Code:
    A var byte[5]
    B0 var byte : B0 = 10
    ARRAYWRITE A, [DEC B0]
    You will have next :
    array = "10CDE"
    Best regards to all and special to Darrel
    Attached Images Attached Images  
    Last edited by phoenix_1; - 10th January 2010 at 21:25.

  6. #6
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    Thanks to both of you!
    Charles Linquist

Similar Threads

  1. ADCIN question
    By Greg McFadden in forum General
    Replies: 4
    Last Post: - 16th September 2008, 02:53
  2. really simple, dumb question
    By picster in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 3rd March 2007, 22:02
  3. FREQOUT - PWM question
    By Etcho in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 25th February 2007, 23:51
  4. Question for a math guru
    By Christopher4187 in forum General
    Replies: 3
    Last Post: - 22nd November 2006, 09:45
  5. Please answer my first question
    By John_001 in forum Off Topic
    Replies: 1
    Last Post: - 15th September 2006, 06:49

Members who have read this thread : 2

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

Posting Permissions

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