Plugged,
You should have been a bit more specific at the beginning of this post. You did not mention anything about searching a whole sentence previously.
REM << get the amount of characters contained in the sentence
length = len(sentence$)
REM << check every character from start to finnish in the sentence, looking for (%)percent signs
outputsentence$ = ""
repeat
inc count
REM << add the character to output string if not a percent sign
if pagemode = 0 and mid$(sentence$,count) <> "%"
outputsentence$ = outputsentence$ + mid$(sentence$,count)
else
REM << check for a % sign, if one is found then start 'page mode'
if pagemode = 0 and mid$(sentence$,count) = "%"
pagemode = 1
tempcount = 3
tempstring$ = ""
tempstring = mid$(sentence$,count)
else
if pagemode = 1
REM << 'page mode' assumes that the next 3 characters make up "d%[i]numbervalue".
REM << add these characters to a tempstring to be evaluated
dec tempcount
if tempcount = 0 then pagemode = 2
tempstring$ = tempstring$ + mid$(sentence$,count)
else
REM << evaluate the tempstring
if left$(tempstring$,3) = "%d" and asc(right$(tempstring$,1)) => 48 and asc(right$(tempstring$,1)) =< 57
REM << add array name to the output string
outputstring$ = outputstring$ + charname$(right$(sentence$,1))
REM << continue search
pagemode = 0
else
REM << end the evaluation if the tempstring wasn't what is expected it to be(meaning the input sentence has been mistyped)
count = length
endif
endif
endif
endif
until count = length[/i]
This code has not been tested, but I do not have time to do so now. With this code, the name array can only go up to a value of 9, from 0. However, that can easily be fixed. Let me know if the code does not work properly.
[EDIT]
IS there not a better way than placing these characters into a string and then evaluating the string? There must be a better way.
[EDIT]
Wouldn't it be easier to store the sentences in a text file, like the example below? (The first line enables you to recall a sentence word group{it is the number of the sentence in step value})
1
Hello
%d%
me and
%d%
are just going to look for
%d%
, yeah and
%d%
said he just saw
%d%
with
%d%
just over that hill
[endsentence]
In this case, you would need the program to know what names to fill in the gaps. This would be much more efficient than evaluating each character in an entire string.
+NanoBrain+