Ok, here's the first method that uses standard commands only:
s$ = "hostgame guitarfreak"
` 1. Find the space
Pos = 1
while mid$(s$, Pos) <> " "
inc Pos
if Pos > len( s$ ) then exit
endwhile
if Pos > len( s$ )
print "No space located"
else
` 2. Separate out the two strings
first$ = left$( s$, Pos-1 )
second$ = right$( s$, len( s$ )-Pos )
print "First string = "; first$
print "Second string = "; second$
endif
wait key
If you instead download my plug-ins and install them, then there are a few alternatives.
First, using 'standard' string commands:
s$ = "hostgame guitarfreak"
` 1. Find the space
Pos = instr( s$, " " )
if Pos = 0
print "No space located"
else
` 2. Separate out the two strings
first$ = left$( s$, Pos-1 )
second$ = remove$( s$, 1, Pos )
` ... or ...
` second$ = mid$( s$, Pos+1, 0 ) ` Uses my mid$, with its special functionality
print "First string = "; first$
print "Second string = "; second$
endif
wait key
Second, using commands designed for this purpose:
s$ = "hostgame guitarfreak"
` 1. Split out the words
split string s$, " "
if split count() < 2
print "No space located"
else
` 2. Retrieve the two strings
first$ = get split word$(1)
second$ = get split word$(2)
print "First string = "; first$
print "Second string = "; second$
endif
wait key