help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Default Path in Octave 4.2.1


From: Raghu ram, Posimsetti (P.)
Subject: RE: Default Path in Octave 4.2.1
Date: Tue, 13 Mar 2018 08:10:48 +0000

Hello Ian,

Thanks for your support.

1.       First one is syntax error correct one is ‘cd(pathdir)’

2.       Added modified code

 

pathdir = fullfile(getenv('USERPROFILE'), 'Documents', 'OCTAVE');

if isdir(pathdir)

                cd(pathdir);

else

                mkdir(pathdir);

                cd(pathdir);

end

 

even after above modification code is not setting current path as requested path. i observed that for a fraction code is setting current path as requested path and after returning to default path.

Is there any other file in package resetting the path?

 

I need to set current Dir path while launching the tool.

 

 

Even after changing code its showing the current dir path as where the installation files are

 

 

 

Regards

RaghuRam Posimsetti

Int: +91-44-6655-6124

FordNet:- 8-357-6124

 

From: Ian McCallion [mailto:address@hidden
Sent: Monday, March 12, 2018 10:07 PM
To: Raghu ram, Posimsetti (P.) <address@hidden>
Cc: address@hidden
Subject: Re: Default Path in Octave 4.2.1

 

On Mon, 12 Mar 2018, 20:26 Raghu ram, Posimsetti (P.), <address@hidden> wrote:

Hello,

I am trying to set default path while launching the tool, same code working with Octave 4.0.3 and not working 4.2.1

Modified code if file “octaverc”, path: Octave-4.2.1\share\octave\site\m\startup

Added code:

cdsid = lower(getenv('USERNAME'));

pathdir = strcat('C:\Users\',cdsid,'\Documents\OCTAVE');

if isdir(pathdir)

                cd(getenv(pathdir);

else

                mkdir(pathdir);

                cd(pathdir);

end

where cdsid is user name. after adding the above code default path not setting to expected one, instead default path is the folder where the Octave files are.

1.This cannot be the code that worked under 4.0.3 as 

 

     cd(getenv(pathdir);

 

is a syntax error. Did you mean

 

   cd (pathdir);

 

2. Also it is poor practice to use strcat to construct paths. Use fullfile instead as this deals automatically with the path separator.

 

      pathdir = fullfile('C:\Users', cdsid, 'Documents\OCTAVE');

 

3. Finally getenv('USERPROFILE') returns the user's home directory directly so 

 

       pathdir = fullfile(getenv('USERPROFILE'), 'Documents', 'OCTAVE');

 

would be the preferred way of doing what you want.

 

I don't know what your bug is but fix the above 3 points first and report back if still not working.

 

Cheers... Ian

 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]