Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Red [
- Needs: View
- Author: "Toomas Vooglaid"
- Date: 2018-01-10
- Purpose: {To have overview of Red's type-conversions}
- ]
- ctx: context [
- types: compose [
- hex #00000001
- local-file "file.red"
- file %file.red
- paren (to-paren [paren])
- red-file %red-file.red
- logic (true)
- set-word (to-set-word 'set-word)
- block [block]
- bitset (charset "abc")
- binary #{01}
- char #"a"
- email e@mail
- float 1.0
- get-path (to-get-path [get path])
- get-word (to-get-word 'get-word)
- hash (to-hash [hash])
- integer 1
- issue #issue
- lit-path 'lit/path
- lit-word 'lit-word
- map #(map: 1)
- none (none)
- pair 1x1
- path (to-path [some path])
- percent 1%
- refinement (to-refinement 'refinement)
- set-path (to-set-path [set path])
- string "string"
- tag <tag>
- time 12:00
- typeset (to-typeset [typeset!])
- tuple 0.0.0.1
- url (to-url 'url)
- word (to-word 'word)
- date 2018-01-01
- ]
- ;OS-path
- ;unset
- ;image
- conversions: copy/part collect [
- foreach w words-of system/words [
- all [
- type: find/match to-string w "to-"
- not find ["OS-path" "image" "unset"] type
- keep w
- ]
- ]
- ] 35
- par: make para! [wrap?: yes align: 'center]
- fnt: make font! [size: 8]
- chead: rhead: cell: horz: vert: r: x: y: none
- lay: copy [
- origin 1x1 space 1x1
- style chead: text beige 49x24 font fnt para par
- ;style rhead: text beige 99x24 font fnt para par
- style cell: text 49x24 font [size: 7] para par wrap
- at 0x0 horz: box 1850x25 200.230.200.200 all-over on-over [
- offs: event/offset
- x: 100 + (offs/x - 100 / 50 * 50)
- vert/offset: as-pair x 0
- 'done
- ]
- at 0x0 vert: box 50x900 200.230.200.200 all-over on-over [
- offs: event/offset
- y: 25 + (offs/y - 25 / 25 * 25)
- horz/offset: as-pair 0 y
- 'done
- ]
- ;at 0x0 box glass 1851x901 focus
- at 0x0 base black 1851x901 all-over on-over [
- offs: event/offset
- if all [offs/x > 100 offs/y > 25][
- x: 100 + (offs/x - 100 / 50 * 50)
- y: 25 + (offs/y - 25 / 25 * 25)
- horz/offset: as-pair 0 y
- vert/offset: as-pair x 0
- ] 'done
- ]
- box 99x24 beige
- ]
- foreach conv conversions [
- append lay compose [chead (head replace find/last to-string conv #"-" #"-" "-^/")]
- ]
- n: 0 m: 0
- foreach [type val] types [
- n: n + 1
- m: 0
- append lay compose [return chead 99x24 (rejoin [to-string type #"^/" mold :val])]
- foreach convert conversions [
- m: m + 1
- err?: error? try [r: do reduce [convert :val]]
- append lay 'cell
- if m = n [append lay 220.220.220.255]
- unless err? [append lay mold :r];"X"];
- ]
- ]
- lay: layout lay
- move/part lay/pane tail lay/pane 2
- view/flags lay [resize]
- ]
Add Comment
Please, Sign In to add comment