Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


Options
Go to last post Go to first unread
Offline sinneD  
#1 Posted : 30 October 2020 10:31:10(UTC)
sinneD


Rank: Advanced Member

Groups: Registered
Joined: 12/03/2011(UTC)
Posts: 101
Location: Chicago

Was thanked: 16 time(s) in 7 post(s)
Is the CurrentDirectory function still broken? Looking at https://smath.com/bts/Is...IssueDetail.aspx?id=4586 its unresolved?

I am on 0.99.7579.3197

No matter where I save the .sm file, it ALWAYS returns "C:\Program Files (x86)\SMath Studio\"

This breaks many of my include statements and excel file imports/exports as I have them defined as -

path:= "xls\workbook.xlsm"

root_dir:=CurrentDirectory(""Wink

and then

path:= concat(root_dir,path) will return

"C:\Program Files (x86)\SMath Studio\xls\workbook.xlsm" instead of

"C:\Users\someguy\JobFolder\xls\workbook.xlsm"

I know that this has come and gone a few times with both uni and AlexM weighing in on it, but I thought it was fixed.

Is there a fix?

Edited by user 30 October 2020 10:33:39(UTC)  | Reason: Not specified

Join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline uni  
#2 Posted : 30 October 2020 10:43:46(UTC)
uni


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 10/11/2010(UTC)
Posts: 1,494
Man
Russian Federation

Was thanked: 1274 time(s) in 745 post(s)
CurrentDirectory() is just a wrapper for the system variable Environment.CurrentDirectory (.Net). So it can't be broken. With an empty argument, it shows the current folder specified in the program and nothing else.
Russia ☭ forever
Viacheslav N. Mezentsev
Offline sinneD  
#3 Posted : 30 October 2020 12:00:52(UTC)
sinneD


Rank: Advanced Member

Groups: Registered
Joined: 12/03/2011(UTC)
Posts: 101
Location: Chicago

Was thanked: 16 time(s) in 7 post(s)
uni-

why isn't the proper directory showing up?

Join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW
Offline uni  
#4 Posted : 30 October 2020 14:24:06(UTC)
uni


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 10/11/2010(UTC)
Posts: 1,494
Man
Russian Federation

Was thanked: 1274 time(s) in 745 post(s)
It looks like SMath Studio doesn't change the folder when saving the document. I addressed this question to Andrey. Let's wait for his answer.
Russia ☭ forever
Viacheslav N. Mezentsev
Offline Andrey Ivashov  
#5 Posted : 31 October 2020 02:16:56(UTC)
Andrey Ivashov


Rank: Administration

Groups: Developers, Registered, Knovel Developers, Administrators, Advanced Member
Joined: 11/07/2008(UTC)
Posts: 1,616
Man
Russian Federation

Was thanked: 1978 time(s) in 666 post(s)
If it is based on Environment.CurrentDirectory then result will differ according to the way how you have opened SMath Studio:
- If opened clicking on program icon - current directory will be equal to SMath Studio installation directory;
- If opened clicking on the Worksheet file - current directory is a folder where file is located.
Offline mkraska  
#6 Posted : 31 October 2020 12:24:25(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,980
Germany

Was thanked: 1120 time(s) in 718 post(s)
Originally Posted by: sinneD Go to Quoted Post
Is the CurrentDirectory function still broken? Looking at https://smath.com/bts/Is...IssueDetail.aspx?id=4586 its unresolved?

I am on 0.99.7579.3197

No matter where I save the .sm file, it ALWAYS returns "C:\Program Files (x86)\SMath Studio\"

This breaks many of my include statements and excel file imports/exports as I have them defined as -

path:= "xls\workbook.xlsm"

root_dir:=CurrentDirectory(""Wink

and then

path:= concat(root_dir,path) will return

"C:\Program Files (x86)\SMath Studio\xls\workbook.xlsm" instead of

"C:\Users\someguy\JobFolder\xls\workbook.xlsm"

I know that this has come and gone a few times with both uni and AlexM weighing in on it, but I thought it was fixed.

Is there a fix?


I recommend to use CurrentDirectory(DocumentDirectory()). This should work for files which have been saved at least once.

What it does is quite straightforward. It gets the directory of the currently active document and sets the current directory to it. Both functions are from Uni's mathcad file access functions plugin.

This way you can have multiple documents open at the same time. When switching between them, the directory is changed once you execute the document.

In your case you could set the root to DocumentDirectory().

Edited by user 31 October 2020 12:26:10(UTC)  | Reason: Not specified

Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
Offline ndtma  
#7 Posted : 31 October 2020 16:58:46(UTC)
ndtma


Rank: Advanced Member

Groups: Registered
Joined: 05/06/2014(UTC)
Posts: 348
Man
Sri Lanka
Location: Colombo

Was thanked: 124 time(s) in 82 post(s)
Originally Posted by: mkraska Go to Quoted Post

I recommend to use CurrentDirectory(DocumentDirectory()). This should work for files which have been saved at least once.


Image of an example attached pl. Works fine in latest SS.

Document_Directory.png

Edited by user 31 October 2020 17:03:48(UTC)  | Reason: Not specified

Look within!... The secret is inside you.
Best Regards
Eng. NDTM Amarasekera - Sri Lanka
Offline sinneD  
#8 Posted : 02 November 2020 06:31:42(UTC)
sinneD


Rank: Advanced Member

Groups: Registered
Joined: 12/03/2011(UTC)
Posts: 101
Location: Chicago

Was thanked: 16 time(s) in 7 post(s)
Originally Posted by: mkraska Go to Quoted Post
This way you can have multiple documents open at the same time. When switching between them, the directory is changed once you execute the document.

In your case you could set the root to DocumentDirectory().


Exactly. Thank you.
Join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.