SHARE
TWEET

Restrict Output

a guest Jul 13th, 2013 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. displayNum = 3;
  2. list = {"a", "abc", "abcd", "abcde"};
  3. Only = Function[{list, n}, Take[list, Min[Length[list], n]]];
  4. i = 0;
  5. CellPrint[
  6.  Cell[BoxData[TagBox[GridBox[{{
  7.        TagBox[
  8.         InputFieldBox[Dynamic[$CellContext`x], String,
  9.          ContinuousAction -> True],
  10.         EventHandlerTag[{"MouseUp" :> (
  11.             Null;
  12.             ), PassEventsDown -> Automatic, PassEventsUp -> True}]
  13.         ]
  14.        }, {
  15.        MakeBoxes@Dynamic@Column[
  16.           Map[Function[
  17.             EventHandler[
  18.              #, {"MouseClicked" :> (x = #)}
  19.              ]
  20.             ],
  21.            Select[list, StringMatchQ[#, x ~~ ___] &]~Only~displayNum ]
  22.           ]
  23.        }
  24.          },
  25.         GridBoxAlignment -> {"Columns" -> {{Left}}},
  26.         GridBoxItemSize -> {"Columns" -> {{Automatic}},
  27.        "Rows" -> {{Automatic}}}],
  28.       "Column"]], "Output"]
  29.  ]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top