I went and had a look to refresh my memory (sorry I see now you already found PrevSent[:I]) but couldn't get a straightforward Hapfile to process. I tried the code below on an otherwise unedited XTF brain and with no other changes bar putting fullbody in as the character.
Anyway this is what I tried. This doesn't work on pushing the hapfiles through, but the Instr function picks out the trigger word fine...
If InStr (1,PrevSent,"happy",1) > 0 Then
HalCommands = "<HAPFILE>" & "Happy.hap" & "</HAPFILE>"
End If
If InStr (1,PrevSent,"sad",1) > 0 Then
HalCommands = "<HAPFILE>" & "Sad.hap" & "</HAPFILE>"
End If
If InStr (1,PrevSent,"tired",1) > 0 Then
HalCommands = "<HAPFILE>" & "Sleepy.hap" & "</HAPFILE>"
End If
In the Haptek SDK it tells you that commands are processed immediately unless scripted over a period of time. I'm pretty sure that the above code will conflict with other Haptek calls, which probably cause a bottleneck, so some get ignored or overided. So my guess is that why anything similar will run into the same problem.
I had something like what you describe working once before but had to strip out all of the emotion handling and also the uhp that Hal uses for a few emotions. If I can find that brain I'll post the changes I made, but it probably won't be till the weekend as I blew up my Harddrive and am having to restore my system!