Re: Filename as Function Argument

*To*: mathgroup at smc.vnet.net*Subject*: [mg30046] Re: Filename as Function Argument*From*: "David Annetts" <David.Annetts at dem.csiro.au>*Date*: Wed, 25 Jul 2001 01:00:28 -0400 (EDT)*References*: <9jcoeb$a62$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Hi Aaron, > I was trying to implement a function in which a file name was passed as > an argument for the function in Mathmatica 3.0. Within the function, > then, I want to use the argument in a function call to ReadList[] to > read in data from the specified file and process it. I tried doing this > and the function will never "compile" (not sure what the Mathematica > term is for this), it reports an error with the ReadList function. I > also would like to do something similar with SetDirectory[] where a > directory name is passed in as a function argument. Any help would be > appreciated. There are at least two ways this can fail .... 1. if the file you're trying to read does not exist; and 2. if you're reading the wrong things with ReadList. The first can be fixed very easily. Assuming that the file you want to read does exist, try reading it as trial1 = ReadList[myfile, String] and echoing it to see if it dosen't contain any pathological entries. Examples of such entries are trying to read a number where you've really got a word, and adjacent data that run together because they're at the limit of their precision and/or no space has been left between adjacent fields. Regards, Dave.