+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2010
    Posts
    15

    Default Copying Array to Array

    I am having trouble copying from one array to another.

    if I do this it works:

    Code:
    array1   VAR BYTE [30]
    CopyMe VAR BYTE[30]
    
    For I = 0 to 29
     array1[I] = CopyMe[I]
    Next I
    If I try this it does not work:

    Code:
    Arraywrite Array1, [CopyMe\30]
    
    OR
    
    Arraywrite Array1, [CopyMe]



    I have even tried

    Code:
    ARRAYWRITE Array1, 30, [CopyMe]
    And

    Code:
    ARRAYWRITE Array1, [STR CopyMe\30]
    But these result in compile errors or in the later example, code not functioning correctly.

    What am I missing with the Arraywrite command?

    ARRAYWRITE ArrayVar, length, label, [data]

    ???

    Thanks
    Last edited by vamtbrider; - 23rd April 2010 at 16:05. Reason: Added declaration of arrays

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,735

    Default

    Which version of PBP do you own?

    Ioannis

  3. #3
    Join Date
    Mar 2010
    Posts
    15

    Default

    running version 2.6

  4. #4
    Join Date
    Jul 2003
    Posts
    2,405

    Default

    Works fine here!
    Code:
    String1 Var Byte(26)
    String2 Var Byte(26)
    Index Var Byte
     
       PAUSE 5000
       Hserout ["Testing",13,10]  
     
    Main:   
       Clear     ' Clear RAM before entry
     
       ' Load String1 with data
       ARRAYWRITE String1,["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
     
       ' Show what's in String1  
       Hserout [13,10,"String1 = "]
       For Index = 0 TO 25
           Hserout [String1(Index)]
       Next Index
     
       ' Copy String1 to String2
       ARRAYWRITE String2, [STR String1\26]
     
       ' Show what's in String2 
       Hserout [13,10,"String2 = "]
       For Index = 0 TO 25
           Hserout [String2(Index)]
       Next Index
       Pause 500
       Goto Main
    Returns;
    Code:
    Testing
    String1 = ABCDEFGHIJKLMNOPQRSTUVWXYZ
    String2 = ABCDEFGHIJKLMNOPQRSTUVWXYZ
    Last edited by Bruce; - 23rd April 2010 at 23:51. Reason: Result
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  5. #5
    Join Date
    Mar 2010
    Posts
    15

    Default

    Thanks for the response Bruce. I will try your example when I get to my bench later tonight.

    For some reason I am having a hard time getting my head around how PBP handles arrays and formatting (DEC, STR, HEX, etc.)

    Here is what I am attempting:
    From VB using USB I pass 64 bytes of data that contain numbers in the range of 0-255
    I assume this shows up in the PIC USBRXBuffer (var from DT and Mistere demos) in hex form of 0x00 through 0xFF.

    For example,
    PC side:
    Bufferout(2) = 150
    Bufferout(3) = 200
    Bufferout(4) = 8
    .
    .
    .
    Bufferout(63) = 233
    On the PIC side the USBRXBuffer needs to be copied into another array, USBDataIn. I then use the data in USBDataIn to make program decisions and store some of the data in EEPROM.

    If I use
    Code:
    ARRAYWRITE USBDataIn, [USBRXBuffer]
    I get random data in the USBDataIn array. By random I mean I can not make the data look anything like the data sent from the PC. This would make sense since I never specified a length for the Arraywrite command.

    If I use the for...next loop method then the data in USBDataIn matches what came from the PC.

    If I try to do the
    Code:
    ARRAYWRITE USBDataIN, [STR USBRXBuffer\24]
    the processor runs off into la la land. It looks like that method should work, so I guess I need to fire up the debugger and see where the code is getting lost.

    So what would happen if you filled your array this way:

    Code:
    For I = 0 to 25
      String1(I) = I * 10
    Next I
    So instead of having "ABCDE..." it now has (0,10, 20, 30...250)

    Does the
    Code:
    ' Copy String1 to String2
       ARRAYWRITE String2, [STR String1\26]
    produce an output of 0,10,20,30,40...250?

Members who have read this thread : 0

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

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