Exporting the data from an array

Hello, I’m new to robot studio and the programming language rapid.

I have created a distance measurement for my robot’s tcp and have put the data in an array. The only way I know to access it is from the flexpendant.

But is there any way to export the data in my array? I would like to analyse it in a different program.

Hi …
You can export to a file.
Look in the help for the Open function.
With it you can create, write, add content…
This is a good start.
Here is a small example:

    ! FUNCTION TO RETURN THE PATH OF THE NEWLY CREATED FILE ##################################################### 1.0 ####
    !       The FileNew function creates a new file with a specific name in the specified directory or in the default directory, depending on the conditions. If the file already exists,
    !       the function does nothing and returns the complete file path. If file access errors occur, they are handled in the error handling block.
    !       This function is designed to create a new file in a specified directory or in the default directory (HOME:), if the file does not exist.
    !       The variables 'fileIodevL' (file handle), 'pathL' (directory path), and 'isDirectoryOrFileL' (checks whether it is a directory or file) are used for
    !       data manipulation.
    !       The function checks if the parameter 'directoryPathP' (directory path) is provided. If provided, it checks if it is an existing directory using the
    !       'IsFile' function with the 'Directory' option. If it does not exist, it creates the directory and constructs the directory path (if provided) with a slash ("/") in the variable 'pathL'.
    !       It also checks if the file with the name 'fileNameP.conf' exists in the specified directory (pathL). If it does not exist, it creates it using the file handle 'Open'
    !       with the 'Append' option. After creating the file, it is immediately closed with 'Close' so that it can be manipulated by another function.
    !       The 'typeP' corresponds to the type of file to be saved. By default, saved files are of type '.data'.
    !       If the file was successfully created, the function returns the complete file path (pathL+fileNameP+typeL). Otherwise, it returns an empty string.
    !       There is an error handling block that specifically deals with the error 'ERR_FILEACC'. This error may occur if there is a file access issue. If this
    !       error occurs, the function will attempt to proceed to the next instruction using the 'TRYNEXT' command. This error usually occurs when attempting to open a non-existent file.
    !
    ! PARAMETERS:
    !   \string directoryPathP: If provided and it does not exist, creates the directory; otherwise, it just sets the path to it. If not provided, defaults to 'HOME:\'.
    !   string fileNameP: Name of the file to be saved.
    !   \string typeP: If provided, this type is used to save the file. By default, it saves as '.data'.
    !
    ! RETURN:
    !   Returns the file path.
    !
    ! USAGE EXAMPLE:
    !   MODULE ModPRG()
    !       VAR string directoryPathP;
    !       VAR string fileNameP;
    !       VAR string typeP;
    !
    !       PROC main()
    !           directoryPathP:="TEMP"
    !           fileNameP:="Parameter";
    !           typeP:=".sys";
    !
    !           TPErase;
    !           TPWrite FileNew(directoryPathP:=directoryPathP,fileNameP\typeP:=typeP);     ! >> ~ "TEMP/Parameters.sys"
    !           TPWrite FileNew(fileNameP\typeP:=typeP);                                    ! >> ~ "HOME/Parameters.sys"
    !           TPWrite FileNew(fileNameP);                                                 ! >> ~ "HOME/Parameters.data"
    !       ENDPROC
    !   ENDMODULE
    !
    ! LIMITATION:
    !   The input parameters "\string directoryPathP", "string fileNameP" and "\string typeP" are limited to 80 characters.
    !
    FUNC string FileNew(\string directoryPathP,string fileNameP\string typeP)
        ! ## ATTRIBUTES ##############################################################################
        VAR iodev fileIodevL;

        VAR string pathL:="";
        VAR string typeL:=".data";
        ! ## ATTRIBUTES ##############################################################################

        ! Checks for the existence of the DIRECTORY; if it does not exist, creates one in HOME:\ ...
        IF Present(directoryPathP) THEN
            MakeDir directoryPathP;

            pathL:=directoryPathP+"/";
        ENDIF

        IF Present(typeP) typeL:=typeP;

        ! Create file ...
        Open pathL\File:=fileNameP+typeL,fileIodevL\Append;

        ! ###### Writes your file ...
        ! If the file is open then insert a line at the end of the file ...
        Write fileIodevL,CDate()+"; "+CTime()+"; FILE;";
        Write fileIodevL,"----------; --------; ------------------;";
        Write fileIodevL,"... TEXT ...";
        Write fileIodevL," ";

        ! Close file
        Close fileIodevL;

        ! If the file was created, returns the path; otherwise, returns empty
        IF IsFile(pathL+fileNameP+typeL\RegFile) THEN
            RETURN pathL+fileNameP+typeL;
        ELSE
            RETURN "";
        ENDIF
    ERROR
        ! #############################################################################################
        ! POSSIBLE ERROR HANDLING
        ! #############################################################################################

        ! If an error is encountered, proceed to the next instruction ...
        IF ERRNO=ERR_FILEACC THEN
            TRYNEXT;
        ENDIF
    ENDFUNC

Good Work.

You want to analyze it in a different rapid program?

No I want to analyze the distance measurement in matlab