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.
i would like to save a list of strings to an xml file to be retrieved by the user (the list is going to represent file paths). the code below doesn't work since i am feeding XMLaddMark [S r1] instead of a simple S:
//code excerpt
let "xmlwriter/xmlwriter.xml" -> file in
let XMLcreate file nil -> xmlstr in
let "harry"::"linda"::"sally"::nil -> list in
let XMLaddMark xmlstr "path_list" nil ["paths" list]::nil nil -> namestr in
(
XMLwrite xmlstr "xmlwriterreaderlist/xmlwriterreaderlist.xml";
_closemachine;
);
how would i turn the local variable, named "list" into a string that can be saved by XMLaddMark...I have been looking through the core and os3d api's but have only found a function that converts a list of intergers to a string, but not a list of strings to a string.
thx!
-h
edit
oh, i see the function listToString....is that the only way to get a string list into an xml file object?
Last edited by hebdemnobad (17-Dec-2014 15:27:30)
Offline
thx iri, for the sake of posterity:
to turn a list into a string and save it into a simple xml file:
//read hybridgui.xos and write to hybridgui.xml in openspace3d/tests/filreader
let "xmlwriterreaderlist/xmlwriterreaderlist.xml" -> file in
let XMLcreate file nil -> xmlstr in
let ("harry"::"Jennifer"::nil)::(nil)::nil-> lpersonlist in
let strbuild lpersonlist -> spersonlist in
let XMLaddMark xmlstr "personlist" nil ["apersonlist" spersonlist]::nil nil -> namestr in
(
XMLwrite xmlstr "xmlwriterreaderlist/xmlwriterreaderlist.xml";
);
to retrieve a string from a simple xml file and turn it into a list with the file created above
let XMLload "xmlwriterreaderlist/xmlwriterreaderlist.xml" -> xml_file in
let XMLgetMarkByValue xml_file "personlist" -> personliststr in
let XMLgetParam personliststr "apersonlist" ->personlist_string in
let strextr personlist_string -> newperson_list in
(
_fooS "the person list from the xml file is" ;
_fooSList hd newperson_list;
complete package file for doing the actions above
proto XMLload = fun [S] XMLfile;;
proto XMLcreate = fun [S S] XMLfile;;
proto XMLaddMark= fun [XMLfile S XMLmark [[S S] r1] S] XMLmark;;
proto XMLwrite = fun [XMLfile S] I;;
proto XMLgetMarkByValue = fun [XMLfile S] XMLmark;;
proto XMLgetParam = fun [XMLmark S] S;;
//proto listToString =fun [[[S r1] r1]] S;;
fun secureLoad(pack)=
let _testpak pack -> ret in
if (ret == nil) then
(
_fooS "xmlparser loading";
_load pack;
1;
)
else
(
_fooS strcat "Error in " ret;
0;
);;
fun load_dependencies() =
let "tools/os3dlib/tools.pkg"::"tools/os3dlib/xmlparser.pkg"::nil -> list_of_dependencies in
(
while (list_of_dependencies!= nil)&& (secureLoad hd list_of_dependencies) do
(
set list_of_dependencies = tl list_of_dependencies;
_fooS "dependencies loading";
);
//all dependencies have been read
if list_of_dependencies==nil then
(
//read hybridgui.xos and write to hybridgui.xml in openspace3d/tests/filreader
let "xmlwriterreaderlist/xmlwriterreaderlist.xml" -> file in
let XMLcreate file nil -> xmlstr in
let ("harry"::"Jennifer"::nil)::(nil)::nil-> lpersonlist in
let strbuild lpersonlist -> spersonlist in
let XMLaddMark xmlstr "personlist" nil ["apersonlist" spersonlist]::nil nil -> namestr in
(
XMLwrite xmlstr "xmlwriterreaderlist/xmlwriterreaderlist.xml";
);
let XMLload "xmlwriterreaderlist/xmlwriterreaderlist.xml" -> xml_file in
let XMLgetMarkByValue xml_file "personlist" -> personliststr in
let XMLgetParam personliststr "apersonlist" ->personlist_string in
let strextr personlist_string -> newperson_list in
(
_fooS "the person list from the xml file is" ;
_fooSList hd newperson_list;
);
0;
)
else
(
_fooS "error in dependency loading";
0;
);
);
0;;
fun main ()=
_showconsole;
load_dependencies;
0;;
Last edited by hebdemnobad (17-Dec-2014 16:32:19)
Offline