91 lines
2.9 KiB
Plaintext
91 lines
2.9 KiB
Plaintext
# Property of Four Js*
|
|
# (c) Copyright Four Js 1995, 2019. All Rights Reserved.
|
|
# * Trademark of Four Js Development Tools Europe Ltd
|
|
# in the United States and elsewhere
|
|
#
|
|
# Four Js and its suppliers do not warrant or guarantee that these
|
|
# samples are accurate and suitable for your purposes. Their inclusion is
|
|
# purely for information purposes only.
|
|
|
|
IMPORT os
|
|
SCHEMA smarmotech
|
|
|
|
DEFINE xruta STRING
|
|
FUNCTION load_demo()
|
|
|
|
DELETE FROM demos
|
|
DELETE FROM topics
|
|
|
|
-- SQLite is known to be slow if INSERTs are not in a transaction
|
|
BEGIN WORK
|
|
CALL load_data_file("demo.data")
|
|
# CALL load_data_file("extensions.data")
|
|
# CALL load_data_file("extensions_2.data")
|
|
# CALL load_data_file("extensions_3.data")
|
|
# CALL load_data_file("extensions_4.data")
|
|
COMMIT WORK
|
|
|
|
END FUNCTION
|
|
|
|
PRIVATE FUNCTION load_data_file(fn)
|
|
DEFINE fn STRING
|
|
DEFINE doc om.DomDocument
|
|
DEFINE r om.DomNode
|
|
IF os.Path.exists(fn) THEN
|
|
LET doc = om.DomDocument.createFromXmlFile(fn)
|
|
LET r = doc.getDocumentElement()
|
|
|
|
CALL walk_tree(r, "")
|
|
END IF
|
|
END FUNCTION
|
|
|
|
PRIVATE FUNCTION walk_tree(r, parentDir)
|
|
DEFINE r om.DomNode
|
|
DEFINE parentDir STRING
|
|
|
|
DEFINE n INT
|
|
DEFINE demo RECORD LIKE demos.*
|
|
DEFINE topic RECORD LIKE topics.*
|
|
DEFINE p, c om.DomNode
|
|
|
|
IF r.getTagName() == "DDir" THEN
|
|
LET topic.name = r.getAttribute("name")
|
|
IF r.getAttributeString("dirname", "none") <> "none" THEN
|
|
LET topic.dirname = r.getAttribute("dirname")
|
|
ELSE
|
|
LET topic.dirname = topic.name
|
|
END IF
|
|
# IF parentDir IS NOT NULL AND topic.dirname IS NOT NULL THEN
|
|
LET topic.dirname = parentDir, "/", topic.dirname
|
|
|
|
# END IF
|
|
LET p = r.getParent()
|
|
LET topic.parent = p.getAttribute("name")
|
|
INSERT INTO topics VALUES(topic.*)
|
|
END IF
|
|
LET c = r.getFirstChild()
|
|
WHILE c IS NOT NULL
|
|
|
|
IF c.getTagName() == "Mbs" THEN
|
|
IF c.getAttribute("name") <> "README" THEN
|
|
LET n = n + 1
|
|
LET demo.name = c.getAttribute("name")
|
|
LET demo.program = c.getAttribute("program")
|
|
LET demo.args = c.getAttribute("args")
|
|
LET demo.tipo = c.getAttribute("type")
|
|
LET demo.description = c.getAttribute("description")
|
|
LET xruta = c.getAttribute('ruta')
|
|
LET demo.basedatos = c.getAttribute('basedatos')
|
|
IF xruta IS NOT NULL THEN
|
|
LET demo.ruta = xruta
|
|
END IF
|
|
LET demo.dirname = topic.dirname
|
|
INSERT INTO demos VALUES(demo.*)
|
|
END IF
|
|
ELSE
|
|
CALL walk_tree(c, topic.dirname)
|
|
END IF
|
|
LET c = c.getNext()
|
|
END WHILE
|
|
END FUNCTION
|