RosettaCodeData/Task/Classes/OxygenBasic/classes.oxy

75 lines
877 B
Plaintext

class SuperString
indexbase 1
union
bstring s
sys bs
sys *y
int *i
byte *b
float *f
end union
method space(sys n)
s=space n
end method
method delete()
freememory bs : bs=0
end method
method clear()
sys j, le=length
if le then
for j=1 to le : b[j]=0 : next
end if
end method
method length() as sys
if bs then return i[0]
end method
method resize(sys n)
sys le=length
if n<le
s=left s,n
elseif n>le
s+=nuls n-le
end if
end method
method fill(string f)
sys j, ls=length, lf=len f
for j=1 to ls step lf
mid s,j,f
next
end method
method constructor()
end method
method destructor
delete
end method
end class
'#recordof SuperString
'=====
'TESTS
'=====
new SuperString ss
'
ss.space 100
ss.resize 8
ss.fill "abc"
'
print ss.s 'result abcabcab
print ss.b[3] 'result 99: ascii for 'c'
'
del ss