Guest User

Untitled

a guest
Jan 22nd, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. Red [
  2. Needs: View
  3. Author: "Toomas Vooglaid"
  4. Date: 2018-01-12
  5. Purpose: {To study conversions between datatypes}
  6. ]
  7. ctx: context [
  8. types: compose [
  9. hex #00000001
  10. local-file "file.red"
  11. file %file.red
  12. paren (to-paren [paren])
  13. red-file %red-file.red
  14. logic (true)
  15. set-word (to-set-word 'set-word)
  16. block [a block]
  17. bitset (charset "abc")
  18. binary #{01}
  19. char #"a"
  20. email e@mail
  21. float 1.0
  22. get-path (to-get-path [get path])
  23. get-word (to-get-word 'get-word)
  24. hash (to-hash [hash])
  25. integer 1
  26. issue #issue
  27. lit-path 'lit/path
  28. lit-word 'lit-word
  29. map #(map: 1)
  30. none (none)
  31. pair 1x1
  32. path (to-path [some path])
  33. percent 1%
  34. refinement (to-refinement 'refinement)
  35. set-path (to-set-path [set path])
  36. string "string"
  37. tag <tag>
  38. time 12:00
  39. typeset (to-typeset [typeset!])
  40. tuple 0.0.0.1
  41. url (to-url 'url)
  42. word (to-word 'word)
  43. date 2018-01-01
  44. ]
  45. ;OS-path
  46. ;unset
  47. ;image
  48.  
  49. conversions: copy/part collect [
  50. foreach w words-of system/words [
  51. all [
  52. type: find/match to-string w "to-"
  53. not find ["OS-path" "image" "unset"] type
  54. keep w
  55. ]
  56. ]
  57. ] 35
  58. rheads: conver: funcs: r: fn: none
  59.  
  60. lay: copy [
  61. title "Conversion laboratory"
  62. backdrop black
  63. size 803x901
  64. origin 1x1 space 1x1
  65. style converted: box "" beige 299x24
  66. style pan: panel black font [size: 10]
  67. rheads: pan 99x899 [origin 1x1 space 1x1]
  68. conver: pan 599x899 [origin 1x1 space 1x1]
  69. funcs: pan 140x899 with [extra: object [text: "mold" obj: object [color: beige]]]
  70. [origin 1x1 space 1x1]
  71. ]
  72. n: 0
  73. clear-reactions
  74. foreach [type val] types [
  75. n: n + 1
  76. append first skip find lay 'rheads 3 compose [
  77. text 99x24 beige center (to-string type) with [font: parent/font] return
  78. ]
  79. append first skip find lay 'conver 3 copy/deep compose [
  80. field 299x24 no-border center (mold :val) with [font: parent/font]
  81. converted with [font: parent/font]
  82. return
  83. ]
  84. append last lay compose [
  85. text 99x24 beige center (mold pick conversions n)
  86. with [font: parent/font]
  87. on-down [
  88. funcs/extra/obj/color: beige
  89. funcs/extra/obj: face
  90. funcs/extra/text: face/text
  91. face/color: wheat
  92. foreach [val var] conver/pane [
  93. err?: error? try [r: do reduce [load face/text val/data]]
  94. var/text: either err? [""][mold :r]
  95. ]
  96. ]
  97.  
  98. return
  99. ]
  100. ]
  101. lay: layout lay
  102. foreach [a b] conver/pane [
  103. react/link func [trg src2][
  104. err?: error? try [r: do reduce [load funcs/extra/text src2/data]]
  105. trg/text: either err? [""][mold :r]
  106. ] [b a]
  107. ]
  108. view/flags lay [resize]
  109. ]
Add Comment
Please, Sign In to add comment