Tim Huffam

Dotting the I and crossing the T of I.T.

  Home  |   Contact  |   Syndication    |   Login
  153 Posts | 0 Stories | 2415 Comments | 653 Trackbacks

News

Archives

Post Categories

Interesting Blogs/Links

Wednesday, March 03, 2010 #

The Aris scripting language provides a couple of ways to select and read a file for input.  This is useful for auto populating Aris (generating models and objects).

To select a file on the clients machine:

Aris provides a dialog for selecting a file on the users machine.  This returns an array of file objects, each of which have a method which returns a byte array (which seems to be the standard way to handle file content in Aris). Eg:

    // Get file from client
    var selectedFiles = Dialogs.getFilePath(null, "XML Files|*.xml||", null, "Select file", 0);
    if(selectedFiles==null){
        Dialogs.MsgBox("No file selected.");
        return;
    }
    var fileByteArray = selectedFiles[0].getData();
 

To use a file on the Aris Server:

Alternatively you can just access a known file from the Common Files area.  To put the file there in the first place you need to add it within Aris (from the Scripting module open the server, right-click on "Common files" and select "Add files..." etc).  Then use the Dialogs.getFilePath() method, eg:

    // Get file from Common files
    var fileByteArray = Context.getFile("myInputFile.xml", Constants.LOCATION_COMMON_FILES);
 

HTH
Tim