Message Boards Message Boards

0
|
7890 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Problem with an instant web form for finding the perihelion

Posted 9 years ago

Hi,

I'm trying to CloudDeploy a little form that takes the name of a planet and returns the perihelion. Here's the code.

planetDistance[a_]:=Module[{D},D=PlanetData[Entity["Planet", a], "Perihelion"]]
CloudDeploy[FormFunction[{"a"->"Planet"},planetDistance[#a]&,"GIF"]]

The function itself seem to work okay in the notebook...

planetDistance["Neptune"]
2.7710865×109mi

I get this message

enter image description here

Thank you.

vr/MB

POSTED BY: Matthew Bryan
2 Replies
Posted 9 years ago

Thank you, Emerson. This worked, and I think I understand why :-)

vr/MB

POSTED BY: Matthew Bryan

Your function implicitly assumes the input will be a string; however, when you make a choice in your form "a" is returned as an entity and not as a string.

You need to reformulate your planetDistance function to operate on an entity rather than a string.

planetDistance[a_Entity] := PlanetData[a, "Perihelion"]
planetDistance[Entity["Planet", "Neptune"]]
POSTED BY: Emerson Willard
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract