Function to extract words from a string by ZioNz22nd Jan 2004 4:22
|
---|
Summary Simple function to extract words from a string. Description Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com REM Simple function to extract words from a string REM ------------------------------------------- test_string$="Hello World" print test_string$ print word$(test_string$,1) print word$(test_string$,2) suspend for key function word$(num1$,word_num) rem Search for spaces you can change " " for "_" or any other delimiter for i = 1 to len(num1$) if mid$(num1$,i)= " " then max=max+1 next i rem make a temporary array dim pala$(max+1) as string cant=1 rem find words and assing them to the array for i = 1 to len(num1$) if mid$(num1$,i)= " " cant=cant+1 else pala$(cant)=pala$(cant) + mid$(num1$,i) endif next i total$=pala$(word_num) endfunction total$ |