Array manipulation


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Array manipulation

  1. #1
    Sai Guest

    Array manipulation


    I have a byte array with a filename+filedelimiter+filedata in it.
    once i get the filename, i want to drop it and the delimiter and write out
    the file data to a file. i have to loop thru the array to do this now.

    i write,

    for 1=filedatastartposition to endoffileposition
    put #1,bytearray(i)
    next

    can anyone tell me how i can speed this up since its really slow for large
    files. ??

    the files could be text, images..anything posted over the web


  2. #2
    Kenny Acock Guest

    Re: Array manipulation


    Here's another approach which may or may not be better:

    lFilePosition = len(sFileName) + len(sFileDelimiter)
    Put #lFileNumber, Mid$(ayByteArray, lFilePosition)

    Here's the logic behind this code snippet:

    Arrays can be converted to strings and back. Each character in the string
    holds two bytes. Assuming that the File Delimiter is a string character
    you can calculate the starting character of the data. You then use the Mid$
    function to extract the rest of the file. I don't know if this will work
    for your situation or not. If it does work I don't know if it will be faster.
    There's only one way to find out, though.

    --Kenny

    "Sai" <sramani@lumedx.com> wrote:
    >
    >I have a byte array with a filename+filedelimiter+filedata in it.
    >once i get the filename, i want to drop it and the delimiter and write out
    >the file data to a file. i have to loop thru the array to do this now.
    >
    >i write,
    >
    >for 1=filedatastartposition to endoffileposition
    >put #1,bytearray(i)
    >next
    >
    >can anyone tell me how i can speed this up since its really slow for large
    >files. ??
    >
    >the files could be text, images..anything posted over the web
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center