7

I have:

Fence[content_, length_] := Column[{
   Grid[Partition[Characters[content], UpTo[length]]],
   Grid[{Select[
      Flatten[Transpose[
        PadRight[
         Partition[Characters[content], 
          UpTo[length]], {Ceiling[Length[Characters[content]]/length],
           length}, "@@"]]], # != "@@" &]}]
   }]
Mani[content_] := 
 Manipulate[Fence[content, x], {x, 1, Length[Characters[content]], 1}]

Then test it in my desktop Mathematica and everything goes well:

enter image description here

So I deploy:

CloudDeploy[Mani["0123456789"], Permissions -> "Public"]
CloudObject["https://www.wolframcloud.com/objects/ea1707d8-8c50-4926-bfad-207c5c1c1430"]

But it seems doesn't evaluate my function(Fence):

enter image description here

Kuba
  • 136,707
  • 13
  • 279
  • 740
Sayakiss
  • 859
  • 7
  • 13

1 Answers1

8

Documentation and Details ans Options section for CloudDeploy are saying:

CloudDeploy[expr,...] automatically deploys all definitions needed to evaluate expr, much like CloudSave.

and as we can see, it's not the case here. Or, it's a feature of Manipulate which boxes definitions are got by FrontEnd so maybe evaluation doesn't apply here.

At the end, you can force them to be remembered by using SaveDefinitions:

Mani[content_] :=  Manipulate[
  Column@{Fence[content, x], DownValues@Fence}, 
  {x, 1, Length[Characters[content]], 1}, 
  SaveDefinitions -> True
]

enter image description here

Kuba
  • 136,707
  • 13
  • 279
  • 740
  • Thanks! I find you changed my code a little(Looks cleaner than mine). Could you please post it in your answer? – Sayakiss Jan 24 '16 at 09:11
  • @Sayakiss I only added Column with Fence definitions for preview. – Kuba Jan 24 '16 at 09:16
  • I find my cloud app is very slow, how to optimize my code to get an more fluent app? – Sayakiss Jan 24 '16 at 09:16
  • @Sayakiss You can't, each time something is meant to be updated it has to call cloud and send results to you. – Kuba Jan 24 '16 at 09:16
  • 1
    It's really disappointing... I think I should deploy a simple HTML page with a single JavaScript to do that task.. – Sayakiss Jan 24 '16 at 09:19
  • @Sayakiss you are not the only one who feels this way. WRI cloud development team is working on allowing some things to be done client side but this was mentioned 1.5 year earlier and a base cloud is still beta so I'm not expecting this to be anywhere soon. – Kuba Jan 24 '16 at 09:22
  • Really thanks for providing that information kindly! – Sayakiss Jan 24 '16 at 09:26