Hi Bryan,
actually your solution should work, I think. That is what I am doing and it
looks like your way:
var Module = {
arguments: [gametag,idxdb],
preRun: [],
postRun: [],
print: (function() {
if (debug==1)
{...
Can you perhaps try to create javascript and html output, add the arguments
to the generated html and see if it works?
Am Montag, 13. Juli 2015 15:51:17 UTC+2 schrieb Bryan Duggan:
>
> Really sorry
>
> I read that and I dont understand your answer at all...
>
> Here is what I want to do:
>
> Create a file (this should be in preRun?)
> Execute abc2midi - I want this to be triggered not run when the page loads
> Get the generated midi file (this should be in postRun?)
>
> Can emscriptren be made to do this? Are there any simple examples of how
> to set this up?
>
> WRT To your answer. I am not generating HTML, just JavaScript. Here is my
> full HTML page:
>
> <html>
> <head>
> <script src = "abc2midi.js"></script>
> </head>
> <body>
> <script>
> var abcContents = "X:1\nT:Jimmy Ward's Jig\nR:jig\nD:Matt Molloy: Heathery
> Breeze\nZ:id:hn-jig-103\nM:6/8\nK:G\n~G3 GAB|AGE GED|~G3 AGE|GED DEF|~G3
> GAB|AGE GAB|cBA BGE|1 DED DEF:|2 DED D2B||\n|:cBA BAG|~A3 AGE|BcA BGE|EDE
> GAB|c2c BAG|ABA ABc|dcA AGE|1 GED D2B:|2 GED DEF||\n\n"
> var argv = [ "in.abc", "1", "-o", "out.mid"];
>
> var Module = {
> "arguments": argv,
> "print": function(text){
> console.log('print');
> console.log(text)
> },
> "printErr": function(text){
> console.log(text)
> },
> "preRun" : function(){
> console.log('prerun');
> FS.createDataFile("/", "in.abc", abcContents, true, true);
> },
> "setStatus": function(text){
> console.log('setStatus');
> console.log(text)
> },
> "noInitialRun": true,
> };
> run(); // This does not run abc2midi though preRun gets called
> </script>
> </body>
> </html>`
>
> And here is how I am compiling:
>
> emcc genmidi.c midifile.c parseabc.c parser2.c queues.c store.c -o
> abc2midi.js -s EXPORTED_FUNCTIONS="['_main', '_abc2midi']"
>
> Im at a loss as to what to try next
>
> Bryan
>
>
> On Monday, 13 July 2015 13:23:39 UTC+1, chronotext wrote:
>>
>> It looks like you work with Module as if you were still in Node mode.
>>
>> But when working in HTML mode, Module has already been defined, as
>> explained here:
>>
>>
>> https://kripken.github.io/emscripten-site/docs/api_reference/module.html#creating-the-module-object
>>
>> On Monday, July 13, 2015 at 2:41:55 PM UTC+3, Bryan Duggan wrote:
>>>
>>> Thanks
>>>
>>> Here is my problem though. If I compile like this:
>>>
>>> emcc genmidi.c midifile.c parseabc.c parser2.c queues.c store.c -o
>>> abc2midi.js -s EXPORTED_FUNCTIONS="['_main', '_abc2midi']"
>>>
>>> Even if I set noInitialRun: true in Module like this:
>>>
>>> var argv = [ "in.abc", "1", "-o", "out.mid"];
>>> var Module = {
>>> arguments: argv,
>>> print: function(text){
>>> console.log('print');
>>> console.log(text)
>>> },
>>> printErr: function(text){
>>> console.log(text)
>>> },
>>> preRun : function(){
>>> console.log('prerun');
>>> FS.createDataFile("/", "in.abc", abcContents, true, true);
>>> },
>>> noInitialRun: true,
>>> };
>>>
>>> The C program runs, but does not take the command line arguments!! I can
>>> see the output on the Javascript console. Also preRun is never called
>>>
>>> If I compile like this:
>>>
>>> emcc genmidi.c midifile.c parseabc.c parser2.c queues.c store.c -o
>>> abc2midi.js -s EXPORTED_FUNCTIONS="['_main', '_abc2midi']" -s INVOKE_RUN=0
>>>
>>> And try this in my HTML page:
>>>
>>> var argv = [ "in.abc", "1", "-o", "out.mid"];
>>>
>>> var Module = {
>>> arguments: argv,
>>> print: function(text){
>>> console.log('print');
>>> console.log(text)
>>> },
>>> printErr: function(text){
>>> console.log(text)
>>> },
>>> preRun : function(){
>>> console.log('prerun');
>>> FS.createDataFile("/", "in.abc", abcContents, true, true);
>>> },
>>> noInitialRun: false, // Makes no difference
>>> };
>>> run();
>>>
>>> preRun gets called but the C program doesnt run
>>>
>>> Whats going on!?
>>>
>>> Bryan
>>>
>>>
>>>
>>> On Monday, 13 July 2015 10:52:54 UTC+1, chronotext wrote:
>>>>
>>>> Hi there,
>>>>
>>>> I think Module.arguments is what you're looking for:
>>>>
>>>>
>>>> https://kripken.github.io/emscripten-site/docs/api_reference/module.html#affecting-execution
>>>>
>>>> HTH,
>>>> Ariel
>>>>
>>>> On Monday, July 13, 2015 at 2:07:13 AM UTC+3, Bryan Duggan wrote:
>>>>>
>>>>> Hey
>>>>>
>>>>> I presume this is standard enough usage for emscripten, but I cant
>>>>> figure out how to do it. I am trying to port a command line C program
>>>>> called abc2midi to emscripten.
>>>>>
>>>>> Everything compiles fine and I can get both the javascript to generate
>>>>> and run in node and the HTML to generate and run in the browser.
>>>>>
>>>>> Now I want to do the following:
>>>>>
>>>>> 1 Write a text file to the virtual file system. This is how Im doing
>>>>> it:
>>>>>
>>>>> var Module = {
>>>>> 'print': function(text){
>>>>> console.log(text)
>>>>> },
>>>>> 'printErr': function(text){
>>>>> console.log(text)
>>>>> },
>>>>> 'preRun' : function(){
>>>>> console.log('prerun');
>>>>> //FS is not defined
>>>>> FS.createDataFile("/", "in.abc", abcContents, true, true); },
>>>>> 'noInitialRun': true,
>>>>> };
>>>>>
>>>>> 2. Call the main method and pass in some command line arguments
>>>>> including the file name. I cant find an example of how to do this and
>>>>> everything Ive tried has not worked
>>>>>
>>>>> 3. Read back the generated file from the file system
>>>>>
>>>>> Surprisingly hard to find an example of this pretty straightforward
>>>>> scenario! Any help would be much appreciated
>>>>>
>>>>> Bryan
>>>>>
>>>>
--
You received this message because you are subscribed to the Google Groups
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.