How do you convert Java Blocks to Java Code?

I have not found anything on this and was wondering if you guys knew.

I had to google Java block to be sure, but as I thought, a Java block is a sequence of Java commands enclosed in curly braces which then syntactically becomes a single Java command. A Java block IS Java code.

I’m guessing that since you’re posting this under FTC, you’re probably trying to describe Blockly, which is the block based software that FTC uses. From some quick googling it looks like you are not the first to want to convert back and forth from blockly to Java.

Try doing some research with the phrase “Convert Blockly to Java” and see if that finds you information that is more relevant to what you’re looking for.

Sorry I meant Blockly to Java.

Wow. Not something I was aware of. I’m not the guy who’s going to be able to answer your question, but maybe I can help you define it well enough for someone else to answer. According to wikipedia:

Blockly is a client-side library for the programming language JavaScript for creating block-based visual programming languages and editors. It is a project of Google and is free and open-source software released under the Apache License 2.0.

What do you mean by “Blockly Code”? Is it the javascript which (in conjuction with the Blockly library) is used to create the visual programming lanuage and editor, or the code written in a Blockly-defined programming language? In the second case, I’d recommend trying to convert your code to Labview than Java.

If the first case, this is far from a trivial task. (Not saying someone hasn’t done it, to be sure!) While Java and Javascript share a few high level goals (e.g. write once run anywhere) and some syntactic structures, they are completely different animals. Using animals as an analogy, I wouldn’t put them under the same genus (Felis) or family (Felidae: lions and tigers and cats), but more likely of the same order (Carnivora) which includes dogs, seals, raccoons, and bears. Based on my experience with automated conversion, if anyone has managed an automated conversion from Javascript to Java, I would expect the converted code to be all but incomprehensible, and essentially useless for later modification.

(Automated conversion from Java to Javascript might be worse.)

There is a button on the Blockly UI labeled: “Export to Java” that you can use to convert blocks programs to java.

Every time I click that button nothing happens.

Is it because my code has vuforia?

When you click that button it should create a Java opmode in the ‘OnBotJava’ section of your screen (on the very top). You click on that to access your Java files.

If it’s not showing up on that page, I’m not sure what’s happening

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.