Shop OBEX P1 Docs P2 Docs Learn Events
SD3.01FATEngine open and newfile hangups — Parallax Forums

SD3.01FATEngine open and newfile hangups

R PankauR Pankau Posts: 127
edited 2011-04-14 12:56 in Propeller 1
I'd like to try to open a file, and if it does not exist then create it then open it.

The problem appears to be that if the file does not exist then it hangs at the openFile and I never get to newFile. I've tried to add the \abort trap but it does not help.

If the file exists then it opens and I can write ok.

strng.stringCopy(@opened_file, strng.trimString(sd.openFile(@File_name , "A")))
open := strng.stringCompareCI(@opened_file ,@File_name)
IF (open <> 0)
  (sd.newFile(@File_name)

DAT
File_name  byte "LOGGER.TXT", 0

Comments

  • R PankauR Pankau Posts: 127
    edited 2011-04-14 12:53
    I may have the problem solved.

    evidently the abort trap does not return a string and the string functions get carried away with some other data.
    this seems to work
          IF (byte[\sd.openFile(@File_name, "A")] <> "L")
              USART.str(string("Open file failed   ",13,10))
              USART.str(string("Trying to create file...   ",13,10)) 
              USART.str(sd.newFile(@File_name))
           else
              USART.str(string("File Opened...   ",13,10))
              open := 0
    
  • R PankauR Pankau Posts: 127
    edited 2011-04-14 12:56
    so my next question is:
    How do I turn off the "UNSOLVED" flag from this post?
Sign In or Register to comment.