0

How to add arguments to functions
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

How to add arguments to functions

by bhedrick on Sun Apr 08, 2018 9:29 am

I created a new function and then went into the javascript window to add arguments. I receive the error "Oops, something went wrong when trying to convert your code." Any ideas?

function setPixelColor(x: number, y: number) {

}

bhedrick
 
Posts: 6
Joined: Sat Sep 01, 2012 1:09 pm

Re: How to add arguments to functions

by bhedrick on Mon Apr 16, 2018 2:06 pm

I didn't figure out how to do this. In the meantime, I end up creating a package on github, and then added it as an extension, to do what I needed.

https://github.com/hedrickbt/pxt-clr-text

bhedrick
 
Posts: 6
Joined: Sat Sep 01, 2012 1:09 pm

Re: How to add arguments to functions

by GuitarHero on Wed May 02, 2018 9:23 am

Your extension adds a block for a single javascript function charCodeAt() to the MakeCode editor.
But what about the functions created with the MakeCode editor itself?
If I call "ADVANCED - FUNCTIONS - Make a Function - New function Name - xyz", there is no way to add parameters to this new function.
Does anybody have a solution for that?

GuitarHero
 
Posts: 8
Joined: Fri Apr 06, 2018 10:01 am

Re: How to add arguments to functions

by pelikhan on Thu Jun 07, 2018 1:14 am

We've recently added a playground to learn how to author blocks. Check it out at https://makecode.com/playground

pelikhan
 
Posts: 15
Joined: Wed Sep 27, 2017 12:18 pm

Re: How to add arguments to functions

by flounder on Sun Oct 07, 2018 7:45 am

I want to have parameters to functions also. But the simple example at the specified link does not show how to create functions with parameters, only how to create blocks of JavaScript code that can be recognized as blocks. This does not help those of us who want to use parameters.
joe

flounder
 
Posts: 324
Joined: Wed Sep 18, 2013 9:10 pm
Location: Pittsburgh PA

Please be positive and constructive with your questions and comments.