Setting whole content of array variable in a simple way?


+ Reply to Thread
Results 1 to 13 of 13
  1. #1
    Join Date
    Feb 2013
    Posts
    1,078

    Default Setting whole content of array variable in a simple way?

    Hello.

    Say I have 24 byte array, called "time"
    I want to set it's content to 32 (That's ASCII code for space)
    TIME=32 Does not work. I have to use:

    arraywrite time, [32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 ,32,32,32,32,32,32,32]

    This is weird, and will get even weirder, with longer arrays.
    Yes I know there are FOR-NEXT, DO-LOOP and other ways of filling array, but I'm curious, why there's no single statement for doing that?

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,389


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

    Default Re: Setting whole content of array variable in a simple way?

    one of pbp3's most redeeming features is USERCOMMAND , If you feel a command is missing then simply create your own
    a MEMSET cmd that emulates the C memset(array_name,fill_chr,length) function could easily be created
    start here
    Warning I'm not a teacher

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: Setting whole content of array variable in a simple way?

    page 119 of the manual:

    rep 32\24

    Ioannis

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


    Did you find this post helpful? Yes | No

    Default Re: Setting whole content of array variable in a simple way?

    Thanks!
    That appears to be at least partial, but still usable solution.
    But arraywrite must always start from position 0 of array, right?

    p.s. in PBP_Manual_0609_260 on page 119 it's all about LCDOUT.

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Default Re: Setting whole content of array variable in a simple way?

    if the value bytes are constants ...
    you could use POKECODE ...

    i.e.
    '************************************************* ****************************
    'Fading_Table
    '************************************************* ****************************
    ' 0 1 2 3 4 5 6 7 8 9
    '
    Pokecode @881, 24, 27, 29, 32, 35, 38, 41, 44, 47,_ ' 30
    50, 54, 57, 60, 64, 68, 71, 75, 79, 83,_ ' 40
    87, 91, 96,100,104,109,113,118,123,127,_ ' 50
    132,137,142,147,153,158,163,169,174,180,_ ' 60
    186,191,197,203,209,212,217,245,250, 1,_ ' 70
    7, 13, 21, 30, 39, 48, 57, 24, 25, 26,_ ' 80
    27, 28, 29, 30, 31, 32, 33, 34, 35, 36,_ ' 90
    37, 38, 39, 40, 41, 43, 44, 45, 46, 48,_ ' 100
    49, 50, 52, 53, 54, 56, 57, 59, 60, 62,_ ' 110
    63, 65, 67, 68, 70, 72, 73, 75, 77, 79,_ ' 120
    81, 83, 84, 86, 88, 90, 92, 94, 97, 99,_ ' 130
    101,103,105,107,110,112,114,117,119,122,_ ' 140
    124,126,129,132,134,137,139,142,145,148,_ ' 150
    150,153,156,159,162,165,168,172,176,180' 160
    see § 5.54 of the LAST version Holy Manual ...

    BUUUUUT ... Which version of PBP do you use ???
    might be 2.60 ?

    Alain
    Last edited by Acetronics2; - 4th June 2023 at 22:12.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: Setting whole content of array variable in a simple way?

    Quote Originally Posted by CuriousOne View Post
    Thanks!
    That appears to be at least partial, but still usable solution.
    But arraywrite must always start from position 0 of array, right?

    p.s. in PBP_Manual_0609_260 on page 119 it's all about LCDOUT.
    I always refer to the latest Manual.

    Yes, the command is referenced to the position 0. If you need something else then you have other options:

    1. USERCOMMAND and do something on your own
    2. Alias to another array.

    But you were specific weren't you? Fill an array with a specific character.

    Ioannis
    Last edited by Ioannis; - 5th June 2023 at 10:18.

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


    Did you find this post helpful? Yes | No

    Default Re: Setting whole content of array variable in a simple way?

    I'm using this manual : https://melabs.com/downloads/PBP_Manual_0609_260.pdf

    I know what is the USERCOMMAND.
    I had similar USR on ZX Spectrum for ASM code or DEF FN for Basic code

  8. #8
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: Setting whole content of array variable in a simple way?

    Which version of PBP do you own?

    Ioannis

  9. #9
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Default Re: Setting whole content of array variable in a simple way?

    Quote Originally Posted by Ioannis View Post
    Which version of PBP do you own?

    Ioannis
    Hi, Ioannis

    this is obviously a link to the 2.60 Version Manual ... dated 2009/06 ...

    a true Vintage one

    Let's suppose PBP Version is the same 2.60 version ( not guaranteed ... )

    Alain
    Last edited by Acetronics2; - 8th June 2023 at 06:49.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  10. #10
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: Setting whole content of array variable in a simple way?

    If he uses Arrayread/Arraywrite, I doubt that...

    Ioannis

  11. #11
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Default Re: Setting whole content of array variable in a simple way?

    Quote Originally Posted by Ioannis View Post
    If he uses Arrayread/Arraywrite, I doubt that...

    Ioannis
    ARRAYREAD / ARRAYWRITE belong to the V 2.60 manual ... I have this printed manual in front of me ...
    I also have HUGE archives ( My SSD holds ... a bit more than 1.4 TB !!! )

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  12. #12


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

    Default Re: Setting whole content of array variable in a simple way?

    Preview
    Default Re: Setting whole content of array variable in a simple way?
    from the
    ' MPASM™ Assembler,
    MPLINK™ Object Linker,
    MPLIB™ Object Librarian
    User’s Guide'

    you might be able to use the FILL command....... something like this...calling gosub FILLING

    Code:
     
    FILLING:
            ASM
                 org: _time       'location by the name of your-array
                 fill  32, 24        'puts dec 32 in next 24 locations
           ENDASM
     Return
    this is one of the directives of MPASM, hopefully the '_array' with the underscore IS the location in ram of your array

  13. #13
    Join Date
    May 2013
    Location
    australia
    Posts
    2,389


    Did you find this post helpful? Yes | No

    Default Re: Setting whole content of array variable in a simple way?

    hopefully the '_array' with the underscore IS the location in ram of your array
    which won't happen because FILL works in Program Memory [code space]
    Warning I'm not a teacher

Similar Threads

  1. Variable not getting value from array...?
    By Ioannis in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 3rd May 2016, 23:58
  2. Simple Array Demo
    By Archangel in forum Code Examples
    Replies: 5
    Last Post: - 15th February 2010, 04:46
  3. Variable in array
    By Gusse in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 22nd February 2009, 19:46
  4. Setting / resetting a variable bit within a byte
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 9th February 2008, 18:38
  5. Array to simple Variable converting
    By mrx23 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 2nd September 2006, 16:44

Members who have read this thread : 13

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