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.

Reply via email to