Shop OBEX P1 Docs P2 Docs Learn Events
Variable file name with a memory stick — Parallax Forums

Variable file name with a memory stick

dodgerdodger Posts: 37
edited 2009-05-30 07:20 in Propeller 1
Hello,

I would like to open a new file everytime I press a momentary push button.· I can currently close and open a file this way when the file name is constant.· I have tried the format object to create a file name.· I can see the first file when i open the memory stick but there is no data saved to it.·Could someone point me in the right direction?·

Thanks

Comments

  • SRLMSRLM Posts: 5,045
    edited 2009-05-30 01:52
    What sort of code are you using right now? I'd probably just reserve a spot in memory, then write an ASCII string there (where part of that is the variable value), and give that as a filename. There might already be code out there to do that.
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2009-05-30 07:20
    If I recall correctly, the Format object cprintf method can do it:

    OBJ fmt:Format
    buffer byte[noparse][[/noparse]13]

    fmt.cprintf(@buffer,string("FILE%04.4d.TXT"),id)

    will create a null terminated filename
    FILE0000.TXT if id is 0
    FILE0001.TXT if id is 1
    etc.
    in byte array buffer

    regards peter

    Post Edited (Peter Verkaik) : 5/30/2009 7:31:14 AM GMT
Sign In or Register to comment.