Not sure why I am getting this error for invalid procedure call for my right call.
Here is my line of code:
lcase(right(trim(RS2.Fields("First_Name")),len(RS2.Fields("Last_Name"))-1))
I can trim everything off and leave just the right function and it will not run as long as I have the length calculation in there. If I make it a simple integer it runs fine.
Make sure that len(RS2.Fields("Last_Name")) won't be 0, so the second parameter can't become -1. Either prepend an If clause or use a Max()-function that clips values < 0.
Evidence:
>> sLN = ""
>> s = Right("pipapo", Len(sLN) - 1)
>>
Error Number: 5
Error Description: Invalid procedure call or argument
Related
I am getting the 800A0414 error in lines 7 and 12 of this script:
Module Module1
Dim p
Sub Main()
CreateObject("Wscript.Shell").Run("program.bat", 0, True)
p = Process.GetProcessesByName("program")
If p.Count > 0 Then
WScript.Sleep(300000)
Else
CreateObject("Wscript.Shell").Run("program clean up.bat", 0, True)
End If
End Sub
Private Function WScript() As Object
Throw New NotImplementedException
End Function
End Module
I am trying to run a batch script, that starts a process, then wait until the process terminates, then run another batch script. I also do not want any command boxes being shown. If their is a easier way please let me know.
Thanks for your help
When you enclose a procedure's argument list in parentheses, you must use the Call keyword:
Call CreateObject("WScript.Shell").Run("program.bat", 0, True)
If you omit the Call keyword, you must also drop parentheses:
CreateObject("WScript.Shell").Run "program.bat", 0, True
To complete what's been said before:
When Call keyword is used to call a procedure (i.e. sub or function) the arguments must be enclosed in parentheses, except when the procedure has no arguments in which case the parentheses are optional. For example all the statements:
Call test()
Call test
Call test(1,2)
are valid, but not this one:
Call test 1
When calling a procedure without using the Call keyword, the parentheses can only be used when either the procedure has zero or one argument or the procedure has a return value (i.e. is a function) and its value is used in the same statement. For example all the statements:
test()
test(1)
test(1,2)
a = test
a = test(1,2)
a = test(test(1,2),2)
are valid, except the third one which has more than one argument. In case it's not clear, the inner call of "test" in the last statement is valid because its return value is used as an argument to another call.
Note that whenever parentheses is used in this text, it is meant to imply the possible comma-separated values as well.
Seems to me this is a VB.NET, not VBScript code.
You have Shell function in VB.NET (and other methods).
Anyway, Run returns any error code returned by the program, and if you
store that result in a variable, you can use parentheses in this case.
Dim lResult As Long
lResult = CreateObject("Wscript.Shell").Run("program.bat", 0, True)
The rest was answered by #Helen.
Set obju=description.Create()
obju("name").value="user"
obju("html tag").value="input"
Arow=Browser("creationtime:=0").page("title:=.*").webedit(obju).set DataTable.Value("user",Global)
Arow=datatable.GetRowCount
For i = 1 To Arow Step 1
datatable.SetCurrentRow (i)
Next
its giving me error "The test run cannot continue due to a syntax error.
Expected end of statement"
anyone know whats going on?
In the line
Arow=Browser("creationtime:=0").page("title:=.*").webedit(obju).set DataTable.Value("user",Global)
you're assigning the return value from the webedit(obju).set procedure to the variable Arow. If you're doing this in VBScript then the arguments for the procedure need to be put in parentheses.
Following the logic of your code I'm not sure if you're intending to save a return value from the set procedure, in which case just take out assigning to the variable:
Browser("creationtime:=0").page("title:=.*").webedit(obju).set DataTable.Value("user",Global)
Similarly, in the for loop, the datatable.SetCurrentRow (i) procedure should be called as
datatable.SetCurrentRow i
I'm trying to ReDim an array in QTP/VB Script but I keep getting the error: Expected Statement.
I've been over the code a hundred times in the last few hours and I'm just not seeing what is missing, and nobody in the office here seems to know what is missing.
So this is just a sanity check for me at this point, and get a fresh set of eyes on the problem.
Here is the line of code with the error message:
ReDim strTempArray(LBound(AryVar) To (UBound(AryVar) - 1))
Or I could put it this way, I've tried so many variations on the theme:
ReDim strTempArray(0 To AryVar.Length - 1)
But they all have one thing in common, they all give the same meaningless error:
Expected statement on that one line of code.
Alright, so maybe it's something with the rest of the sub, so here is the full sub code.
Basically it's part of a Sub called RemoveArrayElement:
Public Sub RemoveArrayElement(AryVar(), intIndexToRemove)
strTempArray()
lngX = 0 'As Long
lngDestinationIndex = 0 'As Long
ReDim strTempArray(LBound(AryVar) To (UBound(AryVar) - 1))
'ReDim strTempArray(0 To AryVar.Length - 1)
lngDestinationIndex = 0
For lngX = LBound(AryVar) To UBound(AryVar)
If lngX <> intIndexToRemove Then
strTempArray(lngDestinationIndex) = AryVar(lngX)
lngDestinationIndex = lngDestinationIndex + 1
End If
Next
AryVar = strTempArray
'End If
End Sub
I should also add that I did include the Option Explicit at the beginning of the file.
Commenting out that one line that is giving the error does make the error go away, which seems to imply for me that the error really is on that line of code and not some place else.
So what am I missing?
Thanks in advance!
VBScript arrays are strictly zero-based, so specifying a range (.. To ..) makes no sense and isn't supported (in contrast to other Basic dialects). Just use ReDim Array(UBound) and be careful with your indices.
I am working on parallelizing String matching algorithm using MATLAB PCT. I am using createJob and several tasks where i am passing the text to be searched, pattern and other parameters. I get the following error. Any idea. The boyer_horsepool function the tasks are targetted looks fine.
Error using parallel.Job/fetchOutputs (line 677)
An error occurred during execution of Task with ID 1.
Error in stringmatch (line 42)
matches = fetchOutputs(job1);
Caused by:
Error using feval
Undefined function handle.
Code
% create the job
parallel.defaultClusterProfile('local');
cluster = parcluster();
job1 = createJob(cluster);
% create the tasks
for index = 1: num_tasks
ret = createTask(job1, #boyer_horsepool, 1, {haystack, needle, nlength, startValues(index), endValues(index)});
fprintf('For index %d the crateTask value is ?\n',index);
disp(class(ret));
%disp(ret);
end
% Submit and wait for the results
submit(job1);
wait(job1);
% Report the number of matches
matches = fetchOutputs(job1);
delete(job1);
Hm, I could be wrong, but it looks like your syntax is fine...
I think the issue is that it's not recognizing boyer_horsepool as a function. It's hard to do anything further without a bit more context. Try moving that function into the same .m file, and double check the spelling and argument count.
Also, try getAllOutputArguments(job1). It's a long shot, but it might work.
Good luck!
I am getting the 800A0414 error in lines 7 and 12 of this script:
Module Module1
Dim p
Sub Main()
CreateObject("Wscript.Shell").Run("program.bat", 0, True)
p = Process.GetProcessesByName("program")
If p.Count > 0 Then
WScript.Sleep(300000)
Else
CreateObject("Wscript.Shell").Run("program clean up.bat", 0, True)
End If
End Sub
Private Function WScript() As Object
Throw New NotImplementedException
End Function
End Module
I am trying to run a batch script, that starts a process, then wait until the process terminates, then run another batch script. I also do not want any command boxes being shown. If their is a easier way please let me know.
Thanks for your help
When you enclose a procedure's argument list in parentheses, you must use the Call keyword:
Call CreateObject("WScript.Shell").Run("program.bat", 0, True)
If you omit the Call keyword, you must also drop parentheses:
CreateObject("WScript.Shell").Run "program.bat", 0, True
To complete what's been said before:
When Call keyword is used to call a procedure (i.e. sub or function) the arguments must be enclosed in parentheses, except when the procedure has no arguments in which case the parentheses are optional. For example all the statements:
Call test()
Call test
Call test(1,2)
are valid, but not this one:
Call test 1
When calling a procedure without using the Call keyword, the parentheses can only be used when either the procedure has zero or one argument or the procedure has a return value (i.e. is a function) and its value is used in the same statement. For example all the statements:
test()
test(1)
test(1,2)
a = test
a = test(1,2)
a = test(test(1,2),2)
are valid, except the third one which has more than one argument. In case it's not clear, the inner call of "test" in the last statement is valid because its return value is used as an argument to another call.
Note that whenever parentheses is used in this text, it is meant to imply the possible comma-separated values as well.
Seems to me this is a VB.NET, not VBScript code.
You have Shell function in VB.NET (and other methods).
Anyway, Run returns any error code returned by the program, and if you
store that result in a variable, you can use parentheses in this case.
Dim lResult As Long
lResult = CreateObject("Wscript.Shell").Run("program.bat", 0, True)
The rest was answered by #Helen.