First off, this is not a question related to pedagogy. I am relatively new to CODE.ORG and app lab programming environment. I am getting the hang of coding (I prefer text mode from previous experience) and have designed an app which will find prime factors of numbers. The problem is always the output! The ‘write’ command seems so limited and sometimes when looping through a list I get all kinds of errors with using write command. I would like to be able to create textboxes as needed by the number of different factors the program finds DYNAMICALLY, rather than setting them up all in DESIGN mode in advance, since I do not know how many text boxes will be needed. I doubt that this is possible in this programming environment. So if any of you more experienced teachers using CODE. ORG have ideas on this, I am all ears! A more pressing issue concerning output: How is it possible to output a character that is a SUPERSCRIPT? I would like this functionality with this particular APP, but this is really hard to find. I have tried some 'fromcharCode() commands to work with ASCII characters but cannot see how to get a superscript of a number (really, a ‘string’ character in this context.) Maybe some import libraries would help here! Though the rubric for coding from students set down by AP committee requires some mathematical/logical structures, loops, subprocedures, AP lab does not do very well with mathematical processes and the UI interface for math is VERY LIMITED. I have since found many commands as methods from the Math.whatever object and they are helpful. JavaScript has to be a lot more versatile than the limited functions supplied by UI. Thanks for any help on this folks!
As far as creating a dynamic set of textboxes goes, it made me think back to how I was creating button dynamically once for a project. Here’s the abstraction I created:
(My first time posting to this forum, so apologies for any formatting errors)
function MakeIngredientButtons(){
var buttonNum = 0; // button counter
for (var y = 95; y <= 410; y += 35){ // predetermined coordinates for my x and y placements of my buttons
for (var x = 50; x <= 180; x += 130){
button("ingredient"+buttonNum, "ingredient"+buttonNum); // command to create a new button
setPosition("ingredient"+buttonNum, x, y, 80, 30); // assign position for new button by name
buttonNum++; // increment button counter in prep for next button
}
}
}
}
I’m not sure if this helps you exactly with what your looking for, but it sounds like it may be similar to your goals.
It’s worth noting, that in my case, I did have a really tough time following this through all the way to fruition in my own project, and I ended up going through the tedious process of manually setting up a table through the UI editor, but that’s just because setting up the table of buttons was the start of a process and not just displaying the results.
As for superscript, I’m afraid I’ve no idea how to approach that one, and 5 minutes of googling didn’t help either… but good luck! I’d probably try implementing a second, differently formatted text box aligned smaller and higher where needed if it is imperative to have the effect…
Thank you so much; THIS MAKES SENSE! If you would consider answering a (hopefully) much easier question: I have tried to add DROPDOWN boxes for this basic app. Does this require a lot of coding with behavior for the choice on the menu before it acts correctly? When I try to select an item in the dropdown box, all of the options vanish and the mouse is of no use! This seems extremely glitchy! What am I missing here? Even if there is no code yet behind the behavior of the control, I would expect to be able to make a choice with the mouse. I can click on ‘down arrow’ on dropdown box and then use arrow key to navigate, but I am sure that the selections should be readily available by simply clicking on selections as is usally the case. thanks for you reply!