Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ VBscript ➜ Speedwalk Database woes

Speedwalk Database woes

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Ishnaf   Australia  (17 posts)  Bio
Date Sun 08 Jun 2003 07:27 AM (UTC)
Message
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

egads!
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Sun 08 Jun 2003 09:37 PM (UTC)
Message
I think your confusion here is because if you have a script name in the "script" box you don't also need to "send to script".

"Send to script" is where the stuff in the send box is sent to the script engine, not where you call a script in the script file.

So, say you typed "speedwalk-shop" then it would send the word "shop" to the VBscript engine, which gives you the syntax error, and then calls the QueryAlias script (because you asked it to do that as well) which succeeds in doing what you want.

Just leave the send box blank (remove the %1). Then it doesn't matter where the "send to" is, but it may as well be the default "send to world".

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


12,163 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.