Subscribe Bookmark RSS Feed

Deleting JMP data files on disk from JSL

I'm astonished to discover that I don't actually know the answer to this question, but how do I delete a JMP data file that's been stored on disk from within JSL? I need to carry out some elementary file management from a dashboard that I've created, and two of the functions I need to perform are (a) deleting and (b) renaming JMP data sets that I've saved to disk. Can anyone tell me how to do that, please?
3 REPLIES
mattf

Community Trekker

Joined:

Jun 23, 2011

If(
Host is( Windows ) & Or(
JMP Version() == " 8.0.1",
JMP Version() == " 8.0.2",
JMP Version() == " 9.0.0"
),

kernel32 = Load Dll( "kernel32" );

/*
http://msdn.microsoft.com/en-us/library/aa363915(VS.85).aspx
BOOL WINAPI DeleteFile(
__in LPCTSTR lpFileName
);
*/

kernel32 << DeclareFunction(
"DeleteFileA",
Convention( STDCALL ),
Alias( "DeleteFile" ),
Arg( AnsiString, "lpFileName" ),
Returns( UInt32 )
); // (returns long) 1=success, 0=not;

rc = kernel32 << Delete File( "C:\temp\test\deleteme.xx2" );

/*
http://msdn.microsoft.com/en-us/library/aa365239(VS.85).aspx
BOOL WINAPI MoveFile(
__in LPCTSTR lpExistingFileName,
__in LPCTSTR lpNewFileName
);
*/
kernel32 << DeclareFunction(
"MoveFileA",
Convention( STDCALL ),
Alias( "MoveFile" ),
Arg( AnsiString, "lpExistingFileName" ),
Arg( AnsiString, "lpNewFileName" ),
Returns( Int8 )
); // (returns long) 1=overwrite, 0= do not overwrite;
kernel32 << ShowFunctions();

rc = kernel32 << Move File( "C:\temp\deleteme.xxx", "C:\temp\test\deleteme.xx2" );
Show( rc ); // returns 0 -> failure, nonzero -> success


kernel32 << ShowFunctions();

kernel32 << UnloadDll();
);
ayaz

Community Trekker

Joined:

Nov 30, 2011

Thank you! This works for moving or deleting any file. I don't think I could have figured it out without your post, MattF.

By an incredible coincidence I've just discovered that I need to do exactly this sort of thing again myself after what I'm seriously embarrassed to see is a gap of getting on for two years since I posed the original question - and it works perfectly. A belated many thanks, MattF.

David