CurrentDirectory broken?

CurrentDirectory broken? - Сообщения

#1 Опубликовано: 30.10.2020 04:31:10
Dionysios J. Pantazis

Dionysios J. Pantazis

16 сообщений из 179 понравились пользователям.

Группа: User

Is the CurrentDirectory function still broken? Looking at https://smath.com/bts/Issues/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("")

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?
Join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW
#2 Опубликовано: 30.10.2020 04:43:46
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 сообщений из 1708 понравились пользователям.

Группа: Moderator

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
#3 Опубликовано: 30.10.2020 06:00:52
Dionysios J. Pantazis

Dionysios J. Pantazis

16 сообщений из 179 понравились пользователям.

Группа: User

uni-

why isn't the proper directory showing up?

Join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW
#4 Опубликовано: 30.10.2020 08:24:06
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 сообщений из 1708 понравились пользователям.

Группа: Moderator

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
#5 Опубликовано: 30.10.2020 20:16:56
Andrey Ivashov

Andrey Ivashov

2270 сообщений из 3734 понравились пользователям.

Группа: Super Administrator

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.
#6 Опубликовано: 31.10.2020 06:24:25
Martin Kraska

Martin Kraska

1222 сообщений из 2150 понравились пользователям.

Группа: Moderator

Wrote

Is the CurrentDirectory function still broken? Looking at https://smath.com/bts/Issues/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("")

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().
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#7 Опубликовано: 31.10.2020 10:58:46
NDTM Amarasekera

NDTM Amarasekera

130 сообщений из 352 понравились пользователям.

Группа: User

Wrote


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
Look within!... The secret is inside you. Best Regards Eng. NDTM Amarasekera - Sri Lanka
#8 Опубликовано: 02.11.2020 00:31:42
Dionysios J. Pantazis

Dionysios J. Pantazis

16 сообщений из 179 понравились пользователям.

Группа: User

Wrote

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
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений