1
$\begingroup$

I'm planning to wrap my FormFunction expression in Cloulddeploy but am having trouble giving input to the required data to Encde, the function I want to run inside FormFunction. Encde runs fine in a notebook on its own, but not inside FormFunction. The websites I've looked at for help (with my untrained eye, including Mathematic.SE) seem to offer contradictory examples of how the function is suppose to be formatted inside FormFunction.

What is the correct way to include a user defined function inside a FormFunction expression?

Encde[v1_, p1_] := 
 TableForm[
  Flatten[
   ToUpperCase[
    IntegerString[
     {Times[ToExpression[ToCharacterCode[v1]], p1]}, 16]] 
    ], TableDirections ->Row
   ]

FormFunction[{"v1"->"String", "p1"->"Integer"}, Encde]
$\endgroup$
2
$\begingroup$

Form functions get an association from the input dialog, so try

Encde[input_] := 
  TableForm[
    Flatten[ToUpperCase[
      IntegerString[{Times[ToExpression[ToCharacterCode[input["v1"]]], input["p1"]]}, 16]]], 
    TableDirections -> Row]

FormFunction[{"v1" -> "String", "p1" -> "Integer"}, Encde]

ff1

ff2

$\endgroup$
  • $\begingroup$ Thanks. Small improvement running in this code this morning. Unforuately, even with copy and pasting directly, my code is still not initiating the wrapped function in a notebook. It is triggering when deployed however but then not displaying in 'tableform'. I will have to investigate more later today. $\endgroup$ – BBirdsell Jul 9 '17 at 14:58
  • $\begingroup$ Would there be a reason when I copy your example and execute it, it wouldn't generate the submit button in the notebook? $\endgroup$ – BBirdsell Jul 9 '17 at 23:43
  • 1
    $\begingroup$ @BBirdsell. Really? As you can see from my post, on my system, the Submit appears. I don't what to say without seeing your notebook. Can only suggest trying my code all by itself in a fresh notebook in a fresh Mathematica session. $\endgroup$ – m_goldberg Jul 10 '17 at 3:08
  • $\begingroup$ Actually I should try that but am beginning to suspect (FYI) it's a quirk of MMA Online after investigating the error message further. I really love MMA Online but wasn't expecting problems with common functions like FormFunction. In any case, I did learn something your answer and I'm not the sort of person to get worked up about bugs in the online platform because I bet it's pretty complicated to get something like MMA working perfectly smoothly in the cloud and WF seems pretty determined to keep refining their could products. $\endgroup$ – BBirdsell Jul 10 '17 at 19:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.