Gday.
I need some help with the following, i cant figure out what my error is.....
I have an alias that sends info to a script:
ALIAS: speedwalk-*
SEND: %1
LABEL: Speed
(SENDS TO SCRIPT) SCRIPT: QueryAlias
But whenever i fire it, it tells me:
Scripting error, Execution of line 1 column 1
Type mismatch: 'bazaar'
Line in error:
But then continues to work perfectly and put up the right speedwalk from the database i have
Database looks like:
Table name:T_Area
Table:
_____________________________________
|ID| areaID | Dirs | Notes | StartCity|
|--|--------|------|-------|----------|
My Script is a modified version of your script, Nick, which I've been using to connect to a speedwalk direction database, this is all the stuff I have:
function GetDatabaseFileName
GetDatabaseFileName = "c:\ishnaf\sped\db1.mdb"
end function
function GetProvider
GetProvider = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & _
GetDatabaseFileName & _
";" & _
"Jet OLEDB:Engine Type=5;"
end function
Function DoSQL (sSQL)
dim db
DoSQL = vbTrue ' error return
On Error Resume Next
Set db = CreateObject ("ADODB.Connection")
If Err.Number <> 0 Then
ShowError Err.Description
Exit Function
End If
' Open the connection
db.Open GetProvider
If Err.Number <> 0 Then
ShowError Err.Description
Set db = Nothing
Exit Function
End If
' Execute it
db.Execute sSQL
If Err.Number <> 0 Then
ShowError Err.Description
Set db = Nothing
Exit Function
End If
On Error GoTo 0
' Wrap up
db.Close
Set db = Nothing
DoSQL = vbFalse ' OK return
end Function
' Since we are doing queries in a few places, we will do the main
' part here ...
' A "true" result means the query failed.
' A "false" (zero) result means the query succeeded
'
Function ExecuteQuery (db, rst, sQuery)
ExecuteQuery = vbTrue ' assume bad result
On Error Resume Next
Set db = CreateObject ("ADODB.Connection")
If Err.Number <> 0 Then
ShowError Err.Description
Exit Function
End If
Set rst = CreateObject ("ADODB.Recordset")
If Err.Number <> 0 Then
ShowError Err.Description
set db = Nothing
Exit Function
End If
' Open the connection
db.Open GetProvider
If Err.Number <> 0 Then
ShowError Err.Description
Set rst = Nothing
Set db = Nothing
Exit Function
End If
' Open the Recordset
rst.Open sQuery, db
If Err.Number <> 0 Then
ShowError Err.Description
Set rst = Nothing
Set db = Nothing
Exit Function
End If
On Error GoTo 0
ExecuteQuery = vbFalse ' good result
End Function
' Do some arbitrary query, display the results
'
sub DoQuery (sQuery)
dim db, rst, count, fld
if ExecuteQuery (db, rst, sQuery) Then Exit Sub
count = 0
' display each record
world.colourtell "red", "black", "Search Results: "
world.note ""
world.note ""
Do Until rst.EOF
' display each field name
For Each fld In rst.Fields
if fld.value <> "0" then
if fld.Name = "ItemType" then
world.colourTell "white", "darkblue", _
"Itemtype:"
world.colourTell "white", "black", " " & fld.value
world.note "" 'newline
else
world.ColourTell "white", "darkblue", _
fld.Name & chr(9) & ":"
world.colourTell "white", "black", " " & fld.value
world.note "" ' newline
end if
end if
Next
world.note "" ' newline
rst.MoveNext
Loop
db.Close
Set rst = Nothing
Set db = Nothing
world.note count & " record(s)"
end sub
sub QueryAlias (sName, sLine, wildcards)
dim SQL
SQL = "SELECT * FROM T_Area WHERE AreaID='" & wildcards(1) &"'"
Speedwalk SQL
end sub
sub Speedwalk (sQuery)
dim db, rst, count, fld
if ExecuteQuery (db, rst, sQuery) Then Exit Sub
' display each record
'MY BIT THAT I ADDED:
dim dirs
dirs = rst("dirs") 'get the directions
world.note dirs 'check it comes out (testing phase only)
world.note world.EvaluateSpeedwalk (dirs) 'speedwalk there
db.Close
Set rst = Nothing
Set db = Nothing
end sub
Hopefully, when its working, ill upload the script to the plugins coz i think it will be pretty useful!
Thanks ppl
|