1 Reply Latest reply on Jun 7, 2011 10:36 AM by raybaudi

    Check file extension before import

    Mitch

      Title

      Check file extension before import

      Post

      Hi,

      I have an import script that first adds the import file as text into a field:  

      gImportFile.

      I would like to limit the import to only files with the file extension of my choice.  At the moment, the would be files with the extension ".USR". 

      Therefore after the import script inserts the name of the file to be imported into gImportFile, I need a script line that will check if the file is has the .USR file extension, if so continue the import.  If not, cancel the import.

      Is there such a script line?

        • 1. Re: Check file extension before import
          raybaudi

          Hi

          1) Set the validation option of gImportFile to ALWAYS validate, By Calculation:

          Let(
          t = Substitute ( Self ; "." ; ¶ ) ;
          GetValue ( t ; ValueCount ( t ) ) = "usr"
          )

          2) The script will be something along:

          Set Field [ YourTable::gImportFile ; "YourDesiredPath" ]
          If [ Get ( LastError ) ]
          Exit Script [ ]
          Else
          ....
          End If