Guest User

Untitled

a guest
Jan 19th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. Red [
  2. Needs: View
  3. Author: "Toomas Vooglaid"
  4. Date: 2018-01-10
  5. Purpose: {To have overview of Red's type-conversions}
  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 [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. par: make para! [wrap?: yes align: 'center]
  59. fnt: make font! [size: 8]
  60. chead: rhead: cell: horz: vert: r: x: y: none
  61. lay: copy [
  62. origin 1x1 space 1x1
  63. style chead: text beige 49x24 font fnt para par
  64. ;style rhead: text beige 99x24 font fnt para par
  65. style cell: text 49x24 font [size: 7] para par wrap
  66. at 0x0 horz: box 1850x25 200.230.200.200 all-over on-over [
  67. offs: event/offset
  68. x: 100 + (offs/x - 100 / 50 * 50)
  69. vert/offset: as-pair x 0
  70. 'done
  71. ]
  72. at 0x0 vert: box 50x900 200.230.200.200 all-over on-over [
  73. offs: event/offset
  74. y: 25 + (offs/y - 25 / 25 * 25)
  75. horz/offset: as-pair 0 y
  76. 'done
  77. ]
  78. ;at 0x0 box glass 1851x901 focus
  79. at 0x0 base black 1851x901 all-over on-over [
  80. offs: event/offset
  81. if all [offs/x > 100 offs/y > 25][
  82. x: 100 + (offs/x - 100 / 50 * 50)
  83. y: 25 + (offs/y - 25 / 25 * 25)
  84. horz/offset: as-pair 0 y
  85. vert/offset: as-pair x 0
  86. ] 'done
  87. ]
  88. box 99x24 beige
  89. ]
  90. foreach conv conversions [
  91. append lay compose [chead (head replace find/last to-string conv #"-" #"-" "-^/")]
  92. ]
  93. n: 0 m: 0
  94. foreach [type val] types [
  95. n: n + 1
  96. m: 0
  97. append lay compose [return chead 99x24 (rejoin [to-string type #"^/" mold :val])]
  98. foreach convert conversions [
  99. m: m + 1
  100. err?: error? try [r: do reduce [convert :val]]
  101. append lay 'cell
  102. if m = n [append lay 220.220.220.255]
  103. unless err? [append lay mold :r];"X"];
  104. ]
  105. ]
  106. lay: layout lay
  107. move/part lay/pane tail lay/pane 2
  108. view/flags lay [resize]
  109. ]
Add Comment
Please, Sign In to add comment