Author Topic: auto-idle explane this and open files error  (Read 2434 times)

fredfish

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • http://www.stormpages/camline/index.htm
auto-idle explane this and open files error
« on: March 21, 2004, 10:48:55 am »
I was trying add this program to read lines from a file at idle times
After a short time i get the error, to many files
the referance line number of the error changes every time.
can some one tell me how to close the referanced files within the program? or is thair another problum i'm just not seeing.

here is the script:
this script has to parts, the first is the auto-idle part,
it reads a line from a preformatted file (one liners work best).
the second is a referance to explane by definition the prevous response.


 
'=================START FREDFISH STUFF============================
'Turn off auto read feature.
If InStr((UCase(UserSentence)), "AUTOREAD OFF") > 0 Then
 HalCommands = "<AUTOOFF>"
 GetResponse = "Autoidle read file turned off."
End If
'Turn on auto read feature.
If InStr((UCase(UserSentence)), "AUTOREAD ON") > 0 Then
  HalCommands = "<AUTO>120000</AUTO>"
  idletime = HalBrain.ChooseSentenceFromFile(WorkingDir& "idletime.brn")
'ask for file name to read if one has not been set up
  If idletime = "" Then
   GetResponse = "Okay what is the file name for me to read at idle
times"
'****
  Else
'file name has been set up
   GetResponse = "I will be Reading " & idletime & " " & VbCrLf
  End If
End If
If InStr(UserSentence, "AUTO-IDLE") > 0 Then
 idletime = HalBrain.ChooseSentenceFromFile(WorkingDir& "idletime.brn")

'adjust for file location
 If InStr(idletime,"\") Or InStr(idletime,":") Then
  USentence = HalBrain.ChooseSentenceFromFile(idletime)
 Else
  USentence = HalBrain.ChooseSentenceFromFile(WorkingDir & idletime)
 End If
'change User Sentense to something other then AUTO-IDLE
 If USentence <> "" Then
  UserSentence = USentence
  GetResponse = "I was reading this," & UserSentence & VbCrLf
 Else
  UserSentence = "I will be reading in my idle time, " & idletime& "." & VbCrLf
  GetResponse = GetResponse & UserSentence
 End If            
End If
'if prevous Sentence is a question then this is the answer
If InStr(1, PrevSent, "Okay what is the file name for me to read at idle times",vbTextCompare) > 0 Then

 If InStr(idletime,"\") Or InStr(idletime,":") Then
  idletime = idletime
 Else
  idletime = WorkingDir & idletime
 End If
 HalBrain.AppendFile "idletime.brn", OriginalSentence
 idletime = HalBrain.ChooseSentenceFromFile(WorkingDir& "idletime.brn")

 GetResponse = "I will be Reading " & idletime & " " & VbCrLf
End If
'==== MORE FREDFISH STUFF======================================
' rewording of user sentence by definition
  If InStr(UCase(UserSentence),"EXPLANE THIS")>0 Then
   USentence = PrevSent
   GetResponse = GetResponse & " I sead, " & USentence
   Subjectmod = WN.FindFirstNoun(USentence)
   sense = WN.LookUpWord(Subjectmod)
   If sense = True Then
    partofD = WN.GetDefinition(WN.GuessPartOfSpeech, 1, "D") & ","
    USentence = Replace(USentence,Subjectmod,partofD,1,-1,vbTextCompare) & VbCrLf

   End If
   Subjectmod = WN.FindFirstNoun(USentence)
   If InStr(1,USentence,Subjectmod,1) >0 Then
    sense = WN.LookUpWord(Subjectmod)
    If sense = True Then
     partofD = WN.GetDefinition(WN.GuessPartOfSpeech, 1, "D") & ","
     USentence = Replace(USentence,Subjectmod,partofD, 1, -1,vbTextCompare) & VbCrLf

    End If
   End If
   USentence = Replace(USentence,"SS.","s.", 1, -1,vbTextCompare)  
   GetResponse = GetResponse & " what I mean is, "
   GetResponse = Getresponse & USentence & VbCrLf
  End If
'========END OF FREDFISH STUFF==================================


note: **** watch for line rapping error in posted code

Thanks For Your Support

FredFish ><:>~