What does "flash.profiler.profile" do? - actionscript-3

I found the undocumented function named profile in the package flash.profiler that receive a Boolean parameter.
What does it do?

Related

MS Access: Property defined with 'Form' return type in a interface gives user-defined type not defined compilation error

Looking for help writing an interface that has a property (or function) that returns an object typed as a "Form" (e.g. Access.Form as the return type).
Problem description:
The following simple example code returns a "User-defined type not defined" error if I attempt to compile the project.
I_TestInterface:
Public Property Get MyForm() as Form
End Property
cls_TestClass:
Implements I_TestInterface
Public Property Get I_TestInterface_MyForm() as Form
End Property
This is the only code/objects in a otherwise blank Access-2016 database and asking VBA to 'compile' produces a "User-defined type not defined" error. No lines are highlighted, it simply won't compile. Same occurs if replace 'Form' by "Access.Form"
My usecase is writing classes that wrap/hold a reference to a form internally - sometimes it is easiest to provide a reference to the underlying form so that consuming code can get at form properties without coding them all into the wrapper class.
Steps taken:
Lots of searches on 'user-defined type not defined' errors, in almost all cases this is due to a missing reference. Does not seem applicable since can create a standard module and happy to compile if write a function with a Form return type there. (*)
There was one previous SO thread on similar 'ambiguous' 'user-defined type not defined' error but I can't find it again and it wasn't specific to the 'Form' type in MS-Access
Have a clumsy workaround of providing property that returns an Object type that consuming code just has to cast to a Form (e.g. public property get MyFormAsObjectThatCanBeCastToForm() as Object).
(*). Possible clue? - if I just change the return types to object, the code still won't compile. I need to exit and use the 'de-compile' start up switch when relaunch Access. Then the above code with Object used as a return type is happily compiled.
Question / request:
Before I start re-installing Office, can others reproduce this?
Has anyone experienced this before? Developed a solution?
Thanks
PAHTDC

ClassCastException when using com.agile.px.IAgileSession function sendMail

There is a function sendMail in the interface IAgileSession. I have been trying to test it but I get a ClassCastException. The function takes arguments: session.sendMail(IUser[] arg0, String arg1)
I cannot find any information regarding this function, rather it is not even listed in the Agile 9.3.4 documentation.
Has anyone ever used this function? If so, how to properly use it?
The toArray is the problem:
it is needs to be updated as below
IUser[] users = usr.toArray(new IUser[usr.size()]);

What does the "_" function in Vala do?

I've seen that some projects used _ function that takes string as an argument, like _("Hello World"). But I couldn't find any manuals or articles about what is it and how to use it.
I guess this has something to do with i18n and l10n (it was mentioned in some article I found on the internet), but can you explain to me how it works and how to use it?
That is the GNU gettext localization function. You can provide language specific alternate strings for the one specified in the function call.
There is the xgettext tool, which generates a .pot file (abbreviation for portable object template) from your application code, then translators can make .po localization files for it. Then, you can bundle these with your application, and deliver a more widely usable piece of software.
I18n. See gettext example here: https://ewgeny.wordpress.com/2012/05/10/supporting-multiple-languages-in-your-application-a-simple-gettext-step-by-step-example/
Also found some info about what exactly this function do, it seems to be the macro for Glib.dgettext() function in Vala, this is from valadoc.org:
dgettext
public unowned string dgettext (string? domain, string msgid)
This function is a wrapper of dgettext which does not translate the message if the default domain as set with textdomain has no translations for the current locale.
...
Applications should normally not use this function directly, but use the _ macro for translations.

Can anyone explain the User Objects example in GAS documentation of HTML service?

I've been looking at this "example" in the GAS documentation, but there is no explanation accompanying it from the googlers documenting it:
https://developers.google.com/apps-script/guides/html-service-communication#user_objects
My question pertains to the successhandler and the passing of parameters to the updateButton function. When called in the onclick, the successhandler doesn't include the variables (within the parentheses) in it's call to updateButton. Following the successhandler call is the user object and getEmail but they seem to be out of order (the function updateButton has email before button).
So, how/why does this code work? I've tested it, and even rearranged the variables and what not but the only way it works is in the documentation's writeup. I am unable to understand how the updateButton function knows the parameter values when they are not included in the call to updateButton and they seem to be out of order in the example. Thoughts?
If I understood your question the return of the getEmail function at your GAS script will be redirect to your sucess Handler. You can try to use Logger.log(Session.getActiveUser().getEmail()) and check the return . The parameters order are first the values returned by the gas function and finally the element which triggered the action.

What are callback methods?

I'm a programming noob and didn't quite understand the concept behind callback methods. Tried reading about it in wiki and it went over my head. Can somebody please explain this in simple terms?
The callback is something that you pass to a function, which tells it what it should call at some point in its operation. The code in the function decides when to call the function (and what arguments to pass). Typically, the way you do this is to pass the function itself as the 'callback', in languages where functions are objects. In other languages, you might have to pass some kind of special thing called a "function pointer" (or similar); or you might have to pass the name of the function (which then gets looked up at runtime).
A trivial example, in Python:
void call_something_three_times(what_to_call, what_to_pass_it):
for i in xrange(3): what_to_call(what_to_pass_it)
# Write "Hi mom" three times, using a callback.
call_something_three_times(sys.stdout.write, "Hi mom\n")
This example let us separate the task of repeating a function call, from the task of actually calling the function. That's not very useful, but it demonstrates the concept.
In the real world, callbacks are used a lot for things like threading libraries, where you call some thread-creation function with a callback that describes the work that the thread will do. The thread-creation function does the necessary work to set up a thread, and then arranges for the callback function to be called by the new thread.
Wiki says:
In computer programming, a callback is
a reference to executable code, or a
piece of executable code, that is
passed as an argument to other code.
This allows a lower-level software
layer to call a subroutine (or
function) defined in a higher-level
layer.
In common terms it is the mechanism to notify a piece of code i.e. a method, which piece of code to execute, i.e. another method, when it is needed.
Callback is related to the fact that the client of the calling function specifies a function that belongs to the client code's responsibility to the calling function to execute and this is passed as an argument.
An example is in GUIs. You pass as argument the function to be called once an event occurs (e.g. button pressed) and once the event
occurs this function is called.
This function is usually implemented by the object that originally registered for the event
Callback function is a function that is called through a function pointer. If you pass the pointer (address) of a function as an argument to another, when that pointer is used to call the function it points to it is said that a call back is made.
Why Should You Use Callback Functions?
A callback can be used for notifications. For instance, you need to set a timer in your application. Each time the timer expires, your application must be notified. But, the implementer of the time'rs mechanism doesn't know anything about your application. It only wants a pointer to a function with a given prototype, and in using that pointer it makes a callback, notifying your application about the event that has occurred. Indeed, the SetTimer() WinAPI uses a callback function to notify that the timer has expired (and, in case there is no callback function provided, it posts a message to the application's queue).
In general you supply a function as a parameter which gets called when something occurs.
In C code you will pass something that looks like this:
int (callback *)(void *, long );
meaning a function that takes two parameters, void * and long and returns an int.
With object-orientated languages the syntax is sometimes simpler. For example you might be able to construct a callback mechanism that allows the user to pass in an object that looks like a function or has an abstract method (thus wrapping a function) and context data too.
Modern languages use the term "delegate" to refer to a function "pattern". These can be used as callbacks. Some languages also use the term lambda which is essentially a function with no name, often created "on the fly" in a block of code and passed as a callback.
C++11 has introduced these into its standard.
The advantage of using a callback is that you can separate out, i.e. reduce / decouple an API from what is calling it, and to some extent vice versa, i.e. although in one place you know you are calling into the API, at the point of the "handler" it does not need to know from where it was called.
For example, you can have an API that generates objects and then "calls-back" as they get generated.
Call back means that you pass the code as a parameter. For example, imagine a button, that much show a dialog when pressed:
Button testBtn;
testBtn.setOnClickListener(new OnClickListener() {
#Override
public void onCLick() {
JOptionPane.showDialog(testBtn, "Test button pressed");
}
}
Here we tell the button what to execute, when it will be click. So, the framework will execute the passed code, when it detecs the click. Inside the framework there are some code like:
void processEvent(Event e) {
if (e.type == Event.CLICK) {
e.getComponent().getOnClickListener().onClick();
}
}
So, some basic code calls back the listener when the appropriate event happens.
PS: Pseudocode here, just do describe the idea.
A callback method is a method that gets called when an event occurs
In simple word, actually, a Callback is a reference to a function or method, which you can pass as a parameter to another function for calling it back later.
From the above figure, B_reference() is the callback method.
Source code sample:
>>> def A(A_msg,B_reference):
... # After printing message, method B is called.
... print(A_msg)
... B_reference()
...
>>> def B():
... print("Message from B")
...
>>>
>>> A("Message from A",B)
Message from A
Message from B
>>>
If you still don't understand what it is, you can check this video: