Gift from the cyber gods: Under construction
While Hal will open any window based application, thats all he does...
If your organised, this is a major for Hal
It creates a table called cyDoc in "Brain", "miscData"
This will open any document by name and load out in what ever progi ur system defaults too.
OPEN DOCUMENT cyberjedi , is all that is needed to open the document named cyberjedi.doc
If you ask me, Do i will need microsoft office ,i will Bannish you from my brain.
Pretty nifty
enjoy
best wishes cyberjedi
Rem Type=Plugin
Rem Name=DOCument Opener
Rem Author=cyberjedi
Rem Host=Assistant
Rem PLUGIN: PLUGINAREA7
'The comment above tells Ultra Hal Assistant to insert the following code
'on-the-fly into the main brain code in the section referenced.
'------------------
' Check if the user asked for reorganizing the DOC table
'------------------
cyDoc = False
If InStr(UserSentence, " INDEX ") <> 0 And InStr(UserSentence, " DOC ") <> 0 Then cyDoc = True
If cyDoc = True Then
'------------------
' If the DOC table does not exist, I create it
'------------------
HalBrain.ReadOnlyMode = False
cyTableName = "cyDoc"
If HalBrain.CheckTableExistence(cyTableName) = False Then
' Create table if it doesn't exist
' It must be of type Brain, to allow partial text search
HalBrain.CreateTable cyTableName, "Brain", "miscData"
Else
' The 260 parameter is 256 + 4 = Yes/No with Default = No
cyAnswer = MsgBox("Shall I delete the existing index and recreate it from scratch?", 260, "Doc Reindexing")
If cyAnswer = 6 Then
HalBrain.RunQuery "DELETE FROM " & cyTableName, cyTempQuery
End If
End If
'------------------
' Ask which is the main DOC folder
'------------------
cyDocFolder = InputBox("Point to main folder you want to re-index?", "Document Re-Indexing", "C:\Documents and Settings\Owner\My Documents")
'------------------ point here to Documents^^^^^
' Read the main DOC folder
'------------------
Set cyFso = CreateObject("Scripting.FileSystemObject")
If cyFso.FolderExists(cyDocFolder) Then
GetResponse = "I have indexed all the Document files in the specified folder and subfolders. "
HalBrain.ReadOnlyMode = False
cyCurrentFolder = cyDocFolder
Call ReadFolder(cyCurrentFolder, cyDocFolder)
Else
GetResponse = "The folder " & cyDocFolder & " does not exist on your computer. "
End If
HalBrain.ReadOnlyMode = True
End If
'------------------
' Check if the user asked for opening a document
'------------------
cyDoc = False
cyToOpen = ""
cyNameToOpen = ""
cyToOpen = UCase(HalBrain.SearchPattern(UserSentence, "OPEN * DOCUMENT *", 2))
If cyToOpen <> "" Then
If HalBrain.CheckTableExistence("cyDoc") = False Then
GetResponse = "I don't find any DOC index in my brain. "
Else
cyNameToPlay = HalBrain.QABrain(cyToOpen, "cyDoc", 0)
If cyNameToPlay <> "" Then
GetResponse = " "
HalCommands = HalCommands & "<RUNPROG>" & cyNameToOpen & "</RUNPROG>"
End If
End If
HalBrain.ReadOnlyMode = True
End If
Rem PLUGIN: FUNCTIONS
' This is the meat of this plugin
Function ReadFolder(cyCurrentFolder, CyDocFolder)
Set cyFso = CreateObject("Scripting.FileSystemObject")
Set cyFolder = cyFso.GetFolder(cyCurrentFolder)
'------------------
' Read all the files in the current folder
'------------------
Set cyFiles = cyFolder.Files
For Each cyFile in cyFiles
'------------------
' It's a .doc file; I add it to the table
'------------------
If UCase(Right(cyFile, 3)) = "doc" Then
cyDoc = Ucase(cyFile)
cyDOc = Replace(cyDoc, ".doc", "")
cyLen = Len(cyDoc)
cyPos = InStrRev(cyDoc, "\")
cyRight = cyLen - cyPos
cyDoc = LTrim(Right(cyDoc, cyRight))
HalBrain.AddToTable "cyDoc", "Brain", cyDoc, cyFile
End If
Next
'------------------
' Read all the subfolders in the current folder
'------------------
Set cySubFolders = cyFolder.SubFolders
For Each cyFolderObject in cySubFolders
Call ReadFolder(cyFolderObject, cyDocFolder)
Next
End Function