ArrayWrite question


Results 1 to 6 of 6

Threaded View

  1. #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

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 : 1

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