2 Replies Latest reply on Mar 27, 2015 7:45 AM by ChrisC_3

    Export data using variable to set path

    Cadburys

      Title

      Export data using variable to set path

      Post

      Hi

      I have a script to export data, when I "hard code" the path it works perfectly. ie.

      "filewin:/c:/My Extract Files/"&$printfilename

      I would prefer to have the path as a variable. I have a table called Setup and have created a field within it called "PCExportPath" and entered C:\My Extract Files\ and set it as a Global variable.

      Then I created a variable within my script for it.  I have tried various ways to setup the export path:

      "filewin:"&Setup::PCExportPath&$printfilename

      and I have tried to first create a variable for it and then include it in the export path variable

      "fielwin:"&$PCExportpath&$printfilename

      with both I get the following message:

      "C:\My Extract Files\Export27032015.csv could not be created on this disk. Use a different name, make more room on the disk, unlock it or use a different disk."

      Is it not possible to create your own path other than when using Get(Document Path)?

      Any help would be appreciated.

      Thanks

      Cadburys 

       

       

       

       

        • 1. Re: Export data using variable to set path
          philmodjunk

          It is indeed possible to create your own file path. Some part of what you are using is not valid. Is there a folder named "my Extract files" at the top level of your C drive?

          You probably do not need the text "filewin:" for exporting data, if your version does require a tag, you can use just "file:" and thus use something that is not platform specific.

          To debug file path issues, I recommend using the exploration file found here: Exploring the use of a $Path Variable in Scripts

          Using it, you can insert a file by reference from the location to which you want to export and then you can use the calculation fields in this file to see the actual file path in order to compare it, character by character to the path you have tried to use in order to detect discrepancies.

          • 2. Re: Export data using variable to set path
            ChrisC_3

            With your calculation of "C:\My Extract Files\" as the value of your PCExportPath field, what you are actually passing over to the export script is

            "filewin:C:\My Extract Files\&$printfilename which isn't the same syntax as:

            "filewin:/c:/My Extract Files/"&$printfilename

            you're missing a forward slash after filewin and have backslashes instead of forward slashes in your filepath.

            Change the value to "/My Extract Files/" and add the forward slash to "filewin:" and see if that works.