wierd problem with constants.vbs

Posted by Perrin on Tue 05 Feb 2008 01:27 AM — 6 posts, 25,032 views.

USA #0
yesterday i was messing around with a trigger and started to receive this error message i didn't do anything to this file and can't figure out what happened

Script error
World: aardwolf
Execution of line 1 column 1
Immediate execution
Expected statement
Line in error: 
<?xml version="1.0" encoding="UTF-8"?>

heres the first few line of the file


<?xml version="1.0" encoding="UTF-8"?>

<!-- Constants For use in VB scripting -->

<!DOCTYPE script>
<script>
<!\[CDATA\[
option explicit
Amended on Tue 05 Feb 2008 01:30 AM by Perrin
Australia Forum Administrator #1
Can you post the trigger you were messing with?
USA #2
Its the trigger i posted in help with an alias/trigger

I switched my script file to a blank .vbs file
all my script functions seem to work but mushclient crashes when i try to use trace

do you know where i can get a new constants.vbs file your link is dead for me.
Amended on Tue 05 Feb 2008 04:04 PM by Perrin
Australia Forum Administrator #3
You haven't given me a heap of information here, however I am guessing that you have a plugin installed (which are the only things that use constants.vbs).

You also haven't said which version of MUSHclient you are using

First thing I would try is remove your plugins and see if the error goes away.

I suspect the problem is caused by using a "relative" path in your configuration for plugins - see Global Preferences -> Plugins -> Plugins Directory. A relative paths starts with a dot (like ".\worlds\plugins\")

I would hit that button and select the actual directory, changing it to an absolute directory (eg. "C:\Program Files\MUSHclient\worlds\plugins\").
Amended on Tue 05 Feb 2008 07:25 PM by Nick Gammon
USA #4
Ok my dir was absolute and i uninstalled everything making backups of my aliases/triggers/plugins/variables
reinstalled mushclient and recreated my world
when i enabled scripting and switched from lua to vbscript
and targeted the new constants.vbs i received this message

Error number: -2146827264
Event:        Execution of line 1 column 1
Description:  Expected statement

Line in error: 

<?xml version="1.0" encoding="UTF-8"?>
Called by:    Immediate execution



had just created the worldfile it is pretty bare
has no aliases,plugins,etc.
Amended on Fri 08 Feb 2008 11:09 PM by Perrin
Australia Forum Administrator #5
Ah OK I see what you are doing. That file constants.vbs is not supposed to be directly used as your script file. If you make a plugin it is included as part of the plugin, to give you various helpful names inside your scripts.

For example, take this line:


const eTimerAlreadyExists = 30018 ' Attempt to add a timer that already exists


Now after doing an AddTimer you might get back an error code. You could either say:


if error = 30018 then
  '  could not add timer
endif


Or, if you used the constants file, you could say:


if error = eTimerAlreadyExists then
  '  could not add timer
endif


The second one is slightly better documentation basically.

Unless you want to use all the names in constants.vbs I would ignore it, and simply make a blank script file (or no script file at all, and just do "send to script").

For more details about that see:

http://mushclient.com/scripting

However if you want to use the constants inside a script file, just omit the XML stuff at the start and the end, like this:


<?xml version="1.0" encoding="UTF-8"?>

<!-- Constants For use in VB scripting -->

<!DOCTYPE script>
<script>
<![CDATA[


.......... keep the rest of the file up to the last 2 lines ........


]]>            
 </script>


If you copy and paste the stuff excluding what I have in bold above, then that is ordinary VBscript, and you could paste it into the start of your new, empty, script file.