hello charles, your examples in post #1 and post #2 don't run here (string stack). problems are word: "this.dn" (#1) and word "s.pop" (#2)
' Empty GUI script created on 12-01-2011 17:04:09 by (ThinAIR)
'CLASSES AND METHODS
'
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
'
'EXTEND STRINH BUFFER IF NEEDED
'
le=THIS.enb+ls+100
If le>lb Then
THIS.buf+=space ls+1000
End If
'
'STORE STRING
'
mid(THIS.buf,THIS.enb+1)=s
'
'STORE STRING LENGTH
'
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
'
'GET STRING LENGTH AND STRING INDEX
'
THIS.enb-=4
Dim As Long p, le At p
p=*THIS.buf + THIS.enb
THIS.enb-=le
'
'EXTRACT STRING
'
METHOD=mid THIS.buf,THIS.enb+1,le
End METHOD
End methods
'====
'TEST
'====
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
'msgbox 0, o2_view "o2h "+src
If Len(O2_ERROR) Then
MsgBox 0, O2_ERROR : Stop
End If
O2_EXEC
bye, largo
Bookmarks