Scripting: adjust inconsistent path parsing

Features wanted...
bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Scripting: adjust inconsistent path parsing

Post by bdeshi »

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. :whistle:
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Scripting: adjust inconsistent path parsing

Post by highend »

Code: Select all

Or go the other way and make writefile, readfile's parsing of dotted relative paths <xypath>-based as well
If this is done, use <curpath> please...
One of my scripts helped you out? Please donate via Paypal

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Scripting: adjust inconsistent path parsing

Post by admin »

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. :|

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Scripting: adjust inconsistent path parsing

Post by bdeshi »

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: :blackstorm:

Also
admin wrote: I just did not work as advertised.
haven't seen any advert, but from what we've seen, you are perfectly fine! :kidding:
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Scripting: adjust inconsistent path parsing

Post by admin »

LOL :tup:

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Scripting: adjust inconsistent path parsing

Post by admin »

SammaySarkar wrote: 27 Jan 2019 15:45 (I can make a list of commands&functions needing update in a while.)
That would be nice!

I fixed folderreport() in the meantime. Don't see any others... :|

EDIT: ok, I see these: inputfile, inputfolder, resolvepath

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Scripting: adjust inconsistent path parsing

Post by bdeshi »

OK, these commands process relative paths as <xypath>-based.

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

broken/incomplete/clarification wanted:

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
So far.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Scripting: adjust inconsistent path parsing

Post by admin »

Thanks, that's a long list! But, are you sure that this is not advertised?

Eg for attrstamp the help says:
itemlist: |-separated list of items (full path) to attrstamp;
So you are not supposed to pass a relative path.

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Scripting: adjust inconsistent path parsing

Post by bdeshi »

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?
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Scripting: adjust inconsistent path parsing

Post by admin »

Good point.

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Scripting: adjust inconsistent path parsing

Post by admin »

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

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Scripting: adjust inconsistent path parsing

Post by bdeshi »

wow, great! (I'll add more suggestion here when/if found)
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Scripting: adjust inconsistent path parsing

Post by admin »

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.
Rubbish. SC exists() will be added in the next beta.

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Scripting: adjust inconsistent path parsing

Post by bdeshi »

:mrgreen:

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!

    Code: Select all

    Not Found
    -----------------------------------
    Could not find: 
    
    D:\tools\XYplorer\catalog.dat      (note: this file exists in this exact path.)
    so the error supports relative paths better than the command itself! :ghost:
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Scripting: adjust inconsistent path parsing

Post by admin »

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!

Code: Select all

Not Found
-----------------------------------
Could not find: 

D:\tools\XYplorer\catalog.dat      (note: this file exists in this exact path.)
so the error supports relative paths better than the command itself! :ghost:
1) Cannot confirm.

2) The help says: "Can be relative to the application data folder." So I cannot change anything here.

Post Reply