Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Offline wb.c  
#1 Posted : 21 September 2022 20:18:31(UTC)
wb.c


Rank: Advanced Member

Groups: Registered
Joined: 02/04/2018(UTC)
Posts: 100
United States

Was thanked: 16 time(s) in 15 post(s)
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?

Edited by user 21 September 2022 20:23:00(UTC)  | Reason: Not specified

Offline uni  
#2 Posted : 21 September 2022 21:53:17(UTC)
uni


Rank: Advanced Member

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

Was thanked: 1163 time(s) in 672 post(s)
Yes, functions have moved to another plugin - Mathcad Toolbox.
You can also use the CWD variable.

Edited by user 21 September 2022 21:56:08(UTC)  | Reason: Not specified

Russia ☭ forever
Viacheslav N. Mezentsev
thanks 1 user thanked uni for this useful post.
on 21/09/2022(UTC)
Offline wb.c  
#3 Posted : 21 September 2022 22:19:23(UTC)
wb.c


Rank: Advanced Member

Groups: Registered
Joined: 02/04/2018(UTC)
Posts: 100
United States

Was thanked: 16 time(s) in 15 post(s)
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!
Offline uni  
#4 Posted : 22 September 2022 07:57:49(UTC)
uni


Rank: Advanced Member

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

Was thanked: 1163 time(s) in 672 post(s)
Originally Posted by: wb.c Go to Quoted Post
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

Originally Posted by: wb.c Go to Quoted Post
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.

Edited by user 22 September 2022 08:14:23(UTC)  | Reason: Not specified

Russia ☭ forever
Viacheslav N. Mezentsev
thanks 1 user thanked uni for this useful post.
on 22/09/2022(UTC)
Offline mkraska  
#5 Posted : 22 September 2022 11:29:23(UTC)
mkraska


Rank: Advanced Member

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

Was thanked: 955 time(s) in 606 post(s)
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.

Edited by user 22 September 2022 11:33:01(UTC)  | Reason: Not specified

Martin Kraska

Pre-configured portable distribution of SMath Studio: https://en.smath.info/wi...th%20with%20Plugins.ashx
thanks 2 users thanked mkraska for this useful post.
on 22/09/2022(UTC),  on 22/09/2022(UTC)
Offline wb.c  
#6 Posted : 22 September 2022 17:21:01(UTC)
wb.c


Rank: Advanced Member

Groups: Registered
Joined: 02/04/2018(UTC)
Posts: 100
United States

Was thanked: 16 time(s) in 15 post(s)
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...
Offline uni  
#7 Posted : 22 September 2022 19:18:28(UTC)
uni


Rank: Advanced Member

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

Was thanked: 1163 time(s) in 672 post(s)
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
Offline wb.c  
#8 Posted : 22 September 2022 19:59:26(UTC)
wb.c


Rank: Advanced Member

Groups: Registered
Joined: 02/04/2018(UTC)
Posts: 100
United States

Was thanked: 16 time(s) in 15 post(s)
Seems reasonable to me.
Thanks uni.
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.