0 Members and 1 Guest are viewing this topic.
xml = {"<ttl>Hello","<txt>this is a test to show you the possibilities of xml in Nspire lua","<txt>It's very simple, just type a tag like <ttl> and than your title","<img>\030\000\000\000\030\000\000\037\/*find yourself a pic to insert, it would be too long to post */137\194\137\194\137\198\207\210x\235\000\000\000\000","<txt>and it automatically scrolls down to the next line after the image","<txt>this is the last sentence!"}
because i (well, not i, just the calc xp) read the line, and seperate the tags, i can easely add them if you want to, it's 2 seconds of work, i just thought it would be easier to not use them as it work per line (the tag ends at the end of the string).
and i'm having a look at that github, it would be a good idea to post it there, for having the most recent version every time
markup = { {ttl = "Hello"}, "this is a test to show you the possibilities of xml in Nspire lua", "It's very simple, just type a tag like <ttl> and than your title", {img = "\030\000\000\000\030\000\000\037\/*find yourself a pic to insert, it would be too long to post */137\194\137\194\137\198\207\210x\235\000\000\000\000"}, "and it automatically scrolls down to the next line after the image", "this is the last sentence!"}for i, v in ipairs(markup) do local t = type(v) if t == "table" then if v.ttl then print('Title: ', v.ttl) elseif v.img then print('Image: ', v.img) end else print(v) endend
i think i'll just upload them to my own site and refer to that page, since i don't manage to get the github working xs i followed the tutorial to install it, and i did everything required, but it does not work xs
-- Adriweb-- TI-Planet-- Original Idea by Nick Steen, Some things added by Extendedplatform.apilevel = '1.0' count = 0markup = { {ttl = "hello"}, {txt = "hallo"}, {center = {txt = "centered text"} }, {txt = "goodbye"}, {bold = {txt = "oh wait ! bold text !!"} }, {img = "\016\000\000\000\018\000\000\000\000\000\000\000 \000\000\000\016\000\001\000\156\243\156\243\156\243\189\247\213\222\235\193\136\181g\181\135\181g\181\137\185O\202\189\247\156\243\156\243\156\243\156\243\156\243{\239O\206\168\222F\243D\243d\247d\247#\243\004\235E\214\170\1858\231\156\243\156\243\156\243\213\222m\210\231\230d\247\132\251\195\255\131\255\131\255\131\255C\251\003\247\132\226\233\193r\210z\239\156\243\204\189\198\226\132\247\166\218\007\198\198\226\195\255\131\255#\243\231\197\007\198\002\251\131\230\135\185\246\222\212\218g\210D\243\166\218\166\218\197\226D\239\131\255\131\255C\247\165\218d\222\006\206\194\242\196\205O\206\170\185\005\239\131\255\197\226D\239\131\255\131\255\131\255\131\255C\251\034\255\002\255E\218\226\250b\234\167\193G\173C\247\131\255\131\255\130\218\001\198\162\222\131\255c\251\002\243\161\197\161\197\226\250\226\250\162\246\133\193f\181#\243C\251\131\255\194\193\194\156\002\202C\251\034\255\162\234\194\156\194\156\193\250\193\254\193\254\133\193g\181\003\247c\251\034\255\196\230e\218\196\234\034\255\034\255\226\242%\218%\218\226\250\226\250\161\254\133\193&\169\226\242\034\255\034\255\034\255\034\255\034\255\002\255\002\255\193\254\193\254\226\250\161\254\161\254\161\254d\189G\173\163\234\002\255\226\242\194\242\163\234\162\242\162\242\162\242\130\238\130\242B\242\130\242\162\246B\242\133\193\014\198E\214\194\242f\181\198\156\231\156\231\156\231\156\231\156\231\156\231\156\198\156\231\156B\242\227\213\235\197Y\235\136\185\130\238\193\254\132\189s\206\222\251\222\251\222\251\222\251{\239\198\156\130\242\129\254d\189\179\214\156\243\237\193\196\205\162\242\162\242\198\201)\165)\165)\165)\165H\173B\242\129\254\227\213\169\193\023\227\156\243z\239\137\185\034\226\162\246\130\242B\234\034\230\034\230B\234\034\234\129\254\130\242D\181\213\222\156\243\156\243\156\243\023\227\201\197\002\222\162\246\161\254\129\254\161\254\129\254\129\250\034\234d\189\147\214\156\243\156\243\156\243\156\243\156\243\246\222\011\206\196\205\002\222B\238\034\238\034\230\196\209\165\197\147\214{\239\156\243\156\243\156\243\189\247\156\243\156\243\023\227p\210\011\206\198\205\198\205\232\205O\210\147\214\156\243\156\243\156\243\156\243"}, {txt = "really, goodbye"}}function on.paint(gc) if go then go = false print("----") Parse(gc, markup, {centered=false}) count = 0 endendfunction Parse(gc, data, options) for i, v in ipairs(data) do local t = type(v) if t == "table" then if v.ttl then count = count + 1 gc:setFont("serif","b",18) myPrint(gc, v.ttl, count-1, {}) elseif v.txt then gc:setFont("serif","r",12) myPrint(gc, v.txt, count, options) elseif v.img then local tmpImg = image.new(v.img) gc:drawImage(tmpImg,0,image.height(tmpImg)*(count-2)) print('Image displayed') elseif v.center then Parse(gc, {v.center}, {centered=true}) elseif v.bold then Parse(gc, {v.bold}, {bold=true}) end count = count + 1 else print("what's going on here ?") myPrint(gc, v, count, {centered=false}) end endendfunction drawXCenteredString(gc,str,y) gc:drawString(str, (pww() - gc:getStringWidth(str)) / 2, y, "top")endfunction myPrint(gc, string, y, options) if options.centered then drawXCenteredString(gc,string,14*y) elseif options.bold then gc:setFont("serif","b",12) gc:drawString(string,1,14*y,"top") else gc:drawString(string,1,14*y,"top") end print(string)end function pww() return platform.window:width()endfunction pwh() return platform.window:height()endfunction on.enterKey() go = trueend
markup = { {ttl = "hello"}, {txt = "hallo"}, {center = {txt = "centered text"} }, {txt = "goodbye"}, {bold = {txt = "oh wait ! bold text !!"} }, {img = //image-string//}, {txt = "really, goodbye"}}
"welcome to the world of computers, where everything seems to be based on random number generators"
Good for me