Shop OBEX P1 Docs P2 Docs Learn Events
file command propeller help! — Parallax Forums

file command propeller help!

SovrSovr Posts: 12
edited 2011-09-08 20:55 in Propeller 1
hello, can anyone show me a sample code using the "file" command to import an external dat from a file? if so how do you even set up a file to have a dat object stored in it? Thank you very much for your help :smile:

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-09-08 20:55
    First of all, you have to understand that the "FILE" statement inserts the entire specified file into the binary output of the compiler. You're not importing source code into the source program like an "include" statement might do. The inserted file might be a compiled Spin program or it might be some other binary file. It could be text for your program to scan or something to copy into a separate flash memory using routines in your program. One example might be:
            DAT
    filestart:
            FILE   "someFile.txt"   ' a text file for example
            BYTE   0   ' marks the end of the file
    
    PUB displayIt | ptr, char
       ptr := @filestart
       repeat while char := byte[ptr++]   ' stop at zero byte
          serial.tx(char)   ' assume we're transmitting to a PC via FullDuplexSerial
    
Sign In or Register to comment.