codification code happining in the back

I got 2 question regarding codification:

  1. Is there any documentation on how and what the codification blocks are doing?
    image
    They are only replacing text with text as far as I can see.
  2. Is there a way to include own blocks in the mapping in smart way? All I can do right now is to create a dummy and a dummy definition, but then I have to manually correct it.
    image

Codification allows you to translate Snap! to another programming language.
Mapping to header allows variable declarations, function definitions, and other things that will be put at the top of the script.
There is an example project that uses codification (File > Open... > Examples > Codification > Open).

I understand how to use the map function , but I dont understand how to use the header and the code section. The heade and the code section is always empty in the example. Do you have an example? I read the manual, went thru example, but still dont understand it. Where can you define the "list", "item","delimiter"? I did not find an example of a function.
image

I think @jens or @bh would be able to help you more with this.

I just found out by the example of the custom block "fib" that the header should be mapped to a functional definition via map to header and the code to the definition of the custom block. If both mappings are done correct the script will be mapped to the code with the function definition and the function call. Very happy about this example but I wish there would be a handbook, manual or a guideline.... I find out a lot by trial and error..... like before in my life...and it just takes so much time...

Hi Matthias, I'm glad you found this, as I was just about to point you to this very example :slight_smile:
Cheers!

So I can define any arbitrary function with recursion and all kind of advanced stuff and transfer it via codification to some other code??????? I did not try to convert custom blocks so far and I am a bit surprised now.

Not urgent and sorry when I bug you, but where ist the definition of "list","item","delimiter" ???? and why is there a dropdown of "collection, variables, parameters"? How do you use that?

yep, all the advanced stuff is possible. C'mon, of course recursion has to work properly :slight_smile:

items inside collection literals such as arrays are usually delimited by commas (which you can - and have to - specify accordingly). But some languages have other delimiters. Same for the formal parameters of a function definition etc. That's what these options are for.

e.g. you can define a bunch of local variables in JS like this:

var foo, bar, baz;

the variable name being separated by commas.

the same code in Smalltalk looks like this:

| foo bar baz |

with no delimiting character between the variable names.

Does this make sense to you?

Sure, THANKS a lot!

I want also local functions to be codificated. Right now it works only for global functions (and I guess also only global variables) Whom do I have to pay what so codification is enhanced also to sprite-local functions?

Jens and Bernat and Joan are all on vacation for a week or two, so right now I don't think you can pay anybody anything. There's still Michael but he's obviously on putting-out-fires duty for now. When the Europeans get back, then you can ask Jens.

4 posts were split to a new topic: Life of Brian

Well, codification of local functions is not a matter of life and death to me. And I haven't got an awful lot of money to pay anyways, so I just wait a few weeks and progress on my other projects.

@jens, @bromagosa, @bh
I would like also local functions to be codificated. Right now it works only for global functions (and I guess also only global variables) for 1 single sprite. Whom do I have to pay what so codification is enhanced also to sprite-local functions and variables? It would be great for teaching OOP!!! Pleeease do something about it.

Oh, that doesn't work? Haha, lemme see..

Error in console
Uncaught TypeError: Cannot read property 'blockInstance' of null
    at CustomCommandBlockMorph.BlockMorph.codeMappingHeader (blocks.js?version=2020-09-14:3828)
    at CustomCommandBlockMorph.BlockMorph.mapToCode (blocks.js?version=2020-09-14:3656)
    at MenuItemMorph.TriggerMorph.trigger (morphic.js?version=2020-09-12:9827)
    at MenuItemMorph.mouseClickLeft (morphic.js?version=2020-09-12:10114)
    at TextMorph.Morph.escalateEvent (morphic.js?version=2020-09-12:4610)
    at TextMorph.StringMorph.mouseClickLeft (morphic.js?version=2020-09-12:9016)
    at HandMorph.processMouseUp (morphic.js?version=2020-09-12:11419)
    at HTMLCanvasElement.<anonymous> (morphic.js?version=2020-09-12:12144)

yeah, we'll fix it

Not urgent though, but would be VERY helpful.