VoiceGuide IVR Software Main Page
Jump to content

Invalid Vbscript Character

Recommended Posts

When working on a script today suddenly got

 

VBscript compilation error: Invalid character.

 

The problem character was the $ sign at the front of $RV_ENTEREDNUMBER

 

Is there some script header or system path setting required to prevent this?

 

TIA

Share this post


Link to post

Are you running this from within a "Get Numbers" module?

 

Have you checked what value $RV_ENTEREDNUMBER is before using it?

 

Try using this:

set vg = CreateObject("VoiceGuide.CommandLink")
vg.Admin_TraceLogAdd 0, 0, "Value is: [$RV_ENTEREDNUMBER]" 
set vg = Nothing

From within the VBScript first and see what appears in the log trace file.

Share this post


Link to post

The script you suggested compiles ok

Thanks, but I think you misunderstood me.

 

The script was working just fine. I downloaded it from the customer site to our system here and opened it using VBSedit. It gave a compile error *before* I made any changes to the script.

 

The script is below. The compiler gives an 'invalid character' error at the $ in $RV_ENTEREDNUMBER

 

 

dim retval, numrecs

Const adCmdStoredProc = &H0004

Const adParamInput = &H0001

Const adParamOutput = &H0002

Const adInteger = 3

Const adExecuteNoRecords = 128

 

set vg = CreateObject("VoiceGuide.CommandLink")

set cn = CreateObject("ADODB.Connection")

set rs = CreateObject("ADODB.Recordset")

 

cn.Open "Provider=SQLOLEDB;Server=Smart-db;UID=Clarion;PWD=bruce;Database=Smart"

Set cmd = CreateObject("ADODB.Command")

With Cmd

.ActiveConnection = cn

.CommandText = "ValidateSafetyCheck"

.CommandType = adCmdStoredProc

.Parameters.Append .CreateParameter ("@KeyPad", adInteger, adParamInput, 10, $RV_ENTEREDNUMBER)

.Parameters.Append .CreateParameter ("RetVal", adInteger, adParamOutput, 10, 0)

End With

SET rs = cmd.Execute (numrecs, , adExecuteNoRecords)

If cn.Errors.Count > 0 Then

' MsgBox("Error: " & cn.Errors(0).Description)

sResult = "verify_failed"

ELSE

RetVal = cmd.Parameters(1).Value

end if

 

IF RetVal > 0 Then

sResult = "verify_passed"

' MsgBox("Passed!")

ELSE

sResult = "verify_failed"

' MsgBox("Failed! " & RetVal)

end if

 

Set cmd = Nothing

Set cn = Nothing

Set rs = Nothing

' MsgBox(sResult)

vg.Run_ResultReturn $RV_LINEID, sResult

set vg = Nothing

Share this post


Link to post

If you are trying to run what you have quoted above as is directly in a VBScript interpreter it will not work.

 

It will however work OK if you run it from within VoiceGuide's VBScript module.

 

$RV_ENTEREDNUMBER and $RV_LINEID are replaced by VG with appropriate values before running the script.

 

You should replace $RV_ENTEREDNUMBER and $RV_LINEID with some test values and then the VBScript compiler will not give errors...

Share this post


Link to post

Thanks, that reduced the range of possibilities.

 

However I still get an error.

 

This part of the script works fine:

 

.Parameters.Append .CreateParameter ("@KeyPad", adInteger, adParamInput, 10, $RV_ENTEREDNUMBER)

.Parameters.Append .CreateParameter ("RetVal", adInteger, adParamOutput, 10, 0)

 

But when I add another parameter I get the 'Invalid Character' error at the '$' of $RV_CIDNUMBER

 

.Parameters.Append .CreateParameter ("@KeyPad", adInteger, adParamInput, 10, $RV_ENTEREDNUMBER)

.Parameters.Append .CreateParameter ("@CallerID", adInteger, adParamInput, 10, $RV_CIDNUMBER)

.Parameters.Append .CreateParameter ("RetVal", adInteger, adParamOutput, 10, 0)

 

Does this mean there is no Caller ID, perhaps?

Share this post


Link to post

Are the quoted snippets running from inside a VoiceGuide VBScript module or are you running these VBScripts directly?

 

 

If running from VoiceGuide's VBScript module and there is no CallerID then $RV_CIDNUMBER will be replaced with an empty string.

 

From http://www.voiceguide.com/vghelp/html/Resu...ltVariables.htm :

If a Result Variable is used in the script that has not yet been defined, it will be replaced with nothing (an empty string), not a digit zero.

 

Eg: If you use expression: C:\SoundFiles\Info$RV[infoNumber].wav and the script has not yet defined $RV[infoNumber] then the resulting string after the Result Variables are replaced will be: C:\SoundFiles\Info.wav

 

so

 

.Parameters.Append .CreateParameter ("@CallerID", adInteger, adParamInput, 10, $RV_CIDNUMBER)

 

would change into

 

.Parameters.Append .CreateParameter ("@CallerID", adInteger, adParamInput, 10, )

 

which would result in a syntax error.

 

And if you are running the above line yourself directly in a VBScript interpreter then you will get error as VBScript does not know what $RV_CIDNUMBER is...

 

Tip:

It is usually best to use quotes around the RVs which may be empty. eg: this line would not cause an error:

 

.Parameters.Append .CreateParameter ("@CallerID", adString, adParamInput, 10, "")

 

(note changing of adInteger to adString)

Share this post


Link to post

Nope.

 

Even this code produces a syntax error at the $ sign:

 

If $RV_CIDNUMBER = "" Then

CallerID = 'Unknown'

Else

CallerID = $RV_CIDNUMBER

End if

Share this post


Link to post

Is this code running from inside a VoiceGuide VBScript module or are you running these VBScripts directly?

 

Is $RV_CIDNUMBER defined?

 

Tip (again):

It is usually best to use quotes around the RVs which may be empty

 

Try changing to:

 

If "$RV_CIDNUMBER" = "" Then

CallerID = "Unknown"

Else

CallerID = "$RV_CIDNUMBER"

End if

 

Note the use of quotes above.

Share this post


Link to post

- this is being run from inside VoiceGuide

- according to the doco, $RV_CIDNUMBER is a standard Result Variable

 

I misinterpreted your earlier instruction. So vg is a meta language? Will proceed as instructed.

Share this post


Link to post

If Caller ID information did not arrive then VoiceGuide will replace $RV_CIDNUMBER with an empty string before letting the VBScript run.

 

So, if Caller ID information did not arrive this code:

If $RV_CIDNUMBER = "" Then

CallerID = 'Unknown'

Else

CallerID = $RV_CIDNUMBER

End if

would be changed to

If = "" Then

CallerID = 'Unknown'

Else

CallerID =

End if

Which you can see is not valid VBScript and hence and error will occur.

 

If you write the code using quotes around the RVs, like this:

If "$RV_CIDNUMBER" = "" Then

CallerID = "Unknown"

Else

CallerID = "$RV_CIDNUMBER"

End if

and Caller ID information did not arrive then the resulting VBScript which VoiceGuide actually runs would be:

If "" = "" Then

CallerID = "Unknown"

Else

CallerID = ""

End if

Which is a valid VBScript and when running it no errors will be generated and the script will work as expected.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×