Announcement

Collapse
No announcement yet.

Read File dynamically

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

  • Read File dynamically

    Hi, once that I can get the filename and display it, I'd like to know how to read it, currently I'm having the FE_FILE_NOT_FOUND code when I try to open it.

    the filename variable returns the position of the pointer and using the str_Printf I can show the name, and if I try to store the name into another variable to set it as parameter it doesn't work.

    Code:
     filename:=getFileName(fileIndex);
                    to(nametmp);str_Printf(&filename,"%s");
                    hndl1:=file_Open(nametmp,'r');
                    fError:=file_Error();
    do you have an example? it seems all the examples use a hardcoded name.

    Regards

  • #2
    Hello Ununezta,

    You can try using the string pointer (getFileName return) directly on the file_Open function
    without needing to formatted printing it into another variable.

    On the other hand, you can use a string pointer function str_Ptr.

    You can check the code snippet I've added below for reference

    Code:
    var tempFileName[7], tempFileNamePtr;
    
        tempFileNamePtr := str_Ptr(tempFileName);
        to (tempFileName); putstr(tempDate);
        to (APPEND); putstr(".pln");
    
        // Access file
        if (file_Exists(tempFileNamePtr))
            var file;
            file := file_Open(tempFileNamePtr, 'r');
            file_Read(plansBuffer,200,file);
            file_Close(file);
    This snippet was taken from the project : https://www.4dmakers.net/projects/de...igital-planner

    I hope this helps,

    Best regards,

    Comment


    • #3
      I swear I tried just setting the filename without formatting it and didn't work, but that solves the problem.

      Thanks a lot for your help!.

      Best Regards.

      Comment


      • #4
        Hello Ununeta,

        Glad to hear that you made it work.
        Just take note that accessing files should be done by using byte pointer to the string name.

        Best Regards,
        Last edited by Jerson; 12th October 2018, 03:14 PM.

        Comment


        • #5
          Hi again,

          Can you please help me out to understand about the HiWord and LoWord?

          if I have a file with a Size of 1.3 MB, how can I split it at the moment of read it? I think it can be possible using the file_Index command. but how can I get the full size?

          is there a formula?

          Regards

          Comment


          • #6
            Hello Ununezta,

            Correct me if I'm wrong, so you are intending to point at the middle of the file under read mode and then split the file into two parts?

            Yes, you could try using file_Seek or file_Index for pointing to your desired address, then start reading from there.

            All of the information regarding the use of the two functions can be found in the Diablo16_InternalFunctions_R_2_0.pdf

            Best Regards,

            Comment

            Working...
            X