Oxygen Basic
Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
Latest OxygenBasic.zip at GitHub
(Click on the Wizard)
Home
Help
Search
Login
Register
Oxygen Basic
»
Programming
»
Example Code
»
Data Processing
»
Word parser for Basic
« previous
next »
Print
Pages: [
1
]
Author
Topic: Word parser for Basic (Read 2827 times)
0 Members and 1 Guest are viewing this topic.
Charles Pegge
Guest
Word parser for Basic
«
on:
February 04, 2013, 01:48:39 AM »
Handles symbols and quotes as well as alphanumeric words
Code: OxygenBasic
function
getword(s
as
string
, b
as
sys
)
as
string
'================================================
'b=1
sys
a,c,d,bb,bc
a=0
bb=b
do
c=
asc
s,b
if
c=0
then
exit
do
if
c>32
then
exit
do
b+=1
end
do
bc=b
if
c=34
or
c=96
then
'quotes
do
b+=1
d=
asc
s,b
if
d=0
or
d=c
then
b+=1 :
jmp
fwd done
end
do
end
if
do
c=
asc
s,b
select
c
case
0
to
32 :
exit
do
case
33
to
47
if
c=35
then
jmp
fwd more
'#
if
b=bc
then
b+=1
exit
do
case
48
to
57 :
jmp
fwd more
'numbers
case
58
to
64
if
b=bc
then
b+=1
exit
do
case
65
to
90 :
jmp
fwd more
'capitals
case
91
to
96
if
c=95
then
jmp
fwd more
'underscore
if
b=bc
then
b+=1
exit
do
case
97
to
122 :
jmp
fwd more
'lower case
case
123
to
127
if
b=bc
then
b+=1
exit
do
end
select
'
'higher ascii chars treated as part of word
'
more:
'
b+=1
end
do
'
done:
'
if
b>bb
then
return
mid
s,bb,b-bb
end
function
'TEST
sys
i=1
string
wd,pr
do
wd=getword("abc(d[xx]+7/6,`qwerty`)",i)
if
not
wd
then
exit
do
pr+=wd+
chr
(13,10)
end
do
print
pr
Logged
Print
Pages: [
1
]
« previous
next »
Oxygen Basic
»
Programming
»
Example Code
»
Data Processing
»
Word parser for Basic