Entraides et échanges autour de la technologie Scol - Informations and exchanges on the Scol technology
Vous pouvez changer la langue de l'interface une fois inscrit - You can change the language once registered
You are not logged in.
colleagues:
let's say i have a path named "tests/test1.xos", here:
let "tests/test1.xos" -> path in
let /*code to move up one step in the folder hierarchy*/ -> rootpath in
and i want to navigate to the openspace3d root directory (up one level)
how would I do this?
it can be using the core scol api or os3d file api, it doesn't matter...i've looked at the api's online but cannot figure this out
thx!
Offline
in OS3D tools there is getFileDirectory
but the parent directory of this folder here should be nil "" or "/"
thx arkeon...i tried this:
_fooS strcatn "the parent of the tests file directory is: ":: (getFileDirectory "tests/")::nil;
and the console printed:
the parent of the tests file directory is: tests//
from your post my understanding is that the root directory is represented by a "/", but the console instead shows "tests//"
there must be something i don't understand...
Offline
it take a file try with "tests/test1.xos"
this function only gives the directory from the file.
to find the parent from a file you could :
let getFileDirectory "tests/test1.xos" -> dir in
let getDirectoryWithoutLastSlash dir -> dirwithoutslash in
let getFileDirectory dirwithoutslash -> parentdir in
all this functions are in the tools.pkg
Offline
thx arkeon...i tried this:
let getFileDirectory "tests/hello_3.scol" -> dir in
let getDirectoryWithoutLastSlash dir -> dirwithoutslash in
let getFileDirectory dirwithoutslash -> parentdir in
_fooS strcatn "the parent of the tests file directory is: ":: parentdir::nil;
and the console shows:
the parent of the tests file directory is: tests//
what i would like to do is have scol access the contents of a particular folder. initially this would be the root partition folder, since I know that everyone with os3d has a root partition, aside from that, they could have renamed all their other folders and all the files in the partition.
howeever i think there is another way to approach this that i will try....http://www.scolring.org/forum/viewtopic.php?id=1249
let "http://ifam.net/openspace/spacemanshooter17/dan_no_mohawk/spacemanshooter1.pak" -> urlsrc in
//get the name of the file, this is the 'lastpath'.
let getlastPathDir urlsrc -> destpathfile in
//split string into list of strings s r1, each of which is before, between, or after a "/"
let strToListSep urlsrc "/" -> urlist in
//get the second to last string, which is the folder in which the file is found
let nth_list urlist (sizelist urlist) - 2 ->secontolastdir in
//put file's folder together with / with file name
let strcatn secontolastdir::"/"::destpathfile::nil-> destpath in
i think i can adapt this, using the strToListSep function...i will try this tomorrow.
Last edited by hebdemnobad (17-Dec-2014 18:51:33)
Offline
ha yes getPathFile used by getFileDirectory search for a file also with .ext
the simple method is just to search for "/" in the string and retrieve the needed string part.
Offline
yes....i think this is all that is needed...
let strToListSep "tests/" "/" -> sepatated_list in
(
_fooS hd sepatated_list;
_fooS strcatn "the size of the saprated lsit is: ":: (itoa (sizelist sepatated_list))::nil;
if (sizelist sepatated_list)<= 1 then _fooS "this directory is one level lower than the root directory, or we are in the directory, if the list size is 0, so setting a path variable (we are planning on making) to \" \" is what we would do now, to get us to the root directory" else _fooS "we are not one level down from the root directory";
);
the list size returned by strToListSep "whatever path you have here " "/" can be used to get up to the root directory or move up one directory (or two or three or however many) if you are in the root directory, which is (""), then the size of the list is 0. if you have a list that is the size of 1, then you are looking at a folder in the root directory.
i think this is the simplest way to navigate "up" the directory hierarchy, no?
Offline