CurrentDirectory("") ... gone?

CurrentDirectory("") ... gone? - Сообщения

#1 Опубликовано: 21.09.2022 14:18:31
Wesly Centerwall

Wesly Centerwall

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

Группа: User

I've had to pull up some older SMath files that I had saved and it seems like CurrentDirectory("" ) is no longer working.
Did something change?
#2 Опубликовано: 21.09.2022 15:53:17
Вячеслав Мезенцев

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

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

Группа: Moderator

Yes, functions have moved to another plugin - Mathcad Toolbox.
You can also use the CWD variable.
Russia ☭ forever, Viacheslav N. Mezentsev
1 пользователям понравился этот пост
Wesly Centerwall 21.09.2022 16:13:00
#3 Опубликовано: 21.09.2022 16:19:23
Wesly Centerwall

Wesly Centerwall

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

Группа: User

Thanks uni!
Follow up question: rfile, wfile, dfile are only working with the default "user" path? No way to use these functions with a different path?

My goal is to be able to delete a file of my choosing in a path of my choosing.

Thanks in advance!
#4 Опубликовано: 22.09.2022 01:57:49
Вячеслав Мезенцев

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

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

Группа: Moderator

Wrote

Follow up question: rfile, wfile, dfile are only working with the default "user" path? No way to use these functions with a different path?



You can use wfile(3) and rfile(2) from Mathcad Toolbox plugin.

wfile.jpg

Wrote

My goal is to be able to delete a file of my choosing in a path of my choosing.



I can add dfile(2) for this.
Russia ☭ forever, Viacheslav N. Mezentsev
1 пользователям понравился этот пост
sergio 22.09.2022 07:31:00
#5 Опубликовано: 22.09.2022 05:29:23
Martin Kraska

Martin Kraska

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

Группа: Moderator

dfile() applied to arbitrary paths can create arbitrary damage, think of usage where the path might be calculated and the formula is wrong. There should be some protection mechanism like

- mandatory whitelist of folders, where SMath is allowed to perform delete operations, this might include document directory by default
- mandatory whitelist of file types which are allowed to be deleted by SMath
- mandatory popup dialog for confirmation (this probably will annoy if such operations occure frequently)

Strictly seen, this should also apply to wfile() or any other writing functions.
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
2 пользователям понравился этот пост
sergio 22.09.2022 07:31:00, Вячеслав Мезенцев 22.09.2022 13:03:00
#6 Опубликовано: 22.09.2022 11:21:01
Wesly Centerwall

Wesly Centerwall

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

Группа: User

I think that if you start to idiot proof SMath, it will become as stupid as the users its designed for.
In the end, the path is not arbitrary, and its not like you are deleting entire directories, dfile(x,x) should be made to only delete specified files not folders.
The file would need to be chosen, so not arbitrary as it sounds.

Microsoft Excel for example is a much larger and commonly used program that allows for the same with only a single "enable macros" toggle.
We could do the same, withing the plugin that carries these file manipulation functions, have a toggle that enables these functions.
In this way, a user is not exposed unknowingly to these functions.
Similar to the way we enable document mode.
2022-09-22 10_18_21-SMath Solver 1.0.8253 - [Worksheet1].png
Just my two cents on the matter...
#7 Опубликовано: 22.09.2022 13:18:28
Вячеслав Мезенцев

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

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

Группа: Moderator

I can add 2 variables (wfile and dfile) and use their string value as a file filter allowing you to work only with those files whose name matches the mask or masks. You can use regular expressions.
In this way, you can manually specify the limits of the sandbox that the write and delete functions work with. By default, use the user folder.
Russia ☭ forever, Viacheslav N. Mezentsev
#8 Опубликовано: 22.09.2022 13:59:26
Wesly Centerwall

Wesly Centerwall

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

Группа: User

Seems reasonable to me.
Thanks uni.
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений