Default Path in Octave 4.2.1

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Default Path in Octave 4.2.1

Raghu ram, Posimsetti (P.)

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.

Request you to help me to resolve this issue.

 

 

 

Regards

Raghuram Posimsetti

Systems Engineering - MBSE, CAE

Requirements, Engineering & Manufacturing

RMZ Millenia -II, Campus 3A, Chennai –600 096

TamilNadu – India.

Int: +91-44-6655-6124

FordNet:- 8-357-6124

Description: FORD

      Go Further

 



-----------------------------------------
Join us March 12-15 at CERN near Geneva
Switzerland for OctConf 2018.  More info:
https://wiki.octave.org/OctConf_2018
-----------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: Default Path in Octave 4.2.1

Ian McCallion
On Mon, 12 Mar 2018, 20:26 Raghu ram, Posimsetti (P.), <[hidden email]> 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



-----------------------------------------
Join us March 12-15 at CERN near Geneva
Switzerland for OctConf 2018.  More info:
https://wiki.octave.org/OctConf_2018
-----------------------------------------
Reply | Threaded
Open this post in threaded view
|

RE: Default Path in Octave 4.2.1

Raghu ram, Posimsetti (P.)

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:[hidden email]]
Sent: Monday, March 12, 2018 10:07 PM
To: Raghu ram, Posimsetti (P.) <[hidden email]>
Cc: [hidden email]
Subject: Re: Default Path in Octave 4.2.1

 

On Mon, 12 Mar 2018, 20:26 Raghu ram, Posimsetti (P.), <[hidden email]> 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

 



-----------------------------------------
Join us March 12-15 at CERN near Geneva
Switzerland for OctConf 2018.  More info:
https://wiki.octave.org/OctConf_2018
-----------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: Default Path in Octave 4.2.1

tmacchant
----- Original Message -----

>From: "Raghu ram, Posimsetti (P.)" 
>To: Ian McCallion 
>Cc: "help
>Date: 2018/3/13, Tue 17:10
>Subject: RE: Default Path in Octave 4.2.1
>
>
>
>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:[hidden email]]
>Sent: Monday, March 12, 2018 10:07 PM
>To: Raghu ram, Posimsetti (P.) <[hidden email]>
>Cc: [hidden email]
>Subject: Re: Default Path in Octave 4.2.1

>On Mon, 12 Mar 2018, 20:26 Raghu ram, Posimsetti (P.), <[hidden email]> 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



Another approach is to edit launch shortut


ShortCut is located here
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Octave-4.2.1


Copy CLI or GUI shortcut and paste where you like.
Right click icon of shortucut and show 'Property' tab
Edit the Working Folder where you like and [OK].

Use the custermized shortcut.

If  Working Folder is empty, working folder is set to the folder where shortcut is located.

HTH

Tatsuro



-----------------------------------------
Join us March 12-15 at CERN near Geneva
Switzerland for OctConf 2018.  More info:
https://wiki.octave.org/OctConf_2018
-----------------------------------------