- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Loop Saving Files
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" )
);
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Loop Saving Files
Here is a simple example that loops until no matching file is found, and then saves the file under a new incremented
lotnumer = "1234";
path = "C:\Users\Desktop\JMP\";
rawdatafile = (path || "_" || lotnumber || " Raw Data.jmp");
If( File Exists( rawdatafile ),
i = 1;
While(
File Exists(
path || "_" || lotnumber || " Raw Data (" || Char( i ) || ").jmp"),
i++
);
dt << save as( path || "_" || lotnumber || " Raw Data (" || Char( i ) || ").jmp" );
,
dtrlu << save as( path || "_" || lotnumber || " Raw Data.jmp" )
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Loop Saving Files
Here is a simple example that loops until no matching file is found, and then saves the file under a new incremented
lotnumer = "1234";
path = "C:\Users\Desktop\JMP\";
rawdatafile = (path || "_" || lotnumber || " Raw Data.jmp");
If( File Exists( rawdatafile ),
i = 1;
While(
File Exists(
path || "_" || lotnumber || " Raw Data (" || Char( i ) || ").jmp"),
i++
);
dt << save as( path || "_" || lotnumber || " Raw Data (" || Char( i ) || ").jmp" );
,
dtrlu << save as( path || "_" || lotnumber || " Raw Data.jmp" )
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content