05-01-2018, 07:54 AM
Macro get QM item properties from a QM file
out
str sPath="Q:\My QM\backup\System.DA667CE0.47ED2B42.qml"
Sqlite x.Open(sPath 1)
SqliteStatement g t
g.Prepare(x "SELECT rowid,name,flags FROM items")
t.Prepare(x "SELECT date,text FROM texts WHERE rowid=?1")
rep
,;get item properties from 'items' table
,if(!g.FetchRow) break
,int rowid=g.GetInt(0)
,str name=g.GetText(1)
,int flags=g.GetInt(2)
,int itemType=flags&0xff
,int isFolder=itemType=6
,lpstr st=0; sel(itemType) case 1 st="Macro"; case 2 st="Function"; case 3 st="Menu"; case 4 st="Toolbar"; case 5 st="Autotext"; case 6: st="Folder"; case 7 st="Member f."; case 8 st="File link"
,
,;get item properties from 'texts' table
,t.BindInt(1 rowid)
,t.FetchRow
,
,;get date
,str date
,if isFolder
,,date="-"
,else
,,DateTime* p=t.GetBlob(0 _i)
,,if(p.t) DateTime d=sub.Reverse64(p.t); date=d.ToStr; else date="unknown"
,
,;get text. Maybe you don't need it, it's just an example. If don't need, remove ",text" from SELECT.
,str text=t.GetText(1)
,text.LimitLen(100); text.escape(1) ;;to display in single line
,
,t.Reset
,
,out F"<>{name%%-30s} <c 0xff0000>{st%%-12s}</c> <c 0x8000>{date%%-20s}</c> <_>{text}</_>"
#sub Reverse64
function'long long'x
long r
byte* a(&x) b(&r)
int i
for i 0 8
,b[7-i]=a[i]
ret r