📄 classopenmind.cls
字号:
Call OpenDatabase
fileNumber = FreeFile
Open filename For Input As fileNumber
While (Not EOF(fileNumber))
c = Input(1, #fileNumber)
If (Asc(c) = 10) Or (Asc(c) = 13) Then
'read the phrase
pos = InStr(phrase, "things often found together are")
If (pos > 0) Then
phrase = Right$(phrase, Len(phrase) - pos - 30)
readObject = False
ObjectStr = ""
NoOfObjects = 0
For i = 1 To Len(phrase)
c = Mid$(phrase, i, 1)
If (c = "(") Then
readObject = True
Else
If (c = ")") Then
readObject = False
ObjectStr = Trim(ObjectStr)
If (ObjectStr <> "") Then
obj(NoOfObjects) = ObjectStr
NoOfObjects = NoOfObjects + 1
End If
ObjectStr = ""
Else
ObjectStr = ObjectStr & c
End If
End If
Next
For i = 0 To NoOfObjects - 1
For j = 0 To NoOfObjects - 1
If (i <> j) Then
Call ConnectObjects(obj(i), obj(j), "collection", "")
End If
Next
Next
End If
phrase = ""
Else
If (c <> "'") And (c <> Chr(34)) Then
phrase = phrase & c
End If
End If
Wend
Close #fileNumber
End Sub
Public Sub ReadFirstNames(filename As String, isMale As Boolean)
'reads first names
Dim fileNumber As Integer
Dim personname As String
Call OpenDatabase
fileNumber = FreeFile
Open filename For Input As #fileNumber
While (Not EOF(fileNumber))
Input #fileNumber, personname
If (personname <> "") Then
If (isMale) Then
Call ConnectObjects(personname, "male name", "isa", "")
Else
Call ConnectObjects(personname, "female name", "isa", "")
End If
End If
Wend
Close #fileNumber
Call ConnectObjects("male name", "person", "belongs", "")
Call ConnectObjects("female name", "person", "belongs", "")
End Sub
Public Sub ReadPerson(filename As String, InitialWords As String, ConnectionType As String)
'reads person info
Dim fileNumber As Integer
Dim c As String
Dim phrase As String
Dim ObjectName As String
Dim dummy As String
Call OpenDatabase
fileNumber = FreeFile
Open filename For Input As fileNumber
While (Not EOF(fileNumber))
c = Input(1, #fileNumber)
If (Asc(c) = 10) Or (Asc(c) = 13) Then
'read the phrase
If (phrase <> "") Then
Call SplitPhrase(phrase, InitialWords, dummy, ObjectName)
If (ObjectName <> "") Then
Call RemovePrefix(ObjectName)
Call ConnectObjects("person", ObjectName, ConnectionType, "")
End If
End If
phrase = ""
Else
If (c <> "(") And (c <> ")") And (c <> "'") And (c <> Chr(34)) Then
phrase = phrase & c
End If
End If
Wend
Close #fileNumber
End Sub
Public Sub ReadStatements(filename As String, InitialWords As String, dividingWords As String, ConnectionType As String)
'reads two related statements
Dim fileNumber As Integer
Dim c As String
Dim phrase As String
Dim phraseText As String
Dim firstStatement As String
Dim secondStatement As String
Dim dummy As String
Call OpenDatabase
fileNumber = FreeFile
Open filename For Input As fileNumber
While (Not EOF(fileNumber))
c = Input(1, #fileNumber)
If (Asc(c) = 10) Or (Asc(c) = 13) Then
'read the phrase
If (phrase <> "") Then
Call SplitPhrase(phrase, InitialWords, dummy, phraseText)
If (phraseText <> "") Then
Call SplitPhrase(phraseText, dividingWords, firstStatement, secondStatement)
Call ConnectStatements(firstStatement, secondStatement, ConnectionType, "")
End If
End If
phrase = ""
Else
If (c <> "(") And (c <> ")") And (c <> "'") And (c <> Chr(34)) Then
phrase = phrase & c
End If
End If
Wend
Close #fileNumber
End Sub
Public Sub ReadComparissonBetweenObjects(filename As String, InitialWords As String, dividingWords As String, ConnectionType As String)
'reads from a comparisson file of the type
'<initial words> <firstobject> <dividing words> <second object>
Dim fileNumber As Integer
Dim c As String
Dim phrase As String
Dim dummy As String
Dim phraseText As String
Dim Reason As String
Dim firstObject As String
Dim secondObject As String
Call OpenDatabase
fileNumber = FreeFile
Open filename For Input As fileNumber
While (Not EOF(fileNumber))
c = Input(1, #fileNumber)
If (Asc(c) = 10) Or (Asc(c) = 13) Then
'read the phrase
If (phrase <> "") Then
Call SplitPhrase(phrase, InitialWords, dummy, phraseText)
If (phraseText <> "") Then
Call SplitPhrase(phraseText, dividingWords, firstObject, secondObject)
Call RemovePrefix(firstObject)
Call RemovePrefix(secondObject)
Call ConnectObjects(firstObject, secondObject, ConnectionType, "")
End If
End If
phrase = ""
Else
If (c <> "(") And (c <> ")") And (c <> "'") And (c <> Chr(34)) Then
phrase = phrase & c
End If
End If
Wend
Close #fileNumber
End Sub
Public Sub ReadComparissonBetweenStatements(filename As String, InitialWords As String, dividingWords As String, ConnectionType As String)
'reads from a comparisson file of the type
'<initial words> <first statement> <dividing words> <second statement>
Dim fileNumber As Integer
Dim c As String
Dim phrase As String
Dim dummy As String
Dim phraseText As String
Dim Reason As String
Dim firstObject As String
Dim secondObject As String
Call OpenDatabase
fileNumber = FreeFile
Open filename For Input As fileNumber
While (Not EOF(fileNumber))
c = Input(1, #fileNumber)
If (Asc(c) = 10) Or (Asc(c) = 13) Then
'read the phrase
If (phrase <> "") Then
Call SplitPhrase(phrase, InitialWords, dummy, phraseText)
If (phraseText <> "") Then
Call SplitPhrase(phraseText, dividingWords, firstObject, secondObject)
Call RemovePrefix(firstObject)
Call RemovePrefix(secondObject)
Call ConnectStatements(firstObject, secondObject, ConnectionType, "")
End If
End If
phrase = ""
Else
If (c <> "(") And (c <> ")") And (c <> "'") And (c <> Chr(34)) Then
phrase = phrase & c
End If
End If
Wend
Close #fileNumber
End Sub
Public Sub ReadComparissonBetweenObjectAndAction(filename As String, InitialWords As String, dividingWords As String, ConnectionType As String)
'reads from a comparisson file of the type
'<initial words> <object> <dividing words> <action>
Dim fileNumber As Integer
Dim c As String
Dim phrase As String
Dim dummy As String
Dim phraseText As String
Dim Reason As String
Dim ObjectName As String
Dim action As String
Call OpenDatabase
fileNumber = FreeFile
Open filename For Input As fileNumber
While (Not EOF(fileNumber))
c = Input(1, #fileNumber)
If (Asc(c) = 10) Or (Asc(c) = 13) Then
'read the phrase
If (phrase <> "") Then
Call SplitPhrase(phrase, InitialWords, dummy, phraseText)
If (phraseText <> "") Then
Call SplitPhrase(phraseText, dividingWords, ObjectName, action)
Call RemovePrefix(ObjectName)
Call ConnectObjectToAction(ObjectName, action, ConnectionType, "")
End If
End If
phrase = ""
Else
If (c <> "(") And (c <> ")") And (c <> "'") And (c <> Chr(34)) Then
phrase = phrase & c
End If
End If
Wend
Close #fileNumber
End Sub
Public Sub ReadComparissonBetweenActions(filename As String, InitialWords As String, dividingWords As String, ConnectionType As String)
'reads from a comparisson file of the type
'<initial words> <object> <dividing words> <action>
Dim fileNumber As Integer
Dim c As String
Dim phrase As String
Dim dummy As String
Dim phraseText As String
Dim Reason As String
Dim firstAction As String
Dim secondAction As String
Call OpenDatabase
fileNumber = FreeFile
Open filename For Input As fileNumber
While (Not EOF(fileNumber))
c = Input(1, #fileNumber)
If (Asc(c) = 10) Or (Asc(c) = 13) Then
'read the phrase
If (phrase <> "") Then
Call SplitPhrase(phrase, InitialWords, dummy, phraseText)
If (phraseText <> "") Then
Call SplitPhrase(phraseText, dividingWords, firstAction, secondAction)
Call RemovePrefix(firstAction)
Call RemovePrefix(secondAction)
Call ConnectActions(firstAction, secondAction, ConnectionType, "")
End If
End If
phrase = ""
Else
If (c <> "(") And (c <> ")") And (c <> "'") And (c <> Chr(34)) Then
phrase = phrase & c
End If
End If
Wend
Close #fileNumber
End Sub
Public Sub ReadComparrisonWithReason(filename As String, InitialWords As String, dividingWords As String, ConnectionType As String)
'reads from the differences file
Dim fileNumber As Integer
Dim c As String
Dim phrase As String
Dim dummy As String
Dim phraseText As String
Dim compared As String
Dim Reason As String
Dim firstObject As String
Dim secondObject As String
Call OpenDatabase
fileNumber = FreeFile
Open filename For Input As fileNumber
While (Not EOF(fileNumber))
c = Input(1, #fileNumber)
If (Asc(c) = 10) Or (Asc(c) = 13) Then
'read the phrase
If (phrase <> "") Then
Call SplitPhrase(phrase, InitialWords, dummy, phraseText)
If (phraseText <> "") Then
Call SplitPhrase(phraseText, dividingWords, compared, Reason)
If (compared <> "") Then
Call SplitPhrase(compared, " and ", firstObject, secondObject)
Call RemovePrefix(firstObject)
Call RemovePrefix(secondObject)
Call ConnectObjects(firstObject, secondObject, ConnectionType, Reason)
End If
End If
End If
phrase = ""
Else
If (c <> "(") And (c <> ")") And (c <> "'") And (c <> Chr(34)) Then
phrase = phrase & c
End If
End If
Wend
Close #fileNumber
End Sub
Private Sub Class_Initialize()
DatabaseName = App.Path & "\openmind.mdb"
End Sub
Public Sub OpenDatabase()
Set db = DBEngine.Workspaces(0).OpenDatabase(DatabaseName)
End Sub
Public Function findWhat(ObjectName As String) As String
Dim rs As Recordset
Dim sqlStr As String
Dim resultStr As String
Call OpenDatabase
sqlStr = "SELECT tblConnections.ConnectionType, tblObjects.Name AS fromObject, "
sqlStr = sqlStr & "tblObjects_1.Name AS ToObject FROM (tblObjects INNER JOIN "
sqlStr = sqlStr & "tblConnections ON tblObjects.ID = "
sqlStr = sqlStr & "tblConnections.FromObjectID) INNER JOIN tblObjects AS "
sqlStr = sqlStr & "tblObjects_1 ON tblConnections.ToObjectID = "
sqlStr = sqlStr & "tblObjects_1.ID WHERE "
sqlStr = sqlStr & "(((tblConnections.ConnectionType)=" & Chr(34) & "is" & Chr(34) & ") AND "
sqlStr = sqlStr & "((tblObjects.Name)=" & Chr(34) & ObjectName & Chr(34) & ")) OR "
sqlStr = sqlStr & "(((tblConnections.ConnectionType)=" & Chr(34) & "is" & Chr(34) & ") AND "
sqlStr = sqlStr & "((tblObjects_1.Name)=" & Chr(34) & ObjectName & Chr(34) & ")) OR "
sqlStr = sqlStr & "(((tblConnections.ConnectionType)=" & Chr(34) & "isa" & Chr(34) & ") AND "
sqlStr = sqlStr & "((tblObjects.Name)=" & Chr(34) & ObjectName & Chr(34) & ")) OR "
sqlStr = sqlStr & "(((tblConnections.ConnectionType)=" & Chr(34) & "isa" & Chr(34) & ") AND "
sqlStr = sqlStr & "((tblObjects_1.Name)=" & Chr(34) & ObjectName & Chr(34) & "));"
resultStr = ""
Set rs = db.OpenRecordset(sqlStr, dbOpenSnapshot)
If (rs.RecordCount > 0) Then
rs.MoveFirst
While (Not rs.EOF)
resultStr = resultStr & getStatement(rs) & Chr(13) & Chr(10)
rs.MoveNext
Wend
End If
rs.Close
findWhat = resultStr
End Function
Public Function findPurpose(ObjectName As String) As String
Dim rs As Recordset
Dim sqlStr As String
Dim resultStr As String
Call OpenDatabase
sqlStr = "SELECT tblConnections.ConnectionType, tblObjects.Name AS fromObject, "
sqlStr = sqlStr & "tblObjects_1.Name AS ToObject FROM (tblObjects INNER JOIN "
sqlStr = sqlStr & "tblConnections ON tblObjects.ID = "
sqlStr = sqlStr & "tblConnections.FromObjectID) INNER JOIN tblObjects AS "
sqlStr = sqlStr & "tblObjects_1 ON tblConnections.ToObjectID = "
sqlStr = sqlStr & "tblObjects_1.ID WHERE "
sqlStr = sqlStr & "(((tblConnections.ConnectionType)=" & Chr(34) & "purpose" & Chr(34) & ") AND "
sqlStr = sqlStr & "((tblObjects.Name)=" & Chr(34) & ObjectName & Chr(34) & ")) OR "
sqlStr = sqlStr & "(((tblConnections.ConnectionType)=" & Chr(34) & "purpose" & Chr(34) & ") AND "
sqlStr = sqlStr & "((tblObjects_1.Name)=" & Chr(34) & ObjectName & Chr(34) & ")) OR "
sqlStr = sqlStr & "(((tblConnections.ConnectionType)=" & Chr(34) & "usedin" & Chr(34) & ") AND "
sqlStr = sqlStr & "((tblObjects.Name)=" & Chr(34) & ObjectName & Chr(34) & ")) OR "
sqlStr = sqlStr & "(((tblConnections.ConnectionType)=" & Chr(34) & "usedin" & Chr(34) & ") AND "
sqlStr = sqlStr & "((tblObjects_1.Name)=" & Chr(34) & ObjectName & Chr(34) & "));"
resultStr = ""
Set rs = db.OpenRecordset(sqlStr, dbOpenSnapshot)
If (rs.RecordCo
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -