History variables: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 1,229: | Line 1,229: | ||
} |
} |
||
CheckHistoryVariables |
CheckHistoryVariables |
||
⚫ | |||
\\ for strings |
|||
Module CheckStringHistoryVariables { |
|||
Class History$ { |
|||
Private: |
|||
myvalue=stack |
|||
Public: |
|||
Group Count { |
|||
Value { |
|||
link parent myvalue to m |
|||
=Len(m) |
|||
} |
|||
} |
|||
Function CopyMe { |
|||
m=This |
|||
.myvalue<=stack(.myvalue) |
|||
=Group(m) |
|||
} |
|||
Group CopyValues { |
|||
Value { |
|||
link parent myvalue to m |
|||
=Stack(m) |
|||
} |
|||
} |
|||
Function Values$ (x as long) { |
|||
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 { |
|||
=StackItem$(.myvalue) |
|||
} |
|||
Set { |
|||
Read x$ : Stack .myvalue { Push x$} |
|||
} |
|||
Class: |
|||
Module History { |
|||
If Match("S") then Read x$ : Stack .myvalue { Push x$} |
|||
} |
|||
} |
|||
N$=History$("First") |
|||
N$="Second" |
|||
N$="Third" |
|||
Print N.Count=3 |
|||
M=N.CopyValues |
|||
K=Each(M, -1, 1) |
|||
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 |
|||
⚫ | |||
=={{header|Oberon-2}}== |
=={{header|Oberon-2}}== |