Here is mix both sources with your + my functionality:
'Steve's idea: 10 different words, each of which is repeated three times and then one is picked and the child writes image name
'(text input, I suppose, because QB64 does not have microphone support)?
SCREEN _NEWIMAGE(800, 600, 32)
_TITLE "Spell It Aloud"
RANDOMIZE TIMER
ImageDir$ = ".\Images\"
SoundDir$ = ".\Alphabet Sounds\"
DIM SHARED AlphaSound(65 TO 90), f AS LONG, f1 AS LONG
REDIM SHARED PhotoList(100000) AS STRING
REDIM SHARED PhotoTags(100000) AS STRING
REDIM SHARED IMG10(9) AS LONG 'array fo 10 different images. Contains diferent indexes numbers for PhotoList()
'load our fonts
f = _LOADFONT("courbd.ttf", 84, "MONOSPACE")
f1 = _LOADFONT("courbd.ttf", 20, "MONOSPACE")
_FONT f
fw = _FONTWIDTH: fh = _FONTHEIGHT
'Load the alphabet sound library
FOR i = 65 TO 90
temp$ = SoundDir$ + CHR$(i) + ".ogg"
AlphaSound(i) = _SNDOPEN(temp$, "VOL,SYNC,LEN,PAUSE")
NEXT
'Get a listing of the files
PhotoList$ = ImageDir$ + "*.bmp " + ImageDir$ + "*.jpg " + ImageDir$ + "*.png " + ImageDir$ + "*.gif "
SHELL _HIDE "DIR " + PhotoList$ + "/b /s /a-d >PhotoList.txt"
'Load those names into a file.
OPEN "Photolist.txt" FOR BINARY AS #1
DO UNTIL EOF(1)
PhotoCount = PhotoCount + 1
LINE INPUT #1, PhotoList(PhotoCount)
LOOP
CLOSE #1
REDIM _PRESERVE PhotoList(PhotoCount)
_DELAY 1 'Give everything a moment to initialize and get started for us.
Insert_10_Different_Images 'insert 10 different indexes numbers from PhotoList, to array IMG10() [LONG] [0..9]
DO
' DO UNTIL photochosen <> oldpic
' RANDOMIZE TIMER
' photochosen = INT(RND * PhotoCount) + 1
' LOOP
' oldpic = photochosen
photochosen = IMG10(index)
index = index + 1
IF index > 9 THEN index = INT(1 + RND * 8): Query = 1
word$ = UCASE$(PhotoList(photochosen))
word$ = MID$(word$, _INSTRREV(word$, "\") + 1)
word$ = LEFT$(word$, INSTR(word$, ".") - 1)
IF tempimage < -1 THEN _FREEIMAGE tempimage
tempimage = _LOADIMAGE(PhotoList(photochosen), 32)
GetTags word$
'Put the image to the screen UPGRADE
FOR Loop_it = 1 TO 3 'as you say. 3x one word + image, this 10x with different images an then query.
CLS
'program photo area is 700 x 450 pixels. So:
GetNewWH 700, 450, tempimage, nW, nH
Ws = 400 - (nW / 2)
We = 400 + (nW / 2)
Hs = 300 - (nH / 2) - 25
He = 300 + (nH / 2) - 25
_PUTIMAGE (Ws, Hs)-(We, He), tempimage
ShowTags 'Display the tags up top
'Put the letters to the screen one by one
pw = _PRINTWIDTH(word$)
StartX = (_WIDTH - pw) \ 2
IF Query = 0 THEN 'as you need: 10x 3 words and then query to image name
FOR i = 1 TO LEN(word$)
a = ASC(word$, i) AND NOT 32
_PRINTSTRING (StartX + (i - 1) * fw, 510), MID$(word$, i, 1)
IF ASC(word$, i) = 32 THEN _DELAY .5: _CONTINUE
IF a < 65 OR a > 90 THEN _CONTINUE
_SNDPLAY AlphaSound(ASC(word$, i))
DO WHILE _SNDPLAYING(AlphaSound(ASC(word$, i))): LOOP ' UPGRADE
NEXT
ELSE
oldFont = _FONT
_FONT 16
'is time to query.....none _INPUTSTRING statement.... :) i am so lasy!!!!!
_PRINTSTRING (10, 510), "Insert image name: "
DO UNTIL inpt$ = CHR$(13)
inpt$ = INKEY$
IF INT(TIMER) MOD 2 = 0 THEN cursor$ = "_" ELSE cursor$ = ""
IF LEN(inpt$) THEN
word2$ = word2$ + UCASE$(inpt$)
IF inpt$ = CHR$(9) THEN word2$ = LEFT$(word2$, LEN(word2$) - 1) 'backspace
END IF
_PRINTSTRING (10 + (20 * 8), 510), word2$ + cursor$
LOOP
ok$ = "Correct!"
okl = _PRINTWIDTH(ok$)
word2$ = MID$(word2$, 1, LEN(word2$) - 1) 'erase CHR$(13) - ENTER from this word
IF UCASE$(_TRIM$(word2$)) = UCASE$(_TRIM$(word$)) THEN
_FONT oldFont
StartX = _WIDTH / 2 - okl / 2
_PRINTSTRING (StartX, 510), ok$
SLEEP 2
END IF
Query = 0
Insert_10_Different_Images
_FONT oldFont
index = 0
_CONTINUE
END IF ' if query condition
WordPlay word$
DO
WHILE _MOUSEINPUT: WEND
MX = _MOUSEX
MY = _MOUSEY
IF MX > Ws AND MX < We AND MY > Hs AND MY < He THEN
IF _FILEEXISTS(_CWD$ + "\animal sounds\" + word$ + ".mp3") THEN
_MOUSESHOW "link"
IF _MOUSEBUTTON(1) THEN AnimalSound word$
END IF
ELSE
_MOUSESHOW "default"
END IF
'keyboard access
k = _KEYHIT
_KEYCLEAR
_LIMIT 10
SELECT CASE k
CASE 65, 97 'a,A
AddTags word$
CASE 68, 100 'd,D
DeleteTags word$
CASE 32 'space
' _DELAY 1
SLEEP 1 ' Better for testing it
EXIT DO
CASE 27 'escape
SYSTEM 'quit
END SELECT
LOOP
NEXT Loop_it
LOOP
SUB AnimalSound (Word$)
ASound$ = _CWD$ + "\animal sounds\" + Word$ + ".mp3"
aAsound = _SNDOPEN(ASound$)
_SNDPLAY aAsound
DO WHILE _SNDPLAYING(aAsound)
IF LEN(INKEY$) THEN _SNDSTOP (aAsound): EXIT DO
LOOP
_SNDCLOSE aAsound
_MOUSESHOW "default"
END SUB
SUB GetNewWH (destWidth, destHeight, handle AS LONG, NewWidth, NewHeight) 'Sub return in variables NewWidth and NewHeight new image Width and image Height with the same ratio for optimal picture to set area width and height with [destWidth, destHeight]
W = _WIDTH(handle)
H = _HEIGHT(handle)
Pw = W / destWidth
Ph = H / destHeight
IF W > H THEN P = Pw ELSE P = Ph
NewWidth = W / P
NewHeight = H / P
END SUB
SUB Insert_10_Different_Images 'place 10 different indexes from array PhotoList
Max = UBOUND(photolist) 'PhotoList [1..?]
REDIM IMG10(9) AS LONG
pass = 0
DIM i_nr AS INTEGER
DO UNTIL pass = 10
st:
RANDOMIZE TIMER
i_nr = 1 + RND * Max
FOR t = 0 TO 9
IF IMG10(t) = i_nr THEN GOTO st
NEXT t
FOR t = 0 TO 9
IF IMG10(t) = 0 THEN IMG10(t) = i_nr: pass = pass + 1: EXIT FOR
NEXT t
LOOP
END SUB
SUB WordPlay (W AS STRING) 'will be replaced to my own mp3..... i never learn english, BUT I TRY IT.
'path$ = _CWD$ + "\Words\" + W$ + ".mp3"
'Word = _SNDOPEN(path$)
'_SNDPLAY Word
'DO WHILE _SNDPLAYING(Word): LOOP
FOR l = 1 TO LEN(W)
char = ASC(W, l)
IF char = 32 THEN _DELAY .5: _CONTINUE
_SNDPLAY AlphaSound(char)
_DELAY .35
NEXT l
END SUB
SUB BlankTop
LINE (0, 0)-(799, 49), &HFF000000, BF 'blank out the top info
END SUB
SUB AddTags (tfile$)
BlankTop
_FONT f1
LOCATE 1, 1: PRINT "Add Tag:";
INPUT tag$
IF tag$ <> "" THEN
u = UBOUND(phototags)
FOR i = 1 TO u
IF _STRICMP(tag$, PhotoTags(i)) = 0 THEN TagExists = -1: EXIT FOR
NEXT
IF NOT TagExists THEN
REDIM _PRESERVE PhotoTags(u + 1) AS STRING
PhotoTags(u + 1) = tag$
file$ = ".\Images\" + tfile$ + ".txt"
OPEN file$ FOR OUTPUT AS #1
FOR i = 1 TO u + 1
PRINT #1, "#";
PRINT #1, PhotoTags(i);
PRINT #1, " ";
NEXT
CLOSE
END IF
END IF
ShowTags
_FONT f
END SUB
SUB DeleteTags (tfile$)
BlankTop
_FONT f1
LOCATE 1, 1: PRINT "Delete Tag:";
INPUT tag$
IF tag$ <> "" THEN
u = UBOUND(phototags)
FOR i = 1 TO u
IF _STRICMP(tag$, PhotoTags(i)) = 0 THEN TagExists = -1: EXIT FOR
NEXT
IF TagExists THEN
FOR j = i TO u - 1
PhotoTags(j) = PhotoTags(j + 1)
NEXT
REDIM _PRESERVE PhotoTags(u - 1) AS STRING
file$ = ".\Images\" + tfile$ + ".txt"
OPEN file$ FOR OUTPUT AS #1
FOR i = 1 TO u - 1
PRINT #1, "#";
PRINT #1, PhotoTags(i);
PRINT #1, " ";
NEXT
CLOSE
END IF
END IF
ShowTags
_FONT f
END SUB
SUB GetTags (tfile$)
'Load the PhotoTags
file$ = ".\Images\" + tfile$ + ".txt"
OPEN file$ FOR BINARY AS #1
IF LOF(1) = 0 THEN 'if there's no tags, we can't get them.
CLOSE
REDIM _PRESERVE PhotoTags(0) AS STRING
EXIT SUB
END IF
DO UNTIL EOF(1)
LINE INPUT #1, junk$
l = 1
DO UNTIL l = 0
l = INSTR(junk$, "#")
IF l THEN
junk$ = MID$(junk$, l + 1)
l1 = INSTR(junk$, "#")
IF l1 = 0 THEN 'nothing more, we now have the tag
tag$ = junk$
l = 0
ELSE
tag$ = LEFT$(junk$, l1 - 1)
junk$ = MID$(junk$, l1)
END IF
END IF
tag$ = _TRIM$(tag$) 'no leading/tailing spaces for ease of matching
TagFound = 0
FOR i = 1 TO TagCount 'Check the existing tags to see if these exist
IF PhotoTags(i) = tag$ THEN TagFound = -1: EXIT FOR
NEXT
IF NOT TagFound THEN 'If not, add the new tags to the list
TagCount = TagCount + 1
IF TagCount > UBOUND(PhotoTags) THEN REDIM _PRESERVE PhotoTags(TagCount + 1000) AS STRING
PhotoTags(TagCount) = tag$
END IF
LOOP
LOOP
CLOSE
REDIM _PRESERVE PhotoTags(TagCount) AS STRING
END SUB
SUB ShowTags
BlankTop
_FONT f1
PRINT UBOUND(phototags); " TAGS: "
FOR i = 1 TO UBOUND(Phototags)
PRINT "#"; PhotoTags(i); " ";
NEXT
_FONT f
END SUB