Advertisement
Guest User

Restrict Output

a guest
Jul 13th, 2013
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  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. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement