' Version 2020-12-22
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Begin BI-component.
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Hard arrays to store actual data:
'
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Temp variable(s):
'
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Nodes:
'
' Node structure
Identity
AS LONG ' Address in identity register Reference
AS LONG ' Pointer to hard array index
MaxNodes = 10000
' Node identity register
IdentityRegister(ktmpsa) = -1
' Node storage
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Soft arrays:
'
' Soft array structure
MaxSoftArrays = MaxNodes / 2
' Soft array register
SoftArrayRegister(ktmpsa) = -1
' Soft array storage
DIM SHARED SoftArray
(MaxSoftArrays
) AS SoftArrayStructure
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Processing
'
LambdaIndex = 0
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' End BI-component.
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'REM $Include: 'SoftArrays.bi'
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Meta:
'
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Visual Nodes (optional)
'
' Visual node structure
TYPE VisualNodesStructure
Reference
AS LONG ' Points to a node.
MaxVisualNodess = 512
VisualNodesCount = 0
' Visual node storage
DIM SHARED VisualNodes
(MaxVisualNodess
) AS VisualNodesStructure
' Visual node extras
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Pre-Main
'
'ScreenHandle = _NEWIMAGE(800, 600, 32)
ScrollPosition.x = 0
ScrollPosition.y = 0
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Main
'
'SLEEP
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Demo cases:
'
TheName = "myObj"
a = NewSoftArray(TheName)
b = LinkEast(a, NewTextNode("name"))
c = LinkEast(b, NewTextNode("John"))
b = LinkSouth(b, NewTextNode("age"))
c = LinkEast(b, NewIntegerNode(30))
b = LinkSouth(b, NewTextNode("cars"))
c = LinkEast(b, NewTextNode("[]"))
c = LinkSouth(c, NewTextNode("{}"))
d = LinkEast(c, NewTextNode("name"))
e = LinkEast(d, NewTextNode("Ford"))
d = LinkSouth(d, NewTextNode("models"))
e = LinkEast(d, NewTextNode("[]"))
e = LinkSouth(e, NewTextNode("Fiesta"))
e = LinkSouth(e, NewTextNode("Focus"))
e = LinkSouth(e, NewTextNode("Mustang"))
c = LinkSouth(c, NewTextNode("{}"))
d = LinkEast(c, NewTextNode("name"))
e = LinkEast(d, NewTextNode("BMW"))
d = LinkSouth(d, NewTextNode("models"))
e = LinkEast(d, NewTextNode("[]"))
e = LinkSouth(e, NewTextNode("320"))
e = LinkSouth(e, NewTextNode("X3"))
e = LinkSouth(e, NewTextNode("X5"))
c = LinkSouth(c, NewTextNode("{}"))
d = LinkEast(c, NewTextNode("name"))
e = LinkEast(d, NewTextNode("Fiat"))
d = LinkSouth(d, NewTextNode("models"))
e = LinkEast(d, NewTextNode("[]"))
e = LinkSouth(e, NewTextNode("500"))
e = LinkSouth(e, NewTextNode("Panda"))
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
TheName = "Tree of Friends"
a = NewSoftArray(TheName)
b = LinkEast(a, NewTextNode("QB64 Buddy"))
c = LinkEast(b, NewTextNode("Handle"))
d = LinkEast(c, NewTextNode("SMcNeill"))
c = LinkSouth(c, NewTextNode("Name"))
d = LinkEast(c, NewTextNode("Steve SMcNeill"))
c = LinkSouth(c, NewTextNode("Country"))
d = LinkEast(c, NewTextNode("USA"))
e = LinkEast(d, NewTextNode("Locality"))
f = LinkEast(e, NewTextNode("Virginia"))
c = LinkSouth(c, NewTextNode("Birthyear"))
d = LinkEast(c, NewIntegerNode(1973))
d = LinkSouth(d, NewTextNode("May?"))
b = LinkSouth(b, NewTextNode("QB64 Buddy"))
c = LinkEast(b, NewTextNode("Handle"))
d = LinkEast(c, NewTextNode("FellippeHeitor"))
c = LinkSouth(c, NewTextNode("Name"))
d = LinkEast(c, NewTextNode("Fellippe Heitor"))
c = LinkSouth(c, NewTextNode("Country"))
d = LinkEast(c, NewTextNode("Brazil"))
e = LinkEast(d, NewTextNode("Locality"))
f = LinkEast(e, NewTextNode("My <3"))
g = LinkEast(f, NewTextNode("JK, it's ___."))
c = LinkSouth(c, NewTextNode("Birthyear"))
d = LinkEast(c, NewIntegerNode(1983))
d = LinkSouth(d, NewTextNode("Sep?"))
d = LinkSouth(d, NewTextNode("... or was it May?"))
b = LinkSouth(b, NewTextNode("QB64 Buddy"))
c = LinkEast(b, NewTextNode("Handle"))
d = LinkEast(c, NewTextNode("Ashish"))
' Query tests
PRINT "Steve's locality: ";
PRINT Literal$
(StepFromUsing
(a
, "eesseee")) PRINT "Fellippe's locality: ";
PRINT Literal$
(StepFromUsing
(a
, "esesseee")) PRINT "Fellippe's birth month: ";
PRINT Literal$
(StepFromUsing
(JumpFrom
(StepFromUsing
(a
, "ese"), "s", 3), "es")) PRINT "Width of Fellippe's Country branch:";
PRINT Measure
(SeekText
("Country", a
, 2), "e") PRINT "Height under Fellippe's Birthyear branch:";
PRINT Measure
(Nodes
(SeekText
("Birthyear", a
, 2)).East
, "s")
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
TheName = "Three-Dimensional Array"
' Create a 3D array manually
TestArray3D(1, 1, 1) = "one.one.one"
TestArray3D(1, 1, 2) = "one.one.two"
TestArray3D(1, 1, 3) = "one.one.three"
TestArray3D(1, 2, 1) = "one.two.one"
TestArray3D(1, 2, 2) = "one.two.two"
TestArray3D(1, 2, 3) = "one.two.three"
TestArray3D(2, 1, 1) = "two.one.one"
TestArray3D(2, 1, 2) = "two.one.two"
TestArray3D(2, 1, 3) = "two.one.three"
TestArray3D(2, 2, 1) = "two.two.one"
TestArray3D(2, 2, 2) = "two.two.two"
TestArray3D(2, 2, 3) = "two.two.three"
TestArray3D(3, 1, 1) = "three.one.one"
TestArray3D(3, 1, 2) = "three.one.two"
TestArray3D(3, 1, 3) = "three.one.three"
TestArray3D(3, 2, 1) = "three.two.one"
TestArray3D(3, 2, 2) = "three.two.two"
TestArray3D(3, 2, 3) = "three.two.three"
' Load 3D array as Soft array
a = NewSoftArray(TheName)
a = LinkEast(a, NewTextNode(TestArray3D(i, j, k)))
b = a
a = LinkSouth(a, NewTextNode(TestArray3D(i, j, k)))
b = a
b = LinkEast(b, NewTextNode(TestArray3D(i, j, k)))
' Store the identity of the array name (even though we already have it, pretend we just received the label.)
a0 = SoftArrayID(TheName)
PRINT PrintSoftArray$
(a0
)
' Store the address of he head node and print its content. This initializes the loop below.
k = SoftArray(a0).HeadNode
PRINT "Typical FOR-like loop:" PRINT "(Listing one layer deep only.)" ' Set the address variable to the first entry in the "array".
k = Nodes(k).East
k = Nodes(k).South
' Exit the loop when there is no south link.
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
TheName1 = "top part"
TheName2 = "bottom part"
a = NewUnitArray("cow", NewIntegerNode(5))
a0 = a
a = NewSoftArray(TheName1)
a = LinkEast(a, NewTextNode("lambda"))
b = LinkEast(a, NewIntegerNode(4))
b = LinkSouth(b, NewIntegerNode(6))
a = NewSoftArray(TheName2)
a = LinkEast(a, NewTextNode("cos"))
b = LinkEast(a, NewTextNode("*"))
b = LinkEast(b, NewIntegerNode(3))
b = LinkSouth(b, NewTextNode("[1]"))
b = LinkSouth(b, CopyIntegerNode(Nodes(a0).East))
b = LinkSouth(b, NewTextNode("[2]"))
a = SoftArrayID(TheName2)
b = SoftArray(a).HeadNode
SoftArrayRegister(a) = -1
IdentityRegister(b) = -1
a = Nodes(SoftArray(SoftArrayID(TheName1)).HeadNode).East
b = Nodes(b).East
Nodes(b).West = -1
Nodes(b).North = a
Nodes(a).South = b
a = EvalMultiSoftArrays(1)
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
TheName = "Lambda Test"
a = NewUnitArray("cow", NewIntegerNode(7))
a0 = a
a = NewSoftArray(TheName)
a = LinkEast(a, NewTextNode("lambda"))
b = LinkEast(a, NewIntegerNode(4))
b = LinkSouth(b, NewIntegerNode(6))
a = LinkSouth(a, NewTextNode("cos"))
b = LinkEast(a, NewTextNode("*"))
b = LinkEast(b, NewIntegerNode(3))
b = LinkSouth(b, NewTextNode("[1]"))
b = LinkSouth(b, CopyIntegerNode(Nodes(a0).East))
b = LinkSouth(b, NewTextNode("[2]"))
a = EvalMultiSoftArrays(1)
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
TheName = "List Test"
a = NewSoftArray(TheName)
a = LinkEast(a, NewTextNode("cos"))
b = LinkEast(a, NewTextNode("three"))
b = LinkSouth(b, NewTextNode("four"))
b = LinkSouth(b, NewTextNode("five"))
b = LinkSouth(b, NewTextNode("six"))
b = LinkSouth(b, NewTextNode("seven"))
a = LinkSouth(a, NewTextNode("cos"))
b = LinkEast(a, NewIntegerNode(3))
b = LinkSouth(b, NewIntegerNode(4))
b = LinkSouth(b, NewIntegerNode(5))
b = LinkSouth(b, NewIntegerNode(6))
b = LinkSouth(b, NewIntegerNode(7))
a = EvalMultiSoftArrays(1)
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
a = NewSoftArray("Arithmetic Test1")
a0 = a
a = LinkEast(a, NewTextNode("*"))
b = LinkEast(a, NewIntegerNode(3))
b = LinkSouth(b, NewIntegerNode(4))
a = LinkSouth(b, NewTextNode("cos"))
b = LinkEast(a, NewTextNode("+"))
b = LinkEast(b, NewIntegerNode(4))
b = LinkSouth(b, NewIntegerNode(7))
b = LinkSouth(a, NewIntegerNode(2))
a = EvalMultiSoftArrays(1)
a = NewSoftArray("Arithmetic Test2")
a = LinkEast(a, NewTextNode("/"))
b = LinkEast(a, NewIntegerNode(3))
a = LinkSouth(b, NewTextNode("cos"))
b = LinkEast(a, NewTextNode("+"))
b = LinkEast(b, NewIntegerNode(4))
b = LinkSouth(b, NewDoubleNode(DoubleData(Nodes(Nodes(a0).East).Reference)))
a = EvalMultiSoftArrays(1)
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
TheName = "Tree Edit Test"
a = NewSoftArray(TheName)
a0 = a
a = LinkEast(a, NewTextNode("QB64 Buddy"))
a = LinkEast(a, NewTextNode("Handle"))
b = LinkEast(a, NewTextNode("flukiluke"))
a = LinkSouth(a, NewTextNode("Name"))
b = LinkEast(a, NewTextNode("Luke C."))
a = LinkSouth(a, NewTextNode("Country"))
b = LinkEast(a, NewTextNode("Australia"))
c = LinkEast(b, NewTextNode("Locality"))
b = LinkEast(c, NewTextNode("Down Under"))
a = LinkSouth(a, NewTextNode("Birthyear"))
b = LinkEast(a, NewIntegerNode(1523))
c = LinkSouth(b, NewTextNode("December"))
a = InsertEast(SeekText("Down Under", a0, 1), NewTextNode("Get it?"))
a = InsertSouth(SeekText("QB64 Buddy", a0, 1), NewTextNode("QB64 Enemy"))
a = EditIntegerReference(StepFromUsing(SeekText("Birthyear", a0, 1), "e"), 1855)
a = DeleteNodes(SeekText("Name", a0, 1))
'CLS
'' Query tests
'PRINT "Inserting `Get it?' into list..."
'PRINT "Adding new entry to bottom of list..."
'PRINT "Editing Birthyear..."
'PRINT "Deleting Name..."
'PRINT
'_DISPLAY
'SLEEP
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Begin GUI/Graphical component (optional)
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
PRINT PrintMultiSoftArrays$
(1)
k = ClearSelections(1)
CALL BuildAllVisualArrays
a = DeleteAllSoftArrays(1)
k = ClearSelections(1)
ScrollPosition.x = 0
ScrollPosition.y = 0
t = MemoryProbe$("")
i = MouseOver(x0, y0)
MB1 = 0
i = MouseOver(xx, yy)
j = i
i = MouseOver(xx, yy)
j = i
MB1 = -1
i = j
'ScrollPosition.x = ScrollPosition.x + (xx - VisualNodes(i).BoxCenter.x)
'ScrollPosition.y = ScrollPosition.y + (yy - VisualNodes(i).BoxCenter.y)
'CALL MoveVisualNodesRecur(i, VisualNodes(i).Reference, xx - VisualNodes(i).BoxCenter.x, yy - VisualNodes(i).BoxCenter.y)
'''
ScrollPosition.x = ScrollPosition.x + (xx - x0)
ScrollPosition.y = ScrollPosition.y + (yy - y0)
CALL MoveAllVisualNodes
(xx
- x0
, yy
- y0
) x0 = xx
y0 = yy
CALL MoveAllVisualNodes
(0, 30 * MW
) ScrollPosition.y = ScrollPosition.y + 30 * MW
'IF ((_MOUSEBUTTON(1) = 0) AND (MB1 = -1)) THEN
i = -1
j = i
MB1 = 0
CALL BuildAllVisualArrays
IF (xx
> VisualNodes
(i
).BoxCenter.x
- VisualNodes
(i
).BoxWidth
/ 2) AND (xx
< VisualNodes
(i
).BoxCenter.x
+ VisualNodes
(i
).BoxWidth
/ 2) THEN IF (yy
> VisualNodes
(i
).BoxCenter.y
- VisualNodes
(i
).BoxHeight
/ 2) AND (yy
< VisualNodes
(i
).BoxCenter.y
+ VisualNodes
(i
).BoxHeight
/ 2) THEN 'CALL NewSelection(i)
' Press-and-hold keys
CtrlKey = 1
CtrlKey = 0
AltWires = 1
AltWires = 0
' State-changing.
IF (SelectionIndex
(1) <> -1) THEN a = Evaluate(VisualNodes(SelectionIndex(1)).Reference)
CALL BuildAllVisualArrays
i = ClearSelections(1)
IF (SelectionIndex
(1) <> -1) THEN a = DeleteNodes(VisualNodes(SelectionIndex(1)).Reference)
CALL BuildAllVisualArrays
i = ClearSelections(1)
IF (SelectionIndex
(1) <> -1) THEN a = SeverSoftArray(VisualNodes(SelectionIndex(1)).Reference)
CALL BuildAllVisualArrays
IF (SelectionIndex
(1) <> -1) THEN a = CopyNodes(VisualNodes(SelectionIndex(1)).Reference)
CALL BuildAllVisualArrays
IF (SelectionIndex
(1) <> -1) THEN a = ConvertToInteger(VisualNodes(SelectionIndex(1)).Reference, 0)
CALL DefineVisualNode
(SelectionIndex
(1), VisualNodes
(SelectionIndex
(1)).Reference
, VisualNodes
(SelectionIndex
(1)).BoxCenter.x
, VisualNodes
(SelectionIndex
(1)).BoxCenter.y
) CALL BuildAllVisualArrays
IF (SelectionIndex
(1) <> -1) THEN a = ConvertToDouble(VisualNodes(SelectionIndex(1)).Reference, 0)
CALL DefineVisualNode
(SelectionIndex
(1), VisualNodes
(SelectionIndex
(1)).Reference
, VisualNodes
(SelectionIndex
(1)).BoxCenter.x
, VisualNodes
(SelectionIndex
(1)).BoxCenter.y
) CALL BuildAllVisualArrays
IF (SelectionIndex
(1) <> -1) THEN a = ConvertToText(VisualNodes(SelectionIndex(1)).Reference, "text")
CALL DefineVisualNode
(SelectionIndex
(1), VisualNodes
(SelectionIndex
(1)).Reference
, VisualNodes
(SelectionIndex
(1)).BoxCenter.x
, VisualNodes
(SelectionIndex
(1)).BoxCenter.y
) CALL BuildAllVisualArrays
IF (SoftArrayRegister
(k
) <> -1) THEN IF (SoftArray
(k
).Label
= Literal$
(VisualNodes
(SelectionIndex
(1)).Reference
)) THEN a = SoftArray(k).HeadNode
b = Nodes(a).East
Nodes(b).West = -1
SoftArrayRegister(k) = -1
IdentityRegister(a) = -1
a = VisualNodes(SelectionIndex(2)).Reference
c = Nodes(a).East
c = DeleteNodes(c)
Nodes(a).East = b
Nodes(b).West = a
IF (SelectionIndex
(1) <> -1) THEN SELECT CASE Nodes
(VisualNodes
(SelectionIndex
(1)).Reference
).Species
a = InsertEast(VisualNodes(SelectionIndex(1)).Reference, NewIntegerNode(0))
a = InsertEast(VisualNodes(SelectionIndex(1)).Reference, NewTextNode("e"))
a = InsertEast(VisualNodes(SelectionIndex(1)).Reference, NewDoubleNode(0))
CALL BuildAllVisualArrays
IF (SoftArrayRegister
(k
) <> -1) THEN IF (SoftArray
(k
).Label
= Literal$
(VisualNodes
(SelectionIndex
(1)).Reference
)) THEN a = SoftArray(k).HeadNode
b = Nodes(a).East
Nodes(b).West = -1
SoftArrayRegister(k) = -1
IdentityRegister(a) = -1
a = VisualNodes(SelectionIndex(2)).Reference
c = Nodes(a).South
c = DeleteNodesRecur(c)
Nodes(a).South = b
Nodes(b).North = a
IF (SelectionIndex
(1) <> -1) THEN SELECT CASE Nodes
(VisualNodes
(SelectionIndex
(1)).Reference
).Species
a = InsertSouth(VisualNodes(SelectionIndex(1)).Reference, NewIntegerNode(0))
a = InsertSouth(VisualNodes(SelectionIndex(1)).Reference, NewTextNode("s"))
a = InsertSouth(VisualNodes(SelectionIndex(1)).Reference, NewDoubleNode(0))
CALL BuildAllVisualArrays
IF (SelectionIndex
(1) <> -1) THEN PRINT "Enter new value:" '+ CHR$(10) + SPACE$(20); SELECT CASE Nodes
(VisualNodes
(SelectionIndex
(1)).Reference
).Species
Nodes
(VisualNodes
(SelectionIndex
(1)).Reference
).Reference
= NewIntegerData
(INT(VAL(t
))) a = VisualNodes(SelectionIndex(1)).Reference
Nodes(a).Reference = NewTextData(t)
IF (SoftArrayRegister
(k
) <> -1) THEN IF (SoftArray
(k
).HeadNode
= a
) THEN SoftArray(k).Label = t
Nodes
(VisualNodes
(SelectionIndex
(1)).Reference
).Reference
= NewDoubleData
(VAL(t
)) CALL DefineVisualNode
(SelectionIndex
(1), VisualNodes
(SelectionIndex
(1)).Reference
, VisualNodes
(SelectionIndex
(1)).BoxCenter.x
, VisualNodes
(SelectionIndex
(1)).BoxCenter.y
) CALL BuildAllVisualArrays
' Display-changing.
ScrollPosition.y
= ScrollPosition.y
- .9 * _HEIGHT / 2 ScrollPosition.y
= ScrollPosition.y
+ .9 * _HEIGHT / 2 PRINT #1, PrintMultiSoftArrays$
(1)
ScreenHandleTemp = ScreenHandle
CALL DrawAllVisualNodes
(AltWires
)
IF (VisualNodes
(i
).Reference
<> -1) THEN CALL DrawSingleNode
(i
, _RGBA(255, 25, 50, 255), _RGBA(255, 255, 0, 255))
CALL lprintstring
(1, 3, "Selection history:") IF (SelectionIndex
(k
) <> -1) THEN IF (VisualNodes
(SelectionIndex
(k
)).Reference
<> -1) THEN CALL lprintstring
(1, 3 + k
, LTRIM$(RTRIM$(STR$(k
))) + ") " + Literal$
(VisualNodes
(SelectionIndex
(k
)).Reference
) + " (@ " + LTRIM$(RTRIM$(STR$(VisualNodes
(SelectionIndex
(k
)).Reference
))) + ")")
i
= UBOUND(SelectionIndex
) + 4 i
= i
+ 1:
CALL lprintstring
(1, i
, "Mouse:") i
= i
+ 1:
CALL lprintstring
(1, i
, " Point = highlight") i
= i
+ 1:
CALL lprintstring
(1, i
, " MB1 = select") i
= i
+ 1:
CALL lprintstring
(1, i
, " MB2 = drag") i
= i
+ 1:
CALL lprintstring
(1, i
, "Soft arrays:") i
= i
+ 1:
CALL lprintstring
(1, i
, " I = new integer") i
= i
+ 1:
CALL lprintstring
(1, i
, " T = new text") i
= i
+ 1:
CALL lprintstring
(1, i
, " D = new double") i
= i
+ 1:
CALL lprintstring
(1, i
, " C = copy recur") i
= i
+ 1:
CALL lprintstring
(1, i
, " Delete = delete") i
= i
+ 1:
CALL lprintstring
(1, i
, " V = sever") i
= i
+ 1:
CALL lprintstring
(1, i
, " Ctrl+S = mov (1)s(2)") i
= i
+ 1:
CALL lprintstring
(1, i
, " Ctrl+E = mov (1)e(2)") i
= i
+ 1:
CALL lprintstring
(1, i
, " Enter = evaluate") i
= i
+ 1:
CALL lprintstring
(1, i
, "Nodes:") i
= i
+ 1:
CALL lprintstring
(1, i
, " E = append east") i
= i
+ 1:
CALL lprintstring
(1, i
, " S = append south") i
= i
+ 1:
CALL lprintstring
(1, i
, " X = edit content") i
= i
+ 1:
CALL lprintstring
(1, i
, " Ctrl+I = to integer") i
= i
+ 1:
CALL lprintstring
(1, i
, " Ctrl+T = to text") i
= i
+ 1:
CALL lprintstring
(1, i
, " Ctrl+D = to double") i
= i
+ 1:
CALL lprintstring
(1, i
, "Report:") i
= i
+ 1:
CALL lprintstring
(1, i
, " L = print all") i
= i
+ 1:
CALL lprintstring
(1, i
, " J = print JSON") i
= i
+ 1:
CALL lprintstring
(1, i
, " Ctrl+L = write file") i
= i
+ 1:
CALL lprintstring
(1, i
, " Ctrl+J = write JSON") i
= i
+ 1:
CALL lprintstring
(1, i
, " M = mem probe") i
= i
+ 1:
CALL lprintstring
(1, i
, " W = all wires")
CALL rprintstring
(3, "Scroll position:")
CALL cprintstring
(_HEIGHT / 2, "--Soft Array Editor--") CALL cprintstring
(-_HEIGHT / 2 + 16, "Press ESC to continue.")
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Visual Nodes
'
h = 22
w
= 12 + 8 * LEN(Literal$
(x
)) VisualNodes(i).Reference = x
VisualNodes(i).BoxCenter.x = cx
VisualNodes(i).BoxCenter.y = cy
VisualNodes(i).BoxHeight = h
VisualNodes(i).BoxWidth = w
VisualNodes(i).CornerNE.x = cx + .5 * w
VisualNodes(i).CornerNE.y = cy + .5 * h
VisualNodes(i).CornerNW.x = cx - .5 * w
VisualNodes(i).CornerNW.y = cy + .5 * h
VisualNodes(i).CornerSE.x = cx + .5 * w
VisualNodes(i).CornerSE.y = cy - .5 * h
VisualNodes(i).CornerSW.x = cx - .5 * w
VisualNodes(i).CornerSW.y = cy - .5 * h
VisualNodes(i).AntennaN.x = cx
VisualNodes(i).AntennaN.y = cy + .5 * h + 3
VisualNodes(i).AntennaS.x = cx
VisualNodes(i).AntennaS.y = cy - .5 * h - 3
VisualNodes(i).AntennaE.x = cx + .5 * w + 3
VisualNodes(i).AntennaE.y = cy
VisualNodes(i).AntennaW.x = cx - .5 * w - 3
VisualNodes(i).AntennaW.y = cy
TheReturn = -1
FOR j
= 1 TO VisualNodesCount
IF (VisualNodes
(j
).Reference
= x
) THEN TheReturn = j
VisualNodeIndexFromReference = TheReturn
VisualNodesCount = 0
y0 = Origin.y + ScrollPosition.y
IF (SoftArrayRegister
(k
) <> -1) THEN CALL BuildVisualArray
(SoftArray
(k
).HeadNode
, Origin.x
+ ScrollPosition.x
, y0
) y0 = y0 - 30
s = Nodes(x).South
e = Nodes(x).East
VisualNodesCount = VisualNodesCount + 1
CALL DefineVisualNode
(VisualNodesCount
, x
, x0
, y0
) y0 = y0 - 30
dxtmp
= 8 * .5 * (LEN(Literal$
(x
)) + LEN(Literal$
(e
))) IF (dxtmp
< 30) THEN dxtmp
= 30 CALL BuildVisualArray
(e
, x0
+ dxtmp
, y0
) CALL BuildVisualArray
(s
, x0
, y0
)
FOR k
= 1 TO VisualNodesCount
CALL MoveSingleVisualNode
(k
, dx
, dy
)
s = Nodes(x).South
e = Nodes(x).East
f = 0
FOR k
= 1 TO VisualNodesCount
IF (VisualNodes
(k
).Reference
= e
) THEN f = 1
CALL MoveVisualNodesRecur
(k
, e
, dx
, dy
) f = 0
FOR k
= 1 TO VisualNodesCount
IF (VisualNodes
(k
).Reference
= s
) THEN f = 1
CALL MoveVisualNodesRecur
(k
, s
, dx
, dy
) CALL MoveSingleVisualNode
(i
, dx
, dy
)
CALL DefineVisualNode
(i
, VisualNodes
(i
).Reference
, VisualNodes
(i
).BoxCenter.x
+ dx
, VisualNodes
(i
).BoxCenter.y
+ dy
)
FOR k
= 1 TO VisualNodesCount
SELECT CASE Nodes
(VisualNodes
(k
).Reference
).Species
CALL DrawSingleNode
(k
, _RGBA(255, 255, 255, 255), _RGBA(155, 55, 55, 255)) CALL DrawSingleNode
(k
, _RGBA(255, 255, 255, 255), _RGBA(55, 155, 55, 255)) CALL DrawSingleNode
(k
, _RGBA(255, 255, 255, 255), _RGBA(55, 55, 155, 255)) CALL DrawSingleNode
(k
, _RGBA(255, 255, 255, 255), _RGBA(55, 55, 55, 255))
CALL clinebf
(VisualNodes
(x
).CornerNE.x
, VisualNodes
(x
).CornerNE.y
, VisualNodes
(x
).CornerSW.x
, VisualNodes
(x
).CornerSW.y
, c2
) CALL bprintstring
(VisualNodes
(x
).CornerNW.x
+ 6, VisualNodes
(x
).CornerNW.y
- 4, Literal$
(VisualNodes
(x
).Reference
)) CALL clineb
(VisualNodes
(x
).CornerNE.x
+ 0, VisualNodes
(x
).CornerNE.y
+ 0, VisualNodes
(x
).CornerSW.x
- 0, VisualNodes
(x
).CornerSW.y
- 0, _RGB32(155, 155, 155, 255))
i = VisualNodes(x).Reference
s = Nodes(i).South
e = Nodes(i).East
k = VisualNodeIndexFromReference(s)
CALL cline
(VisualNodes
(x
).AntennaS.x
, VisualNodes
(x
).AntennaS.y
, VisualNodes
(k
).BoxCenter.x
, VisualNodes
(k
).BoxCenter.y
, _RGBA(155, 155, 155, 255)) CALL ccircle
(VisualNodes
(x
).AntennaS.x
, VisualNodes
(x
).AntennaS.y
, 3, _RGBA(155, 155, 155, 255)) k = VisualNodeIndexFromReference(e)
CALL cline
(VisualNodes
(x
).AntennaE.x
, VisualNodes
(x
).AntennaE.y
, VisualNodes
(k
).BoxCenter.x
, VisualNodes
(k
).BoxCenter.y
, _RGBA(155, 155, 155, 255)) CALL ccircle
(VisualNodes
(x
).AntennaE.x
, VisualNodes
(x
).AntennaE.y
, 3, _RGBA(155, 155, 155, 255))
i = VisualNodes(x).Reference
n = Nodes(i).North
w = Nodes(i).West
k = VisualNodeIndexFromReference(n)
CALL cline
(VisualNodes
(x
).AntennaN.x
, VisualNodes
(x
).AntennaN.y
, VisualNodes
(k
).BoxCenter.x
, VisualNodes
(k
).BoxCenter.y
, _RGBA(255, 55, 55, 255)) CALL ccircle
(VisualNodes
(x
).AntennaN.x
, VisualNodes
(x
).AntennaN.y
, 3, _RGBA(255, 55, 55, 255)) k = VisualNodeIndexFromReference(w)
CALL cline
(VisualNodes
(x
).AntennaW.x
, VisualNodes
(x
).AntennaW.y
, VisualNodes
(k
).BoxCenter.x
, VisualNodes
(k
).BoxCenter.y
, _RGBA(255, 55, 55, 255)) CALL ccircle
(VisualNodes
(x
).AntennaW.x
, VisualNodes
(x
).AntennaW.y
, 3, _RGBA(255, 55, 55, 255))
TheReturn = -1
FOR k
= 1 TO VisualNodesCount
IF (x0
> VisualNodes
(k
).BoxCenter.x
- VisualNodes
(k
).BoxWidth
/ 2) AND (x0
< VisualNodes
(k
).BoxCenter.x
+ VisualNodes
(k
).BoxWidth
/ 2) THEN IF (y0
> VisualNodes
(k
).BoxCenter.y
- VisualNodes
(k
).BoxHeight
/ 2) AND (y0
< VisualNodes
(k
).BoxCenter.y
+ VisualNodes
(k
).BoxHeight
/ 2) THEN TheReturn = k
MouseOver = TheReturn
IF (SelectionIndex
(1) <> x
) THEN SelectionIndex(k) = SelectionIndex(k - 1)
SelectionIndex(1) = x
SelectionIndex(k) = -1
TheReturn = -1
ClearSelections = TheReturn
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Cartesian graphics
'
'LOCATE y1, x1: PRINT a
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' End GUI/Graphical component (optional)
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'REM $Include: 'SoftArrays.bm'
'REM $Include: 'SoftArrays.bi'
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Begin BM-component.
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Processing
'
IF (SoftArrayRegister
(k
) <> -1) THEN TheReturn = Evaluate(SoftArray(k).HeadNode)
EvalMultiSoftArrays = TheReturn
a = x
b = -1
a = EvalStep(FirstEmbedded(a))
a = Nodes(a).South
b = a
TheReturn = a
Evaluate = TheReturn
RefSpecies = ""
FunctionId = x
ReturnSpecies = ""
ReturnInteger = 0
ReturnText = ""
ReturnDouble = 0
' Pre-evaluation
SouthernId = x
i = x
n = Nodes(i).North
i = n
NorthernId = i
FunctionId = Nodes(NorthernId).West
ReturnSpecies = Nodes(FunctionId).Species
ReturnInteger = IntegerData(Nodes(FunctionId).Reference)
ReturnText = TextData(Nodes(FunctionId).Reference)
ReturnDouble = DoubleData(Nodes(FunctionId).Reference)
' Lambda substitution
i = NorthernId
lf = 0
IF (Nodes
(i
).Species
= "text") THEN IF (TextData
(Nodes
(i
).Reference
) = "[1]") THEN j = LambdaMatrix(LambdaIndex, 1)
Nodes(i).Species = Nodes(j).Species
Nodes(i).Reference = Nodes(j).Reference
lf = 1
IF (TextData
(Nodes
(i
).Reference
) = "[2]") THEN j = LambdaMatrix(LambdaIndex, 2)
Nodes(i).Species = Nodes(j).Species
Nodes(i).Reference = Nodes(j).Reference
lf = 1
s = Nodes(i).South
i = s
FOR k
= 1 TO LambdaArgCount
(LambdaIndex
) j = Unlink(LambdaMatrix(LambdaIndex, k))
LambdaArgCount(LambdaIndex) = 0
LambdaIndex = LambdaIndex - 1
' Determine return species
i = NorthernId
IF (Nodes
(i
).Species
= "text") THEN RefSpecies
= "text" IF ((Nodes
(i
).Species
= "double") AND (RefSpecies
<> "text")) THEN RefSpecies
= "double" IF ((Nodes
(i
).Species
= "integer") AND (RefSpecies
<> "text") AND (RefSpecies
<> "double")) THEN RefSpecies
= "integer" i = Nodes(i).South
' Single-pass evaluation
MultiPass = 0
MultiPass = 1
ReturnSpecies = RefSpecies
ReturnInteger = 1
ReturnDouble = 1
MultiPass = 1
ReturnSpecies = RefSpecies
ReturnInteger = 0
ReturnDouble = 0
MultiPass = 0
ReturnSpecies = "double"
ReturnDouble = IntegerData(Nodes(NorthernId).Reference) / IntegerData(Nodes(SouthernId).Reference)
ReturnDouble = IntegerData(Nodes(NorthernId).Reference) / DoubleData(Nodes(SouthernId).Reference)
ReturnSpecies = "text"
ReturnText = Literal$(NorthernId) + "/" + Literal$(SouthernId)
ReturnSpecies = "double"
ReturnDouble = DoubleData(Nodes(NorthernId).Reference) / IntegerData(Nodes(SouthernId).Reference)
ReturnDouble = DoubleData(Nodes(NorthernId).Reference) / DoubleData(Nodes(SouthernId).Reference)
i = Unlink(NorthernId)
i = Unlink(SouthernId)
IF (NorthernId
= SouthernId
) THEN MultiPass = 0
i = NorthernId
ReturnSpecies = "double"
ReturnDouble
= COS(IntegerData
(Nodes
(i
).Reference
)) ReturnSpecies = "text"
ReturnText = "cos" + "(" + Literal$(i) + ")"
ReturnSpecies = "double"
ReturnDouble
= COS(DoubleData
(Nodes
(i
).Reference
)) i = Unlink(i)
MultiPass = 1
ReturnSpecies = "text"
ReturnText = "(" + "cos" + ")"
MultiPass = 1
LambdaIndex = LambdaIndex + 1
ReturnSpecies = "text"
ReturnText = "(" + "lambda" + ")"
CASE "(" + "lambda" + ")" '
' Multi-pass evaluation
i = NorthernId
ReturnInteger = ReturnInteger * IntegerData(Nodes(i).Reference)
ReturnInteger = ReturnInteger * DoubleData(Nodes(i).Reference)
ReturnText = ReturnText + Literal$(i)
ReturnDouble = ReturnDouble * IntegerData(Nodes(i).Reference)
ReturnDouble = ReturnDouble * DoubleData(Nodes(i).Reference)
i = Unlink(i)
s = Nodes(i).South
i = Unlink(i)
i = s
ReturnInteger = ReturnInteger + IntegerData(Nodes(i).Reference)
ReturnInteger = ReturnInteger + DoubleData(Nodes(i).Reference)
ReturnText = ReturnText + Literal$(i)
ReturnDouble = ReturnDouble + IntegerData(Nodes(i).Reference)
ReturnDouble = ReturnDouble + DoubleData(Nodes(i).Reference)
i = Unlink(i)
s = Nodes(i).South
i = Unlink(i)
i = s
Nodes(i).Species = "double"
Nodes
(i
).Reference
= NewDoubleData
(COS(IntegerData
(Nodes
(i
).Reference
))) Nodes(i).Reference = NewTextData("cos" + "(" + Literal$(i) + ")")
Nodes(i).Species = "double"
Nodes
(i
).Reference
= NewDoubleData
(COS(DoubleData
(Nodes
(i
).Reference
))) s = Nodes(i).South
i = s
LambdaArgCount(LambdaIndex) = LambdaArgCount(LambdaIndex) + 1
LambdaMatrix(LambdaIndex, LambdaArgCount(LambdaIndex)) = i
s = Nodes(i).South
i = s
Nodes(FunctionId).Species = ReturnSpecies
Nodes(FunctionId).Reference = NewIntegerData(ReturnInteger)
Nodes(FunctionId).Species = ReturnSpecies
Nodes(FunctionId).Reference = NewTextData(ReturnText)
Nodes(FunctionId).Species = ReturnSpecies
Nodes(FunctionId).Reference = NewDoubleData(ReturnDouble)
TheReturn = FunctionId
EvalStep = TheReturn
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Eval helper functions
'
TheReturn = MostEmbeddedRecur(x, -1)
FirstEmbedded = TheReturn
s = Nodes(x).South
e = Nodes(x).East
TheReturn = MostEmbeddedRecur(e, y)
TheReturn = MostEmbeddedRecur(s, y)
y = x
TheReturn = y
MostEmbeddedRecur = TheReturn
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Programmer-friendly functions
'
'
' Inputs a soft array label and returns the node address.
'
TheReturn = -1
IF (SoftArray
(k
).Label
= t
) THEN TheReturn = k
SoftArrayID = TheReturn
TheReturn = -1
s = Nodes(x).South
e = Nodes(x).East
IF (TextData
(Nodes
(x
).Reference
) = t
) THEN TheReturn = x
r = r - 1
TheReturn = SeekText(t, e, r)
TheReturn = SeekText(t, s, r)
SeekText = TheReturn
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Navigation
'
TheReturn = x
TheReturn = JumpFrom(Nodes(x).North, "n", r - 1)
TheReturn = JumpFrom(Nodes(x).South, "s", r - 1)
TheReturn = JumpFrom(Nodes(x).East, "e", r - 1)
TheReturn = JumpFrom(Nodes(x).West, "w", r - 1)
JumpFrom = TheReturn
i = x
j = Nodes(i).North
j = Nodes(i).South
j = Nodes(i).East
j = Nodes(i).West
TheReturn = i
StepFromUsing = TheReturn
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Internal metrics
'
'
' A simpler version of CountSteps that looks for -1.
'
TheReturn = CountSteps(x, -1, t)
Measure = TheReturn
TheReturn = 0
k = Nodes(x).North
k = Nodes(x).South
k = Nodes(x).East
k = Nodes(x).West
TheReturn = TheReturn + 1
TheReturn = TheReturn + 1 + CountSteps(k, y, t)
CountSteps = TheReturn
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Printing and Reporting
'
't = Literal$(x) + " = {" + CHR$(10) + WriteJSONRecur$(1, Nodes(x).East) + "}"
t
= "{" + CHR$(10) + WriteJSONRecur$
(0, Nodes
(x
).East
) + "}" TheReturn = t
PrintJSON$ = TheReturn
ThisLiteral = LiteralJSON$(x)
n = Nodes(x).North
s = Nodes(x).South
e = Nodes(x).East
w = Nodes(x).West
lb = ""
rb = ""
lq = ""
rq = ""
lb = "["
rb
= Filler$
(i
, " ") + "]" + CHR$(10) ThisLiteral = lb
lq = "{"
rq = Filler$(i, " ") + "}"
ThisLiteral = lq
IF (s
<> -1) THEN rq
= rq
+ ","
ThisLiteral = Filler$(i, " ") + ThisLiteral
IF (Nodes
(e
).East
= -1) THEN ThisLiteral
= ThisLiteral
+ ":" IF (n
<> -1) AND (s
<> -1) AND (e
= -1) AND (w
= -1) THEN ThisLiteral
= ThisLiteral
+ "," IF (n
= -1) AND (s
= -1) AND (e
= -1) AND (w
<> -1) THEN ThisLiteral
= ThisLiteral
+ ","
TheReturn
= TheReturn
+ ThisLiteral
+ CHR$(10)
TheReturn = TheReturn + WriteJSONRecur$(i + 1, e) + rq
TheReturn = TheReturn + WriteJSONRecur$(i, s) + rb
WriteJSONRecur$ = TheReturn
TheReturn = t
TheReturn
= TheReturn
+ "Begin memory probe..." + CHR$(10) TheReturn
= TheReturn
+ "Soft arrays:" + CHR$(10) IF (SoftArrayRegister
(k
) <> -1) THEN TheReturn
= TheReturn
+ " " + SoftArray
(k
).Label
+ " (@@" + STR$(SoftArrayRegister
(k
)) + ") (@" + STR$(SoftArray
(k
).HeadNode
) + ")" + CHR$(10) TheReturn
= TheReturn
+ "Nodes:" + CHR$(10) IF (IdentityRegister
(k
) <> -1) THEN a = IdentityRegister(k)
TheReturn = TheReturn + " " + Literal$(a)
TheReturn
= TheReturn
+ " (@" + STR$(IdentityRegister
(k
)) + ")" TheReturn
= TheReturn
+ CHR$(10) TheReturn
= TheReturn
+ "End memory probe..." + CHR$(10) MemoryProbe$ = TheReturn
TheReturn = ""
IF (SoftArrayRegister
(k
) <> -1) THEN TheReturn = TheReturn + PrintSoftArray$(SoftArray(k).HeadNode)
TheReturn
= TheReturn
+ CHR$(10) PrintMultiSoftArrays$ = TheReturn
t = ListNodesRecur$(0, x)
PrintSoftArray$ = TheReturn
s = Nodes(x).South
e = Nodes(x).East
TheReturn = TheReturn + Filler$(i, " ") + Literal$(x) 'CHR$(9)
'TheReturn = TheReturn + " (" + STR$(Nodes(x).North) + "," + STR$(Nodes(x).South) + "," + STR$(Nodes(x).East) + "," + STR$(Nodes(x).West) + ")"
TheReturn
= TheReturn
+ CHR$(10) TheReturn = TheReturn + ListNodesRecur$(i + 1, e)
TheReturn = TheReturn + ListNodesRecur$(i, s)
ListNodesRecur$ = TheReturn
n = Nodes(x).North
s = Nodes(x).South
e = Nodes(x).East
w = Nodes(x).West
IdentityStackSize = IdentityStackSize + 1
IdentityStack(IdentityStackSize, 1) = x
IdentityStack(IdentityStackSize, 2) = n
IdentityStack(IdentityStackSize, 3) = s
IdentityStack(IdentityStackSize, 4) = e
IdentityStack(IdentityStackSize, 5) = w
TheReturn = IdentityStackBuildRecur(e, 1)
TheReturn = IdentityStackBuildRecur(s, 1)
TheReturn = -1
IdentityStackBuildRecur = TheReturn
TheReturn = ""
TheReturn = TextData(Nodes(x).Reference)
Literal$ = TheReturn
TheReturn = ""
TheReturn
= CHR$(34) + TextData
(Nodes
(x
).Reference
) + CHR$(34) LiteralJSON$ = TheReturn
TheReturn = TheReturn + t
TheReturn = ""
Filler$ = TheReturn
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Soft array construction
'
r = NewSoftArray(t)
TheReturn = r
k = LinkEast(TheReturn, x)
NewUnitArray = TheReturn
TheReturn = NewTextNode(t)
i = NextOpenSoftArray(1)
SoftArrayRegister(i) = i
SoftArray(i).Label = TextData(Nodes(TheReturn).Reference)
SoftArray(i).HeadNode = TheReturn
NewSoftArray = TheReturn
TheReturn = -1
IF (SoftArrayRegister
(k
) = -1) THEN TheReturn = k
NextOpenSoftArray = TheReturn
Nodes(s).North = n
Nodes(n).South = s
TheReturn = s
LinkSouth = TheReturn
Nodes(w).East = e
Nodes(e).West = w
TheReturn = e
LinkEast = TheReturn
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Soft array editing
'
s = Nodes(n).South
Nodes(n).South = x
Nodes(x).North = n
Nodes(x).South = s
Nodes(s).North = x
InsertSouth = x
e = Nodes(w).East
Nodes(w).East = x
Nodes(x).West = w
Nodes(x).East = e
Nodes(e).West = x
InsertEast = x
n = Nodes(x).North
s = Nodes(x).South
e = Nodes(x).East
w = Nodes(x).West
IF (SoftArray
(k
).HeadNode
= x
) THEN SoftArrayRegister(k) = -1
IF (n
<> -1) THEN Nodes
(n
).South
= s
IF (s
<> -1) THEN Nodes
(s
).North
= n
IF (e
<> -1) THEN Nodes
(e
).West
= w
IF (w
<> -1) THEN Nodes
(w
).East
= e
IF ((n
= -1) AND (w
<> -1)) THEN ' content node Nodes(s).West = w
Nodes(s).North = -1
Nodes(w).East = s
IdentityRegister(x) = -1
Unlink = x
e = Nodes(x).East
TheReturn = DeleteNodesRecur(e)
TheReturn = Unlink(x)
DeleteNodes = TheReturn
s = Nodes(x).South
e = Nodes(x).East
TheReturn = DeleteNodesRecur(e)
TheReturn = DeleteNodesRecur(s)
TheReturn = Unlink(x)
DeleteNodesRecur = TheReturn
a = IdentityStackBuildRecur(x, 0)
FOR k
= 1 TO IdentityStackSize
i = k + IdentityStackSize
a = NewNode(NextOpenIdentity(IdentityStack(k, 1)), Nodes(IdentityStack(k, 1)).Species, Nodes(IdentityStack(k, 1)).Reference)
IdentityStack(i, 1) = a
FOR k
= 1 TO IdentityStackSize
i = k + IdentityStackSize
a = IdentityStack(k, j)
FOR n
= 1 TO IdentityStackSize
m = n + IdentityStackSize
b = IdentityStack(n, 1)
Nodes(IdentityStack(i, 1)).North = IdentityStack(m, 1)
Nodes(IdentityStack(i, 1)).South = IdentityStack(m, 1)
Nodes(IdentityStack(i, 1)).East = IdentityStack(m, 1)
Nodes(IdentityStack(i, 1)).West = IdentityStack(m, 1)
a = IdentityStack(1 + IdentityStackSize, 1)
IF (SoftArray
(k
).HeadNode
) = x
THEN a = Nodes(a).East
IdentityStackSize = 0
b = LinkEast(TheReturn, a)
CopyNodes = TheReturn
SoftArrayRegister(x) = -1
TheReturn = DeleteNodesRecur(SoftArray(x).HeadNode)
DeleteSoftArray = TheReturn
IF (SoftArrayRegister
(k
) <> -1) THEN TheReturn = DeleteSoftArray(k)
DeleteAllSoftArrays = TheReturn
' Need to filter out case when node being severed is a head node. It makes no sense.
IF (Nodes
(x
).North
<> -1) THEN Nodes(Nodes(x).North).South = -1
Nodes(x).North = -1
Nodes(Nodes(x).West).East = -1
TheReturn = LinkEast(TheReturn, x)
SeverSoftArray = TheReturn
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Node creation
'
TheReturn = -1
IF (IdentityRegister
(k
) = -1) THEN TheReturn = k
NextOpenIdentity = TheReturn
i = NextOpenIdentity(x)
IdentityRegister(i) = i
Nodes(i).Identity = i
Nodes(i).Species = t
Nodes(i).Reference = r
Nodes(i).North = -1
Nodes(i).South = -1
Nodes(i).East = -1
Nodes(i).West = -1
NewNode = i
CopyIntegerNode = NewIntegerNode(IntegerData(Nodes(x).Reference))
Nodes(i).Species = "integer"
Nodes(i).Reference = NewIntegerData(x)
TheReturn = i
ConvertToInteger = TheReturn
Nodes(i).Species = "text"
Nodes(i).Reference = NewTextData(x)
TheReturn = i
ConvertToText = TheReturn
Nodes(i).Species = "double"
Nodes(i).Reference = NewDoubleData(x)
TheReturn = i
ConvertToDouble = TheReturn
NewIntegerNode = NewNode(1, "integer", NewIntegerData(x))
NewTextNode = NewNode(1, "text", NewTextData(x))
NewDoubleNode = NewNode(1, "double", NewDoubleData(x))
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Node editing
'
z = NewIntegerData(i)
Nodes(x).Reference = z
EditIntegerReference = z
z = NewTextData(t)
Nodes(x).Reference = z
EditTextReference = z
z = NewDoubleData(d)
Nodes(x).Reference = z
EditDoubleReference = z
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Data assimilation (prevents redundancy but can be disabled for more speed)
'
TheReturn = -1
TheReturn = k
IntegerData
(UBOUND(IntegerData
)) = x
TheReturn
= UBOUND(IntegerData
) NewIntegerData = TheReturn
TheReturn = -1
TheReturn = k
TextData
(UBOUND(Textdata
)) = x
NewTextData = TheReturn
TheReturn = -1
TheReturn = k
DoubleData
(UBOUND(DoubleData
)) = x
TheReturn
= UBOUND(DoubleData
) NewDoubleData = TheReturn
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' End BM-component.
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''