BookmarkSubscribeRSS Feed
Choose Language Hide Translation Bar
terapin
Community Trekker

JSL code for File Open if file exists

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
ms
Super User ms
Super User

Re: JSL code for File Open if file exists

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...

  )

);

2 REPLIES 2
Highlighted
ms
Super User ms
Super User

Re: JSL code for File Open if file exists

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

Re: JSL code for File Open if file exists

Thanks MS,

I knew there must be some command for this task. 

0 Kudos