Source language: Translate to:

relative path?

General questions about NeoBook

Moderator: Neosoft Support

relative path?

Postby SebastianMader » Thu Apr 20, 2017 10:54 pm

If I use "FileSaveBox", it gives back the name of the selected files as absolute paths, for example "c:\folder1\folder2". Is there an easy way to change this into relative paths viewed from the PubDir, for example if the publication is there: "c:\programme\publication", then I should get "../../folder1/folder2"?

another question: If i want to seperate drive and directory, then I guess I should use "StrParse" with the delimiter "\". To compare if the drive is the same where the publication is placed, do I have to put "PubDir" with "SetVar" into a new variable and then also seperate drive and directory with "StrParse"?
SebastianMader
 
Posts: 4
Joined: Tue Mar 28, 2017 10:06 am

Re: relative path?

Postby Gaev » Fri Apr 21, 2017 4:57 am

SebastianMader:

If I use "FileSaveBox", it gives back the name of the selected files as absolute paths, for example "c:\folder1\folder2". Is there an easy way to change this into relative paths viewed from the PubDir, for example if the publication is there: "c:\programme\publication", then I should get "../../folder1/folder2"?

NOT an easy way ... too many possibilities ...

- file is in sub folder of [PubDir] ... relatively straight forward
- file is in same folder as [PubDir] ... also straight forward
- file is in parent folder(s) of [PubDir]
- file is in another folder on same drive as [PubDir]
- file is in a different drive than [PubDir]

If i want to seperate drive and directory, then I guess I should use "StrParse" with the delimiter "\". To compare if the drive is the same where the publication is placed, do I have to put "PubDir" with "SetVar" into a new variable and then also seperate drive and directory with "StrParse"?


Code: Select all
FileSaveBox "Save" "Any File|*.*" "c:\" "[File]"
If "[File]" ">" ""
  StrParse "[File]" "!:" "[FileDrive]" "[junk]"
else
  SetVar "[FileDrive1]" ""
EndIf
StrParse "[PubDrive]" "!:" "[PubDrive]" "[junk]"
If "[PubDrive1]" "=" "[FileDrive1]
   ... same drive
Else
   ... not same drive
EndIf
User avatar
Gaev
 
Posts: 3716
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: relative path?

Postby dpayer » Fri Apr 21, 2017 8:52 am

Regarding parsing to get file name/ file path, you could also use NB commands:

ExtractFilePath
ExtractFileName

The help file has details.
David Payer
Des Moines, Iowa
USA
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA


Return to General NeoBook Discussions

Who is online

Users browsing this forum: No registered users and 2 guests

cron