Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / typing program

Author
Message
Inverted
18
Years of Service
User Offline
Joined: 19th Nov 2006
Location: Oregon
Posted: 13th Mar 2007 03:58
Hey everyone,
I'm doing a typing program for the school invention fair. It's supposed to help kids type for grades 2-5. I have a question though.

What i want to do is make it so when a letter when the person is typing is incorrect it makes that letter red. So if the word was "the" but they put "teh" the e and h would be red. How would i go about this.

This is my code:


And media is hooked up below.

Thanks in advanced,
-inverted


Come take a look!

Attachments

Login to view attachments
Hammaman
20
Years of Service
User Offline
Joined: 11th Feb 2004
Location:
Posted: 16th Mar 2007 14:32 Edited at: 16th Mar 2007 14:35
Hi,

Firstly, I've struggled to understand what your code is doing - and this has probably put off others trying to help. I've spent around 10 minutes as I'm eating my lunch looking at your code and trying to understand it. So it would be helpful to give a bit more information - for example:

The user is asked to type in the sentence stored in the variable secondgradecurrent$, and as they type, your store the typing in the variable string$. The variable string$ is displayed on screen by the subroutine PrintCharacters, and so you need help to improve that code to print out what has been typed and highlight errors.

Assuming I'm right, then you need to amend your code to work through each letter typed and compare against the corresponding letter in the sentence they are being asked to type. If it's correct, then set the ink colour to white; otherwise set it to red.

To do this, you'll need to use the Len(string$) function to determine how many characters have been typed, and then loop through each character in turn, determining what each character is using the Mid$(string$,cloop) function.

As I'm at work, I don't have access to DBPro, but I think I've got the correct Mid$() syntax in the code to achieve this below.




-- CODE (having problems wrapping this up in a Code Snippet, so apologies)

PrintCharacters:
set cursor 430,427

print ":"; `Note the ; to stop moving to a new line

`Check if anything to display - if not, return to main routine
if Len(string$) < 1 Then return

`Loop through each character in string$
for cloop = 1 to Len(string$)

`Get the character at position cloop in string$
s$ = Mid$(string$,cloop)

`Get the corresponding character in secondgradecurrent$
t$ = Mid$(secondgradecurrent$,cloop)

`Compare characters and set ink colour accordingly
if s$ = t$
ink rgb(255,255,255),rgb(255,255,255)
else
ink rgb(255,0,0), rgb(255,0,0)
endif

print s$;

next cloop

return

-- END OF CODE

Hope this helps.
Inverted
18
Years of Service
User Offline
Joined: 19th Nov 2006
Location: Oregon
Posted: 16th Mar 2007 16:12
Thanks very much sir,
-inverted


Come take a look!

Login to post a reply

Server time is: 2024-11-25 21:48:09
Your offset time is: 2024-11-25 21:48:09