Passing variables from Parchment/i7 to JavaScript and back

Any sentence that begins with me saying “if I’m remembering my programming terms correctly” is in for a rough ride.

In my usual state of “I have plans for doing this in Glulx, but no immediate deadline.” Sigh.

(Things will improve in a couple of months. Details soon.)

I definitely want to add a Glk API for exchanging information with the Javascript framework (for Javascript terps), and also with included HTML “images” (that feature will go along with this one.) I grok that it has to be a two-way exchange.

It won’t be using magic characters in the output, though. Probably you’ll have to fill out a string buffer and then call a Glk function to send data, and then wait for a Javascript event to receive.

Okay, here’s my implementation for a very basic JS evaluator. Firstly the spec: curiousdannii.github.com/if/op-parchment.html
which says it works on Z-Machine and Glulx. If you want Quixe support it won’t be hard to add.

Source code showing how to use it: github.com/curiousdannii/if/blob … chment.inf
You can use as many different print statements as you want, so there’s no problems with having dynamically generated code too.

You’ll also need the latest Gnusto: github.com/curiousdannii/gnusto
And you need to set PARCHMENT_SECURITY_OVERRIDE=1; in your copy of Parchment.

This particular @parchment function will probably never work on the official Parchment website. If I figure out a way to deal with the security issues then I might add another function.

Getting data back is a bit harder, but not too hard. Let me know if you need it and I’ll figure something out.

This looks like an awesome start. Thank you! I will dig into this soon (thesis proposal due tonight) and start playing around. Yay!

Hope your thesis proposal goes well! I just submitted my thesis last friday, and am quite relieved!

Just got done looking at that Google Groups thread; noticed it was from 2009. I know some of this functionality is in the pipeline via people’s projects, but I have this crazy IF idea that I’d have to rush out the door by December 10-ish (don’t worry, all this would be on me, not on you). Parchment’s undoubtedly been updated since then – would they still work with the latest version?

Said project is fairly simple – just has photos and CSS.

Does that mean you just want to pass stuff to Javascript, and not get anything in return? If so you can use the updated version of Gnusto I mentioned a couple of posts back.

I’m looking to implement this solution, would you be willing to elaborate?

Zombie thread says “vooorrrrpppllee”.

Jeepers, I thought that said November 10th not November 2010…

I’ll take a look but Vorple seems like overkill for what I want, thanks.

1 Like