function []=create_used_from(pdata_dir)

filename=[pdata_dir,filesep,'used_from'];
%% read the  file
% fileID=fopen(filename,'r');
% [~,~,machinefmt,~] = fopen(fileID);
% formatSpec = '%s%[^\n\r]';
% dataArray = textscan(fileID, formatSpec, 'Delimiter', '', 'WhiteSpace', '',  'ReturnOnError', false);
% %% Remove white space around all cell columns.
% dataArray{1} = dataArray{1};
% fclose(fileID);
% clearvars fileID;

texte_dir = split(pdata_dir,filesep);
expno = texte_dir{end-2,1};
sample = texte_dir{end-3,1};
pdata_dir_lin =  strrep(pdata_dir,filesep,'/');

dataArray{1,1} = {'##TITLE= Parameter file, TopSpin 4.3.0';...
    '##JCAMPDX= 5.0';'##DATATYPE= Parameter Values';...
    ['##NPOINTS= 1' char(9) '$$ modification sequence number'];...
    '##ORIGIN= Bruker BioSpin GmbH';...
    '##OWNER= User';...
    '$$ 2023-12-14 14:59:38.125 +0100  User@PC-Max';...
    ['$$ ' pdata_dir_lin '/used_from'];...
    '$$ process C:\Bruker\TopSpin4.3.0\prog\mod\proc1d.exe';...
    '##$CUREXP= <ser>';...
    '##$DATPATH= <C:/Users/User/Mon_Drive/Matlab/bssfpNMR/data>';...
    ['##$EXPNO= ' num2str(expno)];...
    ['##$NAME= <' sample '>'];...
    '##$PROCNO= 1';...
    '##$PROCNO2= 1';...
    '##END='};

machinefmt = 'ieee-le';

%% Write new file
% warning off MATLAB:iofun:UnsupportedEncoding;
% fileID = fopen(filename, 'w', 'b', 'UTF16-LE');
fileID=fopen(filename,'w',machinefmt);
formatSpec = '%s\n';
for ind = 1:size(dataArray{1,1},1)
    fprintf(fileID,formatSpec,dataArray{1, 1}{ind, 1});
end
fclose(fileID);
end


