The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 895 - File: showthread.php PHP 7.2.34 (Linux)
File Line Function
/showthread.php 895 errorHandler->error




Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Convert .qml (QM file) to .xml
#1
2015-07-23. This will not work with files created with QM 2.4.0 and later.

Function QmlToXml
Code:
Copy      Help
;/
function $qmlFile $xmlFile

;Converts .qml (QM file) to .xml.

;qmlFile - .qml file. The function does not modify it.
;xmlFile - .xml file. The function creates or replaces it.

;REMARKS
;QM files are binary. Use this function if want to convert to text format.
;QM must be in Unicode mode.


if(!_unicode) end "QM must be in Unicode mode."

str s.getfile(qmlFile)
IXml x=CreateXml
lpstr sep="[][0][0]"

;header
int k j=findb(s sep 4)
if(!s.beg("//QM v2.") or j<0) goto ge
IXmlNode xr=x.Add("qml")
_s.left(s j); _s.encrypt(8)
xr.Add("header" _s)
xr.SetAttributeInt("version" 1)

;items
lpstr name triggerEtc flagsEtc folder text
rep
,j+4; if(j=s.len) break
,name=s+j
,triggerEtc=name+len(name)+1 ;;can contain not only trigger
,flagsEtc=triggerEtc+len(triggerEtc)+1 ;;flags[ date[ image]]
,folder=flagsEtc+len(flagsEtc)+1
,text=strstr(folder "[]"); if(!text) goto ge
,j=findb(s sep 4 text-s+2); if(j<0) goto ge
,
,IXmlNode xi=xr.Add("item")
,xi.SetAttribute("name" name)
,if(triggerEtc[0]) xi.SetAttribute("triggerEtc" triggerEtc)
,xi.SetAttribute("flagsEtc" flagsEtc)
,text[0]=0; xi.SetAttribute("folder" folder)
,text[0]=13; text[-1]='.'; xi.Value=text-1 ;;.[]text[] ;;. prevents removing empty lines

;x.ToString(_s); out _s
x.ToFile(xmlFile)

err+ end _error
ret
;ge
end "bad file format"

Function QmlFromXml
Code:
Copy      Help
;/
function $qmlFile $xmlFile

;Converts .xml file created by QmlToXml back to .qml format.

;qmlFile - .qml file. The function creates or replaces it.
;xmlFile - .xml file. The function does not modify it.

;REMARKS
;QM must be in Unicode mode.


if(!_unicode) end "QM must be in Unicode mode."

str s
IXml x=CreateXml
x.FromFile(xmlFile)
lpstr sep="[][0][0]"

IXmlNode xr=x.RootElement
if(xr.AttributeValueInt("version")!1) end "different version"

IXmlNode xi=xr.FirstChild
if(StrCompare(xi.Name "header")) goto ge
s.decrypt(8 xi.Value)
s.geta(sep 0 4)

rep
,xi=xi.Next; if(!xi) break
,if(StrCompare(xi.Name "item")) goto ge
,lpstr text=xi.Value; if(text[0]='.') text+1; else goto ge ;;prevent removing empty lines
,s.fromn(s s.len xi.AttributeValue("name") -1 "" 1 xi.AttributeValue("triggerEtc") -1 "" 1 xi.AttributeValue("flagsEtc") -1 "" 1 xi.AttributeValue("folder") -1 text -1 "[0]" 2)

;outb s s.len 1
s.setfile(qmlFile)

err+ end _error
ret
;ge
end "bad file format"


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)