Re: Set working directory? Read polynomial from text file?

*To*: mathgroup at smc.vnet.net*Subject*: [mg56018] Re: Set working directory? Read polynomial from text file?*From*: Bill Rowe <readnewsciv at earthlink.net>*Date*: Wed, 13 Apr 2005 01:11:06 -0400 (EDT)*Sender*: owner-wri-mathgroup at wolfram.com

On 4/12/05 at 5:26 AM, xxxxyz at abv.bg wrote: >1. How can I set working directory that when I restart Mathematica >the wotking directory is that I set previous time? I use >SetDirectory["dir"] but when I restart Mathematica the working >directory is the original "C:\Program file...". Put a SetDirectory[directoryName] in the init.m file that gets executed everytime Mathematica starts up. The init.m file in the directory returned by ToFileName[$UserBaseDirectory,"Kernel"] should work fine for this purpose. Note, this will cause the working directory to be set to the same value at the beginning of every session. If your goal is to have Mathematica remember the last working directory in a session rather than have Mathematica start with a specific pre-defined working directory, then this will not do. I am not aware of any way to get Mathematica to automatically remember the last set working directory from session to session. >2. I have a text file with polynomials in form as follows: >x^n+x^(n-1)+...x+1 (one polynomial per row). How can I read from >this file and Mathematica understand the value it reads as >polynomial? I do this: >streamR=Openfile["file"];poly=Read[streamR,String], but "poly" is >String at the end and I can't use functions CoefficientList, Expand >etc. Use ToExpression to convert the string to an expression that can be manipulated. For example, In[1]:= str = "2 x^2+2 x +1"; CoefficientList[ToExpression[str], x] Out[2]= {1, 2, 2} -- To reply via email subtract one hundred and four