Author Topic: XML2TXT, XML2LUA, TXT2XML, LUA2XML and 2TNS  (Read 13849 times)

0 Members and 1 Guest are viewing this topic.

Offline SpiroH

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 729
  • Rating: +153/-23
    • View Profile
XML2TXT, XML2LUA, TXT2XML, LUA2XML and 2TNS
« on: September 11, 2012, 06:24:12 pm »
Hi, I've been playing around with the weird xml usage by TI. I'm not sure if what i'm going to present to you is of any interest to the programmers community in general but i've decided to do it, anyway. What started me with this type of thing was the need to quickly send a text document to the Nspire calculator, without having to use the tiny in-calc editor. So, i've looked around in omnimaga site and i found first the TNS2XML  in-calc utility, which allows you to grab the xml content of a tns doc via a hook, without going thru the hassle of having to decrypt the tns (btw, a clever idea). That was my starting point, i could finally get hold of the xml content. But, alas, looking inside the xml, the text was not clear at all. So, how could you recover back the embedded text? It had to be there (hidden) somehow!? A second look into the xml and i've found some clues on how that could eventually be done. Well, i think i did it with my XML2TXT utility. Just drop a 'Problem.xml' on top of it, and in principle it should present you at the bottom window the embedded text inside the xml.
     

Secondly, what about the other way around? How on earth could we encode a text-file and send it the calc. We need to prepare an xml file that can be understood by the Nspire. Next, we need to encrypt and compress it, short make it a tns-doc file. Luckly, this latter step had already been accomplished via the 'luna' utility (link below). So, i was left with the task of transforming the text-file into a suitable xml format that could then be post-processed by the 'luna' utility to produce the final 'tns' doc. Now, we only need to send it to the calc and open it up. This brings me to my second utility TXT2XML, that does just that, it encodes the text-file into xml and with the help of 'luna' produces a 'tns' file, ready to be openned in-calc. After some more digging, i thought it would be interesting to do the same for 'lua' scripts. Here, the generated xml has different xml-elements. So i've adjusted both previous utilities to also handle the lua scripts.
     
To clear up a bit more the explanation, i emphasize the fact that the TXT2XML utility actually does a bit more than just the xml generation, it also creates the respective 'tns' files with the help of 'luna'.

You can download luna-v0.3a.zip here. To be able to generate 'tns' files, you'll need to extract the 2 files 'luna.exe' and 'libeay32.dll' and place both in the same directory as the 2 utilities TXT2XML and XML2TXT.

As already said above, i'm not sure if this can be useful for people, but at least for me it was fun to develop and use them with the nspire emulator. See if it suits you in any way. There may exist some compatbility issues, which i'll try to tackle later.

Enjoy,
SpiroH

P.S: I know this is rather basic stuff for many of you, but i think it can be helpful for newcomers to the nspire environment.




Offline blfngl

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 121
  • Rating: +3/-4
  • No worry, I'll surpass Calc84 in greatness...never
    • View Profile
Re: XML2TXT, XML2LUA, TXT2XML, LUA2XML and 2TNS
« Reply #1 on: September 11, 2012, 07:29:19 pm »
Very nice! I can't wait to use it :)
« Last Edit: September 11, 2012, 07:29:44 pm by blfngl »
GAMEGAMEGAMEGAMEGAMEGAMEGAMEGAMEGAMEGAME
My blog:

TiLibs
My Projects:
Minecraft Library

Offline ElementCoder

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 611
  • Rating: +42/-2
    • View Profile
Re: XML2TXT, XML2LUA, TXT2XML, LUA2XML and 2TNS
« Reply #2 on: September 12, 2012, 05:54:54 am »
This is definitely useful! Good job.

Some people need a high five in the face... with a chair.
~EC

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: XML2TXT, XML2LUA, TXT2XML, LUA2XML and 2TNS
« Reply #3 on: September 12, 2012, 06:27:24 am »
Nice !

Although for Lua scripts the built-in editor is there for that :P (in TINCS 3.2, I mean)
But for people who don't have it, it's definitely a good job.

By the way, what language is this written in ? Any chance it would compile on other platform ?



EDIT : It looks like there are still some   "   chars here and there ?  (in the example lua file)
« Last Edit: September 12, 2012, 06:30:22 am by adriweb »
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline SpiroH

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 729
  • Rating: +153/-23
    • View Profile
Re: XML2TXT, XML2LUA, TXT2XML, LUA2XML and 2TNS
« Reply #4 on: September 13, 2012, 06:20:43 pm »
Thank you all for the nice remarks and excuse me for the late response.

By the way, what language is this written in ? Any chance it would compile on other platform ?
The language is c++. Well, it relies on windows IXMLDOMDocument interface, but it shouldn't too difficult to find some equivalent in the unix/mac-world. Right now, i don't have much time, but asap i'll try to split the GUI and make a simpler console app that should be easy enough to port. I'll see what i can do.

Quote from: adriweb
It looks like there are still some   "   chars here and there ?  (in the example lua file)
Thanks! Yeah, sorry about that. Hope is fixed now. Please check attachment.

Also, this was a first version to test the 'concept'. The previous problem was due to a weird escape-sequence not being detected in TXT2XML utility. It's possible that some others will surface with different lua scripts. We'll get them then. ;)  I've also added a 'save' button to the XML2TXT utility, so that the user can save the text/lua-script rather then use the clipboard.

Cheers,

Offline Jonius7

  • python! Lua!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1918
  • Rating: +82/-18
  • Still bringing new dimensions to the TI-nspire...
    • View Profile
    • TI Stadium
Re: XML2TXT, XML2LUA, TXT2XML, LUA2XML and 2TNS
« Reply #5 on: June 30, 2013, 01:57:19 am »
Err, so what's 2TNS then?
This looks like a nifty set of tools that'll come in handy, nice work.
« Last Edit: June 30, 2013, 01:57:57 am by Jonius7 »
Programmed some CASIO Basic in the past
DJ Omnimaga Music Discographist ;)
DJ Omnimaga Discography
My Own Music!
My Released Projects (Updated 2015/05/08)
TI-nspire BASIC
TI-nspire Hold 'em
Health Bar
Scissors Paper Rock
TI-nspire Lua
Numstrat
TI-nspire Hold 'em Lua
Transport Chooser
Secret Project (at v0.08.2 - 2015/05/08)
Spoiler For Extra To-Be-Sorted Clutter:

Spoiler For Relegated Projects:
TI-nspire BASIC
Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled) | Cosmic Legions (stalled)
Axe Parser
Doodle God (stalled while I go and learn some Axe)