Uses
"oxygen"
,
"file"
Dim
p0,p1
As
Long
, src
As
String
Dim
dd(100)
As
Double
src = "
CLASS
string_stack
METHOD
Push(s
As
String
)
METHOD
Pop()
As
String
/
buf
As
String
enb
As
Long
le
As
Long
End
CLASS
methods of string_stack
METHOD
Push(s
As
String
)
Dim
As
Long
lb,ls,le
lb=
Len
THIS
.buf
ls=
Len
s
le=
THIS
.enb+ls+100
If
le>lb
Then
THIS
.buf+=space ls+1000
End
If
mid
(
THIS
.buf,
THIS
.enb+1)=s
THIS
.enb+=ls
Dim
As
Long
p, a
At
p
p=*
THIS
.buf +
THIS
.enb
a=ls
THIS
.enb+=4
End
METHOD
METHOD
Pop()
As
String
THIS
.enb-=4
Dim
As
Long
p, le
At
p
p=*
THIS
.buf +
THIS
.enb
THIS
.enb-=le
METHOD
=
mid
THIS
.buf,
THIS
.enb+1,le
End
METHOD
End
methods
Dim
s
As
string_stack
s.Push `abc` : s.Push `defg` : s.Push `HI`
Print
s.Pop + `-` s.Pop + `-` s.Pop
terminate
"
O2_BASIC
src
If
Len
(
O2_ERROR
)
Then
MsgBox
0,
O2_ERROR
:
Stop
End
If
O2_EXEC
Bookmarks