I’m having trouble with the dynamic file naming of Filescope Blocks in xPC Embedded Option. I would like the file name of a scope to increment each time the software boots so I can record data from multiple test runs.

I have added '_<%%%>' to the file name (now ‘ins_<%%%>’) and checked ‘auto restart’ and ‘dynamic file naming’ (not that I want to limit the size of each file with ‘auto restart’ but it is the only way to get the ‘dynamic file naming’ box to appear). If I boot the software 3 times I get one file named ins_001.dat with the correct data in it, one file named ins_002.dat that is empty and only 1KB in size, file ins_003.dat is missing.

I have also tried running the software without either 'auto restart' or 'dynamic file namining' checked but that doesn't work.

Unfortunately, I do not have a solution, only emphasis on the issue set forth by James above.

I am having a similar problem, only in my 2009a version, the initial file D_<%%%>.dat isn't even showing up. When I eliminate the '<%%%>', the first file saves with no problem. I do not have a 'dynamic file naming' option in 2009a, but I do not receive an error, the program builds, loads and executes.

The dynamic file naming enables additional files to be created when the max file size is reached for a given file. Autorestart is not for logging across power cycles.

Each time the xPC (FreeDOS) starts the application file, new (mostly empty) data files for the scopes are created, replacing the ones from the previous power cycle.

What I did:
To address the issue of preserving data between reboots, I modified the autoexec.bat file to backup my data files from the previous power cycle, before it loads the stand alone application. Due to FreeDOS command set limitations, I compiled an .exe that renames the files to include the current day & time. The autoexec calls my .exe to rename the files and then moves it to a data folder. I used the OpenWatcom compiler/IDE to make a compatible 32-bit DOS executable.

Keep in mind that the filenames are limited to 8 characters, not including the extension.

That sounds like a good work around which could save me a lot of time. Would you mind sharing your code with those of us less able to program?

Does your .exe preserve any element of the original file name? The reason I ask is that I log several scopes at once, so generate 5 .dat files simultaneously (ins.dat, ain.dat, din.dat, val.dat and cnt.dat), I would need them to end up with differing file names even though they were all created at the same time.

Thanks for posting the code. I had some trouble getting it running, reading up on it, it appears that my version of DOS is very basic an has only the internal commands; for example it can't handle the MOVE command.

To overcome the problem I wrote my own script (which took ages as I was clueless) using only the most basic DOS commands available. It is a bit crude in that it will only go up to 30 runs, but does that job for me. I had far flashier scripts running in cmd.exe and command.exe (for example, they would increment the file name using 'variable=%variable%+1', or name the file with its creation date), but found that they would produce 'bad command or file name' errors on my embedded computer.

If anyone wants to use my script, just cut and paste it into note pad and save as xpcfile.bat. The autoexec.bat will need a tweak and off you go.

if true
% code
::File Name - xpcfile
::Description - A script for moving .dat files to a folder with labled with the run number (max 30 runs). This script must run before xpc boots or else .dats will be over-written.
::Purpose - To overcome a glitch in MatLab xPC Target Embedded that means data is over-written each run.
::Author - James Robertson.
::Disclaimer - I don't really know anything about programming and have cobbled this script together form stuff I have read on Google. Whilst it works for me, I have not tested it exhaustivley and therefore it may blow your computer up. I won't be held responsible if it does.
::How to Use - 1) Modify the 4th to last line of this script to call your specific xPC .rtb file (note max 8 characters). 2) Add a line to call this script from autoexec.bat file and remove the line calling the xPC .rtb (this script should do it).
::-------------------------------------------------------------------------------
:: Dont Print Steps to Screen.
::-------------------------------------------------------------------------------
@ECHO OFF
:: The Main Script - Checks for a folder called run1 and, if it doesn't exist, creates it and moves .dat files into it. If run1 does exist the process is repeated for run2 etc..........
::-------------------------------------------------------------------------------
::Look for .dat files, if found run ":RUNS", if none found skip to ":DONE".
IF EXIST *.dat GOTO :RUN1
IF NOT EXIST *.dat GOTO :DONE
::The run number increment bit. Note a max of 30 runs can be saved, this could be expanded if you need to by cutting and pasting the code and changing the numbers.
::--------------------------------------------------------------------------------
:RUN1
SET RUNNO=1
ECHO run%RUNNO%
IF EXIST \run%RUNNO%\*.dat GOTO :RUN2
IF NOT EXIST \run%RUNNO%\*.dat GOTO :FOLDER
:RUN2
SET RUNNO=2
ECHO run%RUNNO%
IF EXIST \run%RUNNO%\*.dat GOTO :RUN3
IF NOT EXIST \run%RUNNO%\*.dat GOTO :FOLDER
:RUN3
SET RUNNO=3
ECHO run%RUNNO%
IF EXIST \run%RUNNO%\*.dat GOTO :RUN4
IF NOT EXIST \run%RUNNO%\*.dat GOTO :FOLDER
:RUN4
SET RUNNO=4
ECHO run%RUNNO%
IF EXIST \run%RUNNO%\*.dat GOTO :RUN5
IF NOT EXIST \run%RUNNO%\*.dat GOTO :FOLDER
:RUN5
SET RUNNO=5
ECHO run%RUNNO%
IF EXIST \run%RUNNO%\*.dat GOTO :RUN6
IF NOT EXIST \run%RUNNO%\*.dat GOTO :FOLDER
:RUN6
SET RUNNO=6
ECHO run%RUNNO%
IF EXIST \run%RUNNO%\*.dat GOTO :RUN7
IF NOT EXIST \run%RUNNO%\*.dat GOTO :FOLDER
:RUN7
SET RUNNO=7
ECHO run%RUNNO%
IF EXIST \run%RUNNO%\*.dat GOTO :RUN8
IF NOT EXIST \run%RUNNO%\*.dat GOTO :FOLDER
:RUN8
SET RUNNO=8
ECHO run%RUNNO%
IF EXIST \run%RUNNO%\*.dat GOTO :RUN9
IF NOT EXIST \run%RUNNO%\*.dat GOTO :FOLDER
:RUN9
SET RUNNO=9
ECHO run%RUNNO%
IF EXIST \run%RUNNO%\*.dat GOTO :RUN10
IF NOT EXIST \run%RUNNO%\*.dat GOTO :FOLDER
:RUN10
SET RUNNO=10
ECHO run%RUNNO%
IF EXIST \run%RUNNO%\*.dat GOTO :RUN11
IF NOT EXIST \run%RUNNO%\*.dat GOTO :FOLDER
:RUN11
SET RUNNO=11
ECHO run%RUNNO%
IF EXIST \run%RUNNO%\*.dat GOTO :RUN12
IF NOT EXIST \run%RUNNO%\*.dat GOTO :FOLDER
:RUN12
SET RUNNO=12
ECHO run%RUNNO%
IF EXIST \run%RUNNO%\*.dat GOTO :RUN13
IF NOT EXIST \run%RUNNO%\*.dat GOTO :FOLDER
:RUN13
SET RUNNO=13
ECHO run%RUNNO%
IF EXIST \run%RUNNO%\*.dat GOTO :RUN14
IF NOT EXIST \run%RUNNO%\*.dat GOTO :FOLDER
:RUN14
SET RUNNO=14
ECHO run%RUNNO%
IF EXIST \run%RUNNO%\*.dat GOTO :RUN15
IF NOT EXIST \run%RUNNO%\*.dat GOTO :FOLDER
:RUN15
SET RUNNO=15
ECHO run%RUNNO%
IF EXIST \run%RUNNO%\*.dat GOTO :RUN16
IF NOT EXIST \run%RUNNO%\*.dat GOTO :FOLDER
:RUN16
SET RUNNO=16
ECHO run%RUNNO%
IF EXIST \run%RUNNO%\*.dat GOTO :RUN17
IF NOT EXIST \run%RUNNO%\*.dat GOTO :FOLDER
:RUN17
SET RUNNO=17
ECHO run%RUNNO%
IF EXIST \run%RUNNO%\*.dat GOTO :RUN18
IF NOT EXIST \run%RUNNO%\*.dat GOTO :FOLDER
:RUN18
SET RUNNO=18
ECHO run%RUNNO%
IF EXIST \run%RUNNO%\*.dat GOTO :RUN19
IF NOT EXIST \run%RUNNO%\*.dat GOTO :FOLDER
:RUN19
SET RUNNO=19
ECHO run%RUNNO%
IF EXIST \run%RUNNO%\*.dat GOTO :RUN20
IF NOT EXIST \run%RUNNO%\*.dat GOTO :FOLDER
:RUN20
SET RUNNO=20
ECHO run%RUNNO%
IF EXIST \run%RUNNO%\*.dat GOTO :RUN21
IF NOT EXIST \run%RUNNO%\*.dat GOTO :FOLDER
:RUN21
SET RUNNO=21
ECHO run%RUNNO%
IF EXIST \run%RUNNO%\*.dat GOTO :RUN22
IF NOT EXIST \run%RUNNO%\*.dat GOTO :FOLDER
:RUN22
SET RUNNO=22
ECHO run%RUNNO%
IF EXIST \run%RUNNO%\*.dat GOTO :RUN23
IF NOT EXIST \run%RUNNO%\*.dat GOTO :FOLDER
:RUN23
SET RUNNO=23
ECHO run%RUNNO%
IF EXIST \run%RUNNO%\*.dat GOTO :RUN24
IF NOT EXIST \run%RUNNO%\*.dat GOTO :FOLDER
:RUN24
SET RUNNO=24
ECHO run%RUNNO%
IF EXIST \run%RUNNO%\*.dat GOTO :RUN25
IF NOT EXIST \run%RUNNO%\*.dat GOTO :FOLDER
:RUN25
SET RUNNO=25
ECHO run%RUNNO%
IF EXIST \run%RUNNO%\*.dat GOTO :RUN26
IF NOT EXIST \run%RUNNO%\*.dat GOTO :FOLDER
:RUN26
SET RUNNO=26
ECHO run%RUNNO%
IF EXIST \run%RUNNO%\*.dat GOTO :RUN27
IF NOT EXIST \run%RUNNO%\*.dat GOTO :FOLDER
:RUN27
SET RUNNO=27
ECHO run%RUNNO%
IF EXIST \run%RUNNO%\*.dat GOTO :RUN28
IF NOT EXIST \run%RUNNO%\*.dat GOTO :FOLDER
:RUN28
SET RUNNO=28
ECHO run%RUNNO%
IF EXIST \run%RUNNO%\*.dat GOTO :RUN29
IF NOT EXIST \run%RUNNO%\*.dat GOTO :FOLDER
:RUN29
SET RUNNO=29
ECHO run%RUNNO%
IF EXIST \run%RUNNO%\*.dat GOTO :RUN30
IF NOT EXIST \run%RUNNO%\*.dat GOTO :FOLDER
:RUN30
SET RUNNO=30
ECHO run%RUNNO%
IF EXIST \run%RUNNO%\*.dat GOTO :ERROR
IF NOT EXIST \run%RUNNO%\*.dat GOTO :FOLDER
::Create folder and copy .dat files to it.
::---------------------------------------------------------------------------------
:FOLDER
ECHO make folder run%RUNNO%
mkdir \run%RUNNO%
COPY *.dat \run%RUNNO%
::Check .dat files have been copied correctly before deleting originals.
IF EXIST \run%RUNNO%\*.dat GOTO :DELETE
IF NOT EXIST \run%RUNNO%\*.dat GOTO :ERROR
::Delete originals.
-----------------------------------------------------------------------------------
:DELETE
DEL *.dat
::Provide a point to jump to when done, display message
::---------------------------------------------------------------------------------
:DONE
ECHO Moving of files complete or no .dat files to move.
::Boot xPC Files when done
::---------------------------------------------------------------------------------
xpcboot Clever~1.rtb
GOTO :EXIT
::Provide a point to jump to if there is an error. EXIT without booting xPC .rtb if files do not copy so they are not overwritten
::---------------------------------------------------------------------------------
:ERROR
ECHO THERE WAS A PROBLEM! Files did not copy to new folder. xPC .rtb Will not launch. You may have exceeded the maximum number of runs - Remove previous runs and try again.
:EXIT
end