1. A fix in Volume, and some work internal, we have a new example, then Jukebox in info, for playing mp3 like a juke box. We can program by using numbers the tracks we want to play aftet the current one, we can play one or a list in a loop, using a simple interface. In this module we handle the console as window. We can move it around, and using F10 we can maximize or restore it. Except for the movement of console, all other inputs are through keyboard only.
2. I wrote an xml parser in an object (simple one), and works fine. So I made two adapters objects to handle it through the M2000 code.
3. I make an adapter object for cZipArchive, a very good class for handling zip files, using dedicated machine code for the job. ZipArchive
This is the code from XML module (the demo in info file)
We make this xml
<?xml version="1.0" encoding="UTF16"?>
<names>
<element Id="69">
<codename>VB6</codename>
<sold>2</sold>
</element>
<element Id="70" Nobel="yes">
<codename>C++</codename>
<sold>3</sold>
</element>
<element Id="71">
<codename>M2000</codename>
<sold>10</sold>
</element>
</names>
We use a simple interface to add nodes.
form 80, 48
declare xml xmlData
With xml, "LastChild" as Child
with xml, "xml" as doc$, "beautify" as beautify
with xml, "childcount" as xml.count, "anychild" as xml.child()
print type$(xml)="XmlMono" ' true
method xml, "PrepareNodeSimple", "xml" as ProcessInstructions
// nodes are not xmlmono types
print type$(ProcessInstructions)="XmlNode"
method xml, "PlaceAttributeToNode", ProcessInstructions, "version", "1.0"
method xml, "PlaceAttributeToNode", ProcessInstructions, "encoding", "UTF16"
// the first node we build used for the processinstructions
method xml, "PlaceProcessingInstructions", ProcessInstructions
method xml, "PrepareNode", "names" as Node
method xml, "InsertNode", Node
// so now our xml has a name "names"
// now we make a new one, pace an attribute and place it as a child
method xml, "PrepareNode", "element" as Node1
method xml, "PlaceAttributeToNode", Node1, "Id", "69"
method xml, "AppendChild", Node1
// we can get the XmlMono from that list child
Print type$(Child)="XmlMono"
// our child hasn't a node, so we have to make one and then insert to it
method xml, "PrepareNode", "codename","VB6" as Node
method Child, "AppendChild", Node
// we can append a child to this child
method xml, "PrepareNode", "sold","2" as Node1
method Child, "AppendChild", Node1 ' see we call AppendChild to Child object
with child, "tag" as child.tag$, "attr" as child.attr$(), "text" as child.text$, "xml" as child.doc$, "anychild" as child.child()
with child,"childcount" as child.count
Print child.tag$
Print child.attr$("Id")
Print child.text$
Print child.doc$
declare anychild xmldata
with anychild, "text" as anychild.text$, "tag" as anychild.tag$
for i=0 to child.count-1
anychild=child.child(i)
Print anychild.tag$;"=";anychild.text$
next
// we repeat the element here
method xml, "PrepareNode", "element" as Node1
method xml, "PlaceAttributeToNode", Node1, "Id", "70"
// we can place additional attribudes
method xml, "PlaceAttributeToNode", Node1, "Nobel", "yes"
method xml, "AppendChild", Node1
// we can get the XmlMono from that list child
Print type$(Child)="XmlMono"
// our child hasn't a node, so we have to make one and then insert to it
method xml, "PrepareNode", "codename","C++" as Node
method Child, "AppendChild", Node
// we can append a child to this child
method xml, "PrepareNode", "sold","3" as Node1
method Child, "AppendChild", Node1 ' see we call AppendChild to Child object
for i=0 to child.count-1
anychild=child.child(i)
Print anychild.tag$;"=";anychild.text$
next
// we repeat the element here
method xml, "PrepareNode", "element" as Node1
method xml, "PlaceAttributeToNode", Node1, "Id", "71"
method xml, "AppendChild", Node1
// we can get the XmlMono from that list child
Print type$(Child)="XmlMono"
// our child hasn't a node, so we have to make one and then insert to it
method xml, "PrepareNode", "codename","M2000" as Node
method Child, "AppendChild", Node
// we can append a child to this child
method xml, "PrepareNode", "sold","10" as Node1
method Child, "AppendChild", Node1 ' see we call AppendChild to Child object
for i=0 to child.count-1
anychild=child.child(i)
Print anychild.tag$;"=";anychild.text$
next
// part2
// we make same new xmlData object
declare Child1 xmlData
declare nChild xmlData
With nChild, "Attr" as nChild.Attr$()
for i=0 to xml.count-1
nchild=xml.child(i)
Print nChild.Attr$("Id")
next
function getnextchild(xml, &xmlmono) {
method xml, "EndOffChilds", &xmlmono as ok
= ok
}
// Here we get the result from LastChild, if we use AS and not Set we get the property
// but here we need the original pointer
// so when we change the pointer the connected propeties made them with With statement,
// these follows the object ponter.
// (when we use AS we connect the properties with a property of another object, so when we change that object, the other properties follow)
// (you see that in the For Next blocks after each element append to xml)
With xml, "LastChild" set Child1
with child1, "tag" as child1.tag$, "attr" as child1.attr$(), "text" as child1.text$, "xml" as child1.doc$, "anychild" as child1.child()
declare inner xmlData
with inner, "tag" as inner.tag$, "text" as inner.text$
method xml, "ResetChildPointer"
// here we pass a xmlData object and we get another
While getnextchild(xml, &child1)
method child1, "ResetChildPointer"
Print child1.attr$("Id"), child1.tag$,
While getnextchild(child1, &inner)
Print inner.tag$, inner.text$
end while
end While
''''''''''''''''''''''aaaaa
Pen 15 {Print "Using negative beautify, we set identation to 0 for first level"}
beautify=-4
Print #-2, doc$
Print "Press a key"
Push key$: Drop
cls
Pen 15 {Print "Using positive beautify, we set identation same for all levels"}
beautify=4
Print #-2, doc$
declare L xmlData
with L, "xml" as L.doc$,"childcount" as childrens
L.doc$=doc$
Pen 15 {Print "By default beautify=0 so we get all text in a row"}
Report 3, L.doc$
Print childrens=3
child1=xml.child(2) ' 3rd
child1=child.child(1) ' 2nd
Print child1.doc$
child1.text$=str$(val( child.text$)+1, "")
Print child1.doc$
method xml, "GetListByTag", "codename" as list_in_a_stack_object
Print "Found: ";Len(list_in_a_stack_object)
For i=1 to Len(list_in_a_stack_object)
child1=stackitem(list_in_a_stack_object, i)
Print "codename:";child1.text$
next
// another way
one=each(list_in_a_stack_object)
while one
child1=stackitem(one)
Print "codename:"; child1.text$
end while
method xml, "GetListByTag", "element" as list_in_a_stack_object
one=each(list_in_a_stack_object)
with child1, "textFromChild" as child1.child.text$()
while one
child1=stackitem(one)
nobel$=child.attr$("Nobel")
Print "Id="+child1.attr$("Id"), if$(nobel$=""-> "","Nobel="+nobel$)
Print "codename:"; child1.child.text$("codename"), "sold: ";child1.child.text$("sold")
end while
declare xml nothing