History variables: Difference between revisions

Content added Content deleted
Line 1,277: Line 1,277:
\\ for strings
\\ for strings
Module CheckStringHistoryVariables {
Module CheckStringHistoryVariables {
Class History$ {
Class History$ {
Private:
Private:
myvalue=stack
myvalue=stack
Public:
Public:
Group Count {
Group Count {
Value {
Value {
link parent myvalue to m
link parent myvalue to m
=Len(m)
=Len(m)
}
}
Function CopyMe {
m=This
.myvalue<=stack(.myvalue)
=Group(m)
}
}
Group CopyValues {
}
Value {
Function CopyMe {
link parent myvalue to m
m=This
=Stack(m)
.myvalue<=stack(.myvalue)
}
=Group(m)
}
}
Function Values$ (x as long) {
Group CopyValues {
if x>=0 and x<=len(.myvalue) then =StackItem$(.myvalue, x)
Else Error "Fault index"
}
Module Back {
if len(.myvalue)<2 then exit
Stack .myvalue {Drop}
}
Operator "+=" (x$) {
Stack .myvalue {
Push stackitem$()+x$
} }
Value {
Value {
=StackItem$(.myvalue)
link parent myvalue to m
}
=Stack(m)
Set {
Read x$ : Stack .myvalue { Push x$}
}
Class:
Module History {
If Match("S") then Read x$ : Stack .myvalue { Push x$}
}
}
}
}
N$=History$("First")
Function Values$ (x as long) {
if x>=0 and x<=len(.myvalue) then =StackItem$(.myvalue, x)
N$="Second"
N$="Third"
Else Error "Fault index"
Print N.Count=3
}
M=N.CopyValues
Module Back {
K=Each(M, -1, 1)
if len(.myvalue)<2 then exit
While K {
Stack .myvalue {Drop}
Print StackItem$(K)
}
Operator "+=" (x$) {
Stack .myvalue {
Push stackitem$()+x$
} }
Value {
=StackItem$(.myvalue)
}
Set {
Read x$ : Stack .myvalue { Push x$}
}
Class:
Module History {
If Match("S") then Read x$ : Stack .myvalue { Push x$}
}
}
N$+=" and this"
}
N$=History$("First")
Print N.Count=4
Print N.CopyValues
N$="Second"
N.Back
N$="Third"
Print N.Count=3
Print N.Count=3
Print N.CopyValues
M=N.CopyValues
K=Each(M, -1, 1)
Print N.Values$(2)="Second"
While K {
Print StackItem$(K)
}
N$+=" and this"
Print N.Count=4
Print N.CopyValues
N.Back
Print N.Count=3
Print N.CopyValues
Print N.Values$(2)="Second"
}
}
CheckStringHistoryVariables
CheckStringHistoryVariables