Scripting: adjust inconsistent path parsing
Scripting: adjust inconsistent path parsing
Some difference exists in how functions parse paths.
writefile(".\subfolder\data.txt", "content"); // writes to <curpath>\subfolder\data.txt
listfolder(".\subfolder"); // takes <xypath> as base, and lists <xypath>\subfolder.
(I think only goto states this <xypath>-based parsing explicitly.)
But since we can browse to paths with .\ in addressbar, it's only intuitive to expect such relative paths should resolve to <curpath> as base with all functions (except for obvious exceptions, such as load, catalogload, columnlayout, ctbicons, loadlayout, loadsettings, paperfolder, tabset, tagload, toolbar etc which take feature-specific basepaths.)
[ed+] Moreover, most places in the reference say that paths "defaults to the current folder". So it's expected that relative paths will also follow current folder as well.
Or go the other way and make writefile, readfile's parsing of dotted relative paths <xypath>-based as well.
writefile(".\subfolder\data.txt", "content"); // writes to <curpath>\subfolder\data.txt
listfolder(".\subfolder"); // takes <xypath> as base, and lists <xypath>\subfolder.
(I think only goto states this <xypath>-based parsing explicitly.)
But since we can browse to paths with .\ in addressbar, it's only intuitive to expect such relative paths should resolve to <curpath> as base with all functions (except for obvious exceptions, such as load, catalogload, columnlayout, ctbicons, loadlayout, loadsettings, paperfolder, tabset, tagload, toolbar etc which take feature-specific basepaths.)
[ed+] Moreover, most places in the reference say that paths "defaults to the current folder". So it's expected that relative paths will also follow current folder as well.
Or go the other way and make writefile, readfile's parsing of dotted relative paths <xypath>-based as well.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
Re: Scripting: adjust inconsistent path parsing
Code: Select all
Or go the other way and make writefile, readfile's parsing of dotted relative paths <xypath>-based as well
One of my scripts helped you out? Please donate via Paypal
-
- Site Admin
- Posts: 60595
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Scripting: adjust inconsistent path parsing
1. Yes, SC listfolder had to be fixed. I just did not work as advertised.
2. SC goto is tricky. The behavior of the Address Bar actually depends on this setting (factory default is OFF):
Configuration | General | Controls and More | Miscellaneous | Address Bar relative to application path
Scripts should not depend on this setting, of course.
All in all I tend to change goto to make it work like all (? ... I hope so) other commands: make it relative to <curpath>.
However, this might break old code. So I cannot do that.
2. SC goto is tricky. The behavior of the Address Bar actually depends on this setting (factory default is OFF):
Configuration | General | Controls and More | Miscellaneous | Address Bar relative to application path
Scripts should not depend on this setting, of course.
All in all I tend to change goto to make it work like all (? ... I hope so) other commands: make it relative to <curpath>.
However, this might break old code. So I cannot do that.
FAQ | XY News RSS | XY Twitter
Re: Scripting: adjust inconsistent path parsing
ok. listfolder now works okay. I take it other functions will follow suit?
for example: folderreport(,'r', '..\'); // list <xypath>\..\
(I can make a list of commands&functions needing update in a while.)
goto: bummer. burn all old scripts! :pitchfork:
Also
for example: folderreport(,'r', '..\'); // list <xypath>\..\
(I can make a list of commands&functions needing update in a while.)
goto: bummer. burn all old scripts! :pitchfork:
Also
haven't seen any advert, but from what we've seen, you are perfectly fine!admin wrote: ↑ I just did not work as advertised.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
- Site Admin
- Posts: 60595
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Scripting: adjust inconsistent path parsing
That would be nice!SammaySarkar wrote: ↑27 Jan 2019 15:45 (I can make a list of commands&functions needing update in a while.)
I fixed folderreport() in the meantime. Don't see any others...
EDIT: ok, I see these: inputfile, inputfolder, resolvepath
FAQ | XY News RSS | XY Twitter
Re: Scripting: adjust inconsistent path parsing
OK, these commands process relative paths as <xypath>-based.
broken/incomplete/clarification wanted:
So far.
Code: Select all
attrstamp()
copy
copyto // location <curpath>-based, but source <xypath>-based
moveto // ^^
backupto // ^^
pasteto
exists()
filesequal()
flattenfolder()
foldersize()
get()
* counticons
hash()
hashlist
open
rename
runq // relative path in directory param is <xypath>-based
runret // ^^
showhash
Code: Select all
box // relative paths not allowed?
highlight // ^^
html // ^^
id3tag // ^^
sync // ^^
copyas // are relative paths disallowed in targetpath?
moveas // ^^
editconf // <xypath>-based. shouldn't it be <xydata>-based like savesettings?
quicksearch() // no relative paths in path param?
run // relative path in directory param fails in contrast to runq
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
- Site Admin
- Posts: 60595
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Scripting: adjust inconsistent path parsing
Thanks, that's a long list! But, are you sure that this is not advertised?
Eg for attrstamp the help says:
Eg for attrstamp the help says:
So you are not supposed to pass a relative path.itemlist: |-separated list of items (full path) to attrstamp;
FAQ | XY News RSS | XY Twitter
Re: Scripting: adjust inconsistent path parsing
Judge it yourself.
But the fact of the matter is attrstamp() does not fail if given a relative path, so that's already in violation of the docs, so why not go all the way?
But the fact of the matter is attrstamp() does not fail if given a relative path, so that's already in violation of the docs, so why not go all the way?
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
- Site Admin
- Posts: 60595
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Scripting: adjust inconsistent path parsing
Did them all. Apart from:
Code: Select all
- exists: needs to react on unaltered inputs to make sense.
- html(): too ambiguous
- id3tag: already okay it seems
FAQ | XY News RSS | XY Twitter
Re: Scripting: adjust inconsistent path parsing
wow, great! (I'll add more suggestion here when/if found)
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
- Site Admin
- Posts: 60595
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Scripting: adjust inconsistent path parsing
Rubbish. SC exists() will be added in the next beta.admin wrote: ↑28 Jan 2019 13:28 Did them all. Apart from:Code: Select all
- exists: needs to react on unaltered inputs to make sense.
FAQ | XY News RSS | XY Twitter
Re: Scripting: adjust inconsistent path parsing
Some more notes (sorry if I'm being pedantic or to pressing ):
- savethumb() does not support relative paths. Plans to support?
- columnlayout(), loadlayout(), paperfolder() partially accepts relative paths in that they can prepend <xydata>\(columns|layouts|paper), but breaks with .\ and ..\. Do you think these should also correctly support dotted relative paths, being relative to their function-specific base locations?
so for example, columnlayout("..\..\xydata.bak\columns\defaultcolumns.txt") will work, (load columns from a backup profile directory by pathfinding to parent folders of <xydata>\columns) - catalogload also does not support dotted relative paths. This is more confusing because for example, catalogload("..\..\catalog.dat") fails, but the error message has the correct path!so the error supports relative paths better than the command itself!
Code: Select all
Not Found ----------------------------------- Could not find: D:\tools\XYplorer\catalog.dat (note: this file exists in this exact path.)
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
- Site Admin
- Posts: 60595
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Scripting: adjust inconsistent path parsing
1) Cannot confirm.SammaySarkar wrote: ↑29 Jan 2019 11:10 catalogload also does not support dotted relative paths. This is more confusing because for example, catalogload("..\..\catalog.dat") fails, but the error message has the correct path!so the error supports relative paths better than the command itself!Code: Select all
Not Found ----------------------------------- Could not find: D:\tools\XYplorer\catalog.dat (note: this file exists in this exact path.)
2) The help says: "Can be relative to the application data folder." So I cannot change anything here.
FAQ | XY News RSS | XY Twitter