Subscribe Bookmark RSS Feed

JSL code for File Open if file exists

terapin

Community Trekker

Joined:

Jun 23, 2011

Hi Folks,

I have some JSL code that opens a series of files (both a *.jmp and *.dat) and then performs various data management activities on them (namely, testing for presence of new data and then concatenating only the new data). The code runs fine as long as all the files are present.  There are some cases where a particular data file hasn't been collected and I want the JSL code to run for those data files that exist.  Currently, the JSL code stops if a file specified in my dt = Open  ( ......) doesn't exist.  I am looking for a way to test for whether a *.dat file exists and to open it if does or jump to next section of code if it doesn't.  Is there a way to do this in JSL?  Any suggestions would be very much appreciated.

2 REPLIES
ms

Super User

Joined:

Jun 23, 2011

At least in JMP 10 there is a function File Exists() that could be useful here.

For( i = 1, i <= n_files, i++,

  If( File Exists( "path" ),

  my dt = Open( "path" ); // more code...

  )

);

terapin

Community Trekker

Joined:

Jun 23, 2011

Thanks MS,

I knew there must be some command for this task.