Shop OBEX P1 Docs P2 Docs Learn Events
Len of file dat — Parallax Forums

Len of file dat

bassmasterbassmaster Posts: 181
edited 2007-01-02 14:56 in Propeller 1
Any easy way to get the length of a binary file in memory when read.


DAT
···myfile file "myfile.bin"···



I can use windows explorer to get the size then hard code it, but that bites.


Sean

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-01-01 23:42
    You could try
    DAT
    myfile  file   "myfile.bin"
    sizeOf  long  sizeOf - myfile
    
    


    I haven't tried it, but it ought to work.
  • Ym2413aYm2413a Posts: 630
    edited 2007-01-02 00:08
    The file formats I made for use with the propeller all have the file size in the header.
    But normally what I do is just right click on a file and read its properties.
    It's pretty fast and only takes a second.
  • Ym2413aYm2413a Posts: 630
    edited 2007-01-02 00:17
    BassMaster.
    Sizeof is a pointer.

    DAT
    myfile file "myfile.bin"
    varsize long varsize - myfile

    This would do the same thing.

    I'm not sure if you have to use the @ symbol though with that code since they are pointers.

    DAT
    myfile file "myfile.bin"
    mysize long @mysize - @myfile

    I haven't tried the above either, But it's a good starting point.
  • bassmasterbassmaster Posts: 181
    edited 2007-01-02 00:21
    Ym, that is ok, as long as the file does not change. I am curious if I could make a program that would take a file regardless of size by the same name, and not add any new code to re-load it.
  • bassmasterbassmaster Posts: 181
    edited 2007-01-02 00:27
    mysize long @mysize - @loadme

    works perfectly... thanks...
  • Ym2413aYm2413a Posts: 630
    edited 2007-01-02 14:56
    Your welcome.
Sign In or Register to comment.