I am thoroughly stumped by this problem. I have some standard functions that I saved in a compiled AppleScript file, let's call it functions.scpt. In another script, I use load script to load a script object to functions.scpt:
set funcs to load script "path/to/functions.scpt
I have one handler in functions.scpt called icon(). For whatever reason, if I try to call this function more than once in my other script, I get an error. Here's some quick example code:
--called once
funcs's icon()
--called twice
funcs' icon()
Whenever I do this, I get the following error: error "«script» doesn’t understand the “icon” message." number -1708 from «script» to «class icon».
Why can't I call the same function from a loaded script object twice? How can I fix this? I need to call it multiple times.
Thank you to #CRGreen and #jweaks. I actually just found the answer on this thread: https://stackoverflow.com/a/13256042/2884386
I had set a variable icon within the handler, which was overwriting the handler. So when the other script tried to access it the second time, it wasn't pointing to the handler, but to the variable. I rewrote the internal variables, and that fixed it.
So, this is (as an example) correct:
on icon()
set _icon to "path/to/icon.png"
return POSIX file _icon
end icon
Whereas this is incorrect:
on icon()
set icon to "path/to/icon.png
return POSIX file icon
end icon
Related
As suggested in the title, it looks like a simple question but i didn't find any solution so far.
So i would like to delete a Word document from a file system, share, file explorer; so any location.
I didn't find a way to deal with that concern.
I've tried simple DeleteFile function but it seems it doesn't handle word file.
Function DeleteAFile(filespec)
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile(filespec)
End Function
The same i tried creating a oWord object ( an instance of a COM component ) but there is no delete method or event available.
Set oWord = CreateObject("Word.Application")
oWord.'No method nor event for delete action
So i'm blocked.
Is someone having a solution, it would be helpful.
In VBA or VB.Net the simple command is:
Kill(Path and Filename)
Based on additional information provided in the comments that only VBScript can now be used. You should consider two factors. The files you are trying to delete are Read Only and you have to then use the Force option on the DeleteFile method. The other is that your routine is receiving some error condition and thus the DeleteFile method is being stopped. You should add error checking to your routine.
For further information on the FileDelete method see the following:
https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/deletefile-method
I have created a system, within which I am instancing kinematic bodies (2D). These have scripts attached. When I call the functions within these, all is GENERALLY okay. However randomly, with wildly different wait times for it to happen (sometimes it never does), the system will crash, saying that the function, that has been working fine, is does not exist within Area2D. I have no clue why this can happen, can anyone give me any help with this.
The actual error code Invalid call. Nonexistent function 'move' in base 'Area2D'
Thanks
Add check for method existence before you call method.
Let's say you call move method for obj variable (replace it with your own).
Now call to the move method should look like this:
if obj.has_method("move"):
obj.move()
Docs
I'm looking through at an old Classic ASP page that uses VBScript. The code below appears to use a variable stored in the config (global.asa) called called CODES_TIMESTAMP. However looking at the servers in question it appears that that variable no longer exists. My question is, if that variable is not defined in the config file then will the error message box be activated?
Dim DB_TIMESTAMP_CODES
DB_TIMESTAMP_CODES = "<%=Application("CODES_TIMESTAMP")%>"
If trim(DB_TIMESTAMP_CODES) = "" Then
msgbox "Setup Error... Codes are not Defined"
End If
My question is, if that variable is not defined in the config file then will the error message box be activated?
Value will be "". But msgbox cannot be executed on ASP web page. msgbox will appear only from VBS script.
The code below appears to use a variable stored in the config (global.asa) called called CODES_TIMESTAMP
You (previous developer) could assign value to Application variable from any page. I suggest you to make full search over all .ASP pages, may be this value assigned not in GLOBAL.ASA
I've built a Google Script which runs when my Spreadsheet is edited:
function onEdit(event)
{
Browser.msgBox(event.source);
general(event);
}
When my function is named onEdit(), the Browser.msgBox returns "Spreadsheet" (so the source is defined)
When my function is named othername(), the Browser.msgBox retunrs "undefined".
I execute the script with the same user, the script runs when my Spreadsheet is edited and i don't change anything else than the name of the function.
Thanks.
onEdit is an event in Google Script, so changing it's name will generate different behavior.
Hope this helps!
event.source stays undefined when you use another function than onEdit().
I've replaced event.source by event.range and now it works.
I don't understand why but it runs.
Here is a sniplet of the QTP code :
Call CreateResultFile("E:\2012MX\Result\test_d\")
And the error is:
The test run cannot continue due to unrecoverable error. Type does not
match:'CreateResultFile'
What am I doing wrong?
This is the error you would get if CreateResultFile wasn't defined, are you sure such a function exists?
1) Somewhere CreateResultFile is declared as an variable, array or as an class/object. It cann't be called, but has to be used as an object of that type.
-or-
2) You did not use Option Explicit in your script (An Unforgivable Sin: each time you run a script without option explicit, somewhere on Earth a puppy dies). QTP sees undefined functions automagically as undeclared variables and complains with "Type mismatch" as explained in 1.
It could be you did not associate the library (vbs or qfl file) with the CreateResultFile function as a resource to the action you are working in.