# Codification

I would like to use custom blocks to generate custom script code. Essentially using Snap! to simplify script creation for my users. I was looking at the Codification feature but I don't understand how I can set blocks to generate my custom code. Could someone point me to some documentation, examples or tutorials that address this topic?
Thanks,
Bill

Hi, I answered this in the contact email but I'll do it here, too, to finish off this thread...

If you go to Snap! 's File menu and choose Open, then push the big Examples button, you can open the Codification project, which shows how to implement various programming languages. That's the best documentation we have.

I'm looking at that example. My question is how do I create one of the converters?
At the bottom of the example is 'map to C' block. How do I create one of those for my own script?

That "map to C" block is written in Snap!, so you can look inside it to see how it works. It just establishes translations for each block of interest. You can duplicate the "map to C" block and change it to map to your scripting language.

Written inside, do you mean in Snap! source?
I tried exporting the project xml and the blocks xml, but I must be missing it.

Ok, I think I just figured out what you meant by look inside it. If I right click on the block and select 'edit' then I can see the sub blocks. I think that is what you mean. Sorry I was slow on the uptake.
I appreciate the assist and info.

if Codification is the word for turning things into code, what's the word for turning things into cod?
edit: thanks wikipedia! the scientific name is Gadus so would that mean the word is Gadification

How would I edit that block? I'd like to drill down into it and edit it but I can't seem to do that from the toolbar or an instantiated instance.

I don't understand the question. You figured out to say "Edit" on the block. That opened a Block Editor window. In that window, drag blocks in or out, or edit the text in the blocks that are there.

what's the word for turning things into cod?
Coddification

yeah but wouldnt that be the word for turning things into codd?

Yes; English is weird. <- "i" before "e" rule doesn't apply here (or in several other words).

i know but if we want to have separate words for cod, codd, and code, we need gadification for the cod one

If we can get back to the original question, you guys, @billcoke, do you still have a problem, and if so, can you help me understand it?

@bh Thanks for focus on question.
I was able to drag the blocks out of the edit window like you indicated.
I need to spend some more time/effort on working from here.
Thank you for your time and help.
I think that I'll probably have further questions, but this is enough for now.
Bill

Is there a way to run the program loaded to the Arduino without being connected to Snap?

Hi @usalas,
I guess you are using Snap4Arduino...

• You will find a "New Arduino translatable project" option to help our users to get simple Arduino sketches from their Snap! programs. But it's only a limited feature, as a helper.

• But Snap4Arduino is really an Snap! distro that allows you to "talk" with devices. And then, it makes Snap! projects, that are not translatable to any device. It's not only because sprites, stage, keyboard... and many other Snap! (and browser) elements. It's also about parallel execution, events, data types (and first class objects)

• Maybe you know it, but there is Microblocks project with the same idea of Snap!/Scratch about dynamic programming, but it really do it programming devices. So there, your code is always running inside the microcontroller.

• A last comment.

• If the problem is only about wires, you can connect your devices by bluetooth or wifi.
• If your problem is the autonomy of the projects... yes maybe this is not the quick solution for a makers approach (to make final object)... but for my educational perspective, I always want the computer there! Because I want that project dynamically, showing its bones, changing, testing... not only when they do it.. also when I evaluate it. Think that a Snap! project is not a program... Inside a project can be multiple programs, tests, debugging objects, visualizations...

Joan

Hi everyone, I'm trying to go deeper into how the "codification" works behind the scenes.
I see there are a few main blocks involved:

• map "..." to "..."
• map "..." to code "..."
• map "..." of "..." to code "..."
• code of "..."
• map to "language"

If I understand correctly the first 3 are building blocks inside the "map to language" to help create the translation.
I can not figure what is the role of "code of ... " . I see it used in "Set code to code of script" but I can't figure what it does exactly and why?

@bh please move this to #help as #how-to is more for tutorials (Like my "How to make an Enemy AI Agent for your top-down games" tutorial)

please don't post after a topic dies.