Announcement

Collapse
No announcement yet.

How to build strings

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to build strings

    Hi,my problem is when I use "file_Open(fname, mode)".
    I want to build a string with the name "fname", but I can't do it directly.

    My program is this:
    I want to create a file in SD and write on this file 4 bytes like a chars.

    func WritedSD(var name, var byte1, var byte2, var byte3, var byte4)

    var string[20];

    to(string); print("File");
    to(APPEND); putch(Cnumber); //ASCII valueto(APPEND); putch(Dnumber); //ASCII valueto(APPEND); putch(Unumber); //ASCII valueto(APPEND); print(".txt");

    hndl := file_Open(string, 'w'); // Create file with fname=string file_PutC(byte1, hndl); //Write SD file_PutC(byte2, hndl); file_PutC(byte3, hndl); file_PutC(byte4, hndl); file_Close(hndl); endfunc


    My program create a file, but without name, and I can see your size (4 bytes) but I can't open this file and all files have the same name therefore I only can create 1 file.



    If I use this program, run perfectly.


    func WritedSD(var name, var byte1, var byte2, var byte3, var byte4)

    var string;

    string:="File123.txt";
    hndl := file_Open(string, 'w'); // Create file with fname=string file_PutC(byte1, hndl); //Write SD file_PutC(byte2, hndl); file_PutC(byte3, hndl); file_PutC(byte4, hndl); file_Close(hndl); endfunc

    Can anyone help me? Thank.
    Sorry for my english.

  • #2


    Try

    hndl := file_Open(str_Ptr(string), 'w'); // Create file with fname=string
    Mark

    Comment


    • #3


      Thank you!, run perfectly

      Comment

      Working...
      X