Shift starting position for ARRAYWRITE?


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Feb 2013
    Posts
    1,078

    Default Shift starting position for ARRAYWRITE?

    Hello.

    Say I have some array, with say, 32 byte length.
    I want to write a text string "Hello world!" starting from position, 20
    How should I?
    I know that I can break the text apart and write each letter to each address individually, but that's not practical.

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,793


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: Shift starting position for ARRAYWRITE?

    From the manual:

    7.6.3 Sub-Arrays within Arrays

    Consider the following variable declarations:

    all_data VAR BYTE[48] ' Array for all my data
    samples VAR all_data[0] ' 16 bytes for ADC samples
    calcs VAR all_data[16] ' 16 bytes for calculated values
    readings VAR all_data[32] ' 16 bytes for port readings


    Ioannis

  3. #3
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Shift starting position for ARRAYWRITE?

    And how that going to help?
    I want to change that offset runtime...

  4. #4
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: Shift starting position for ARRAYWRITE?

    If you know the offset is 20, give that byte a name as Ioannis suggested. This will act as a place marker for your start point. You can also use a variable start point:
    Code:
    CondVar = inputVal
    TXREG = all_data[20+CondVar]
    Last edited by mpgmike; - 11th August 2022 at 17:41.

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,516


    Did you find this post helpful? Yes | No

    Default Re: Shift starting position for ARRAYWRITE?

    There's no way to do that directly using ARRAYWRITE (perhaps there is, by preloading system variables, but I'm not going to research that). But if you have some RAM to spare you can:
    Code:
    ActualArray VAR BYTE[32]
    TempArray   VAR BYTE[16]
    Start	    VAR BYTE
    idx	    VAR BYTE
    
    
    Main:
      ArrayWrite TempArray,["Hello World!", 0]	' What you want written, note the null at the end = important!
      Start = 10                                    ' Where you want it written in the main array, make sure to not go out of bounds.
      GOSUB WriteArray
    END
    
    WriteArray:
      idx = 0
      WHILE TempArray[idx] <> 0
        ActualArray[Start + idx] = TempArray[idx]
        idx = idx + 1
      WEND
    RETURN

  6. #6
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Shift starting position for ARRAYWRITE?

    Well the situation is as follows, I have an array, which is used as a display buffer - separate routine reads data from it, decodes and sends to display.
    I want to do some text scrolling, so want to write same line of text into that array, with some offset, to create the scroll effect.
    Name:  array.jpg
Views: 179
Size:  406.8 KB

  7. #7
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,516


    Did you find this post helpful? Yes | No

    Default Re: Shift starting position for ARRAYWRITE?

    And I belive what I showed can be made to do that - not that it neccesarily is the best way to achieve your end result but never the less :-)

    Instead of "write same line of text into that array, with some offset" modify the actual display routine so that it doesn't start displaying from index 0 of the screen buffer.

  8. #8
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Shift starting position for ARRAYWRITE?

    Yes that is what I planned.
    To make display buffer 24 byte wide, instead of 8, and "read" it with changing offset, to achieve the scrolling effect. But this means that text data should be written into "center" of array - from 8th position to 16th.

Similar Threads

  1. bit position variable
    By dsicon in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 16th December 2012, 22:41
  2. Question about ARRAYWRITE
    By circuitpro in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 30th July 2010, 22:00
  3. Changing position of program code
    By aerostar in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 15th December 2006, 08:34
  4. how to know servo position on lcd?
    By macx75 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 23rd March 2006, 23:52
  5. Read cursors position on LCD?
    By lab310 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 13th April 2005, 14:20

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