Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Native reactive spreadsheet demo in 14 LOC
;-- Each line is limited to 82 characters. Requires Red build from 07/07/2016 at least.
;-- Save it to a file to be able to run it, or type at console's prompt `do [`, paste the code, type `]` and ENTER.
Red [] L: charset "ABCDEFGHI" D: union N: charset "123456789" charset "0" repeat
y 9 [repeat x 9 [col: either x = 1 [#"^(2028)"][#"A" + (x - 2)] append p: [] set
ref:(to word! rejoin [col y - 1]) make face! [size: 90x24 type: pick [text field]
header?: (y = 1) or (x = 1) offset: -20x10 + as-pair ((x - 1) * size/x + 2) ((y
- 1) * size/y + 1) text: form case [y = 1 [col] x = 1 [y - 1] 'else [copy ""]]
para: make para! [align: pick [center right] header?] extra: object [name: form
ref formula: old: none] actors: context [on-create: on-unfocus: function [f e][
f/color: none if rel: f/extra/old [react/unlink rel 'all] if #"=" = first
f/extra/formula: copy text: copy f/text [parse remove text [any [p: L N not ["/"
skip not N] insert p " " insert "/data " | L skip | p: some D opt [some D] insert
p " " insert " " | skip]] f/text: rejoin [f/extra/name "/data: any [math/safe ["
text {] "#UND"]}] if f/data [any [react f/extra/old: f/data do f/data]]]]
on-focus: func [f e][f/text: any [f/extra/formula f/text] f/color: yello]]]]]
view [size 840x300 title "PicoSheet" do [self/pane: p]]

This comment has been minimized.

Copy link

@iArnold iArnold commented Jul 8, 2016

Why all this trouble for a one-liner? ;-)
Great little app.
I have put all variations from in 1 script without even removing the Red headers and ran the script without any problems from my GUI-console.exe program. Close one "spreadsheet" and the next example opens.
(Just added this comment for the interested followers on )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment