Hi, I have a script where a file saves to a particular location. I am saving data files as a string of the product lot number and raw data. I want to be able to run the script multiple times for the same lot number without the files saving over themselves. I want to create some sort of loop that if the file name already exists, then it will save as lotnumber Raw Data (1), lotnumber Raw Data (2) etc. This is what I have coded now, but I don't know how to make a loop with it. Can someone help make this a loop please?
lotnumer = 1234;
path = "C:\Users\Desktop\JMP\";
rawdatafile = (path || "_" || lotnumber || " Raw Data.jmp");
If( File Exists( rawdatafile ),
dt << save as( path || "_" || lotnumber || " Raw Data (1).jmp" ),
dtrlu << save as( path || "_" || lotnumber || " Raw Data.jmp" )
);