How can I find what parameters are passed to the event methods of Shell.Explorer? - activex

I thought Shell.Explorer means Webbrowser Control in AutoHotkey.
But as I view the output of the parameters of theNavigateError event, it is slightly different than the ones described in MSDN pages.
I found two different pages at MSDN for NavigateError.
DWebBrowserEvents2::NavigateError http://msdn.microsoft.com/en-us/library/aa768286%28v=vs.85%29.aspx
NavigateError Event http://msdn.microsoft.com/en-us/library/bb268221%28v=vs.85%29.aspx
Since the second parameter shows a url with the below code, I guess AutoHotkey is using the DwebBrowserEvents2 interface but the MSDN page says the method accepts 5 parameters while AutoHotkey receives 6 of them.
new WBConttrol("file:///" A_ScriptDir "/nofile")
class WBConttrol {
NavigateError(oParams*) {
msgbox, 64, % Parameters, % "the number of passed parameters: " oParams.MaxIndex() "`n"
. "1: " (IsObject(oParams.1) ? "object" : oParams.1) "`n"
. "2: " (IsObject(oParams.2) ? "object" : oParams.2) "`n" ; url
. "3: " (IsObject(oParams.3) ? "object" : oParams.3) "`n"
. "4: " (IsObject(oParams.4) ? "object" : oParams.4) "`n"
. "5: " (IsObject(oParams.5) ? "object" : oParams.5) "`n"
. "6: " (IsObject(oParams.6) ? "object" : oParams.6) "`n"
}
__New(strURL="") {
static WB
Gui, New, Resize MaximizeBox
Gui, Add, ActiveX, vWB w300 h200, Shell.Explorer
Gui, show, w300 h200
ComObjConnect(WB, this)
WB.Navigate(strURL)
}
}

Shell.Explorer does indeed mean the WebBrowser control.
The extra (sixth) parameter is defined in the documentation for ComObjConnect():
PrefixEventName([Params..., ComObject])
...
ComObject is optional, and can only be used if the correct number of Params are defined; it contains a reference to the original wrapper object which was passed to ComObjConnect.
The reason for this extra parameter is that some COM event methods do not define any parameters at all, and therefore don't provide a reference to the COM object which the event is being raised on.

Related

RATIONAL DOORS DXL, transfering a versioned link from a formal module to an other

So, I'm trying to make a formal module merging tool right now, and everything is working so far, except link copy. Here's how we copy
We empty already baselined reception formal module
We copy object with correct hierarchy
Then we should copy links
(Yes, it's more of a destroy and rebuild tool, than merging, but still, end result is the same)
The problem is, for incoming links, I'm told the source object of the link is inaccessible, even though the formal module is loaded, and I can access and do whatever I want with it. Here's the code to copy Incoming Links
for o in entire PRBaseline do
{
//Once current PBS has been emptied, start recovering objects from baseline
print "Inside Object : " o."IE PUID" "\n" ""
//Once current PBS is emptied & reconstructed to this PBS baseline, do links.
Link incomingLink
Link outLink
Object sourceObject
Object targetObject
for incomingLink in all(o <- "*") do //Iterate on all incoming baselined links, and load source module
{
ModName_ srcModRef = source(incomingLink)
Module temp = edit(fullName(srcModRef),true)
sourceObject = source(incomingLink)
Object oPRCurr
print name srcModRef
print sourceObject."IE PUID" ""
for oPRCurr in modOldPR do
{
print "Currently on Object : " oPRCurr."IE PUID" " and object : " o."IE PUID" "\n" ""
if (oPRCurr."IE PUID" "" == o."IE PUID" "")
{
createLinkset(fullName(srcModRef), fullName(modOldPR), "Test")
print sourceObject."IE PUID" "\n" ""
sourceObject -> "/Test_Access/Test" -> oPRCurr
print "Creating link between source object : " sourceObject."IE PUID" " & target object : " oPRCurr."IE PUID" " from" name srcModRef "\n" ""
}
}
}
}
As for outgoing links I'm not even able to recover the target object of the link, even though I've loaded in edit mode the targeted module
// Continuation of preceding code block
for outLink in all(o -> "*") do
{
ModName_ srcModRef = target(outLink)
print name srcModRef " est la cible \n" ""
Module temp = read(fullName(srcModRef),true)
targetObject = target(outLink)
Object oPRCurr
print name srcModRef
for oPRCurr in modOldPR do
{
print "Currently on Object : " oPRCurr."IE PUID" " and object : " o."IE PUID" "\n" ""
if (oPRCurr."IE PUID" "" == o."IE PUID" "")
{
createLinkset(fullName(srcModRef), fullName(modOldPR), "Test")
oPRCurr -> "/Test_Access/Test" -> targetObject
print "Creating link between target object : " " " " & source object : " oPRCurr."IE PUID" " from" name srcModRef "\n" ""
}
}
}
I'm sorry if I'm already asking a question that's been asked before, but I can't figure out why it doesn't want to work, and I've tried a lot of solutions already.
So, I actually found the answer after a whole lot more of digging. I'll post it below to help people that need to do this.
So, first of all, regarding incoming links the problem to not having access to the link was actually that I recoverd the baseline object, and not the current version object, like that, I was therefore only able to recover info, not edit the object (As it should be !). Therefore the solutionn should be then to actually open the CURRENT module, and find the object via a comparaison key (I hope you have a way to find the object back). Afterwards, I just proceed as before, with the only difference being that I have the current object, and not it's baselined counterpart.
For outgoing links, the matter was a little trickier, I was able to recover my target module name BUT I couldn't load objects from it for the life of me. The problem was, that you have to actually open the baselined module, to recover the baselined object, to recreate the link. To do so, I loaded it like this (know, that I'm iterating on Baseline Sets in this code, that's what the bs variable is)
Module temp = load(test,baseline(major bs, minor bs, suffix bs), true)
and proceeded as before. Now the scripts works perfectly well, so if you need precisions on the way I do this, feel free to ask below, I'll answer to the best of my capacity.

How can I do about " and ' for saved object in server side and use it for JSON.parse() in javascript?

How can I do about " and ' for saving object and use it for JSON.parse() in javascript?
Because I have some strings and user can type using " and ' in a single string, for example "some description like "abc" for '3 feet" or "about 3'5 feet" or "wel"come"". When I want to transform into a JSON, especially when I want to parse in view side, for example:
var test = '${test as JSON}';
It breaks because contains escape like \"
However, if only contains " and use this JSON.parse("[{"abc": "asda"das"}]"), still invalid, because need escape.
So, I really don't know what I should do in thoses cases. I need some explanation how to fix, avoid or magic.
JSON can be treated directly as Object in Javascript. So you can simply write:
var test = ${(test as JSON).toString()}
Optionally, you can pass true to the toString() method to make the JSON pretty string or Object.
var test = ${(test as JSON).toString(true)}

SugarCRM: Coding a Custom Middle Name field

I'm trying to create a Custom Field in SugarOS 6 to store Middle Names. Designing and implementing the field in EditView was easy enough with the Studio. But I'm stuck when it comes to displaying the concatenated name parts in DetailView (i.e. Salutation + First Name + Middle Name + Last Name).
Foraging through the Sugar Forums got me to this thread which describes a way it can be done. I've implemented the code given there in the form of a Sugar logic hook that utilizes the after_retrieve hook that is called upon the loading of a record.
Here's my hook code:
$hook_array['after_retrieve'] = Array();
$hook_array['after_retrieve'][] = array(
100,
'set_full_name',
'custom/modules/Leads/leads_custom_logic.php',
'LeadsCustomLogic',
'setFullName'
);
And here's the function that is being called:
function setFullName( &$focus, $event, $arguments ) {
$name = $focus->salutation . ' ' .
$focus->first_name . ' ' .
( $focus->middle_name_c ? ( $focus->middle_name_c . ' ' ) : '' ) .
$focus->last_name;
$focus->name = $name;
$focus->full_name = $name;
// echo $focus->full_name;
}
The hook and the called code seems to work fine and if I uncomment the last line (echo) the full name is dumped all over the screen (wherever this function is called). However, it's not displaying where it's actually supposed to, i.e. the row in the DetailView screen where the full name appears.
Any ideas?
Thanks,
m^e
maybe just change detailview.php and add the following to your full name field defs
'customCode' => '{$fields.salutation.value} {$fields.first_name.value} {$fields.midle_name_c.value} {$fields.last_name.value}'
as a new key => value in array and the custom code will be displayed instead of full_name value.

Grails link taglib use outside of GSP

I'm trying to use the taglib call there's attribute parameters, but also the stuff inside the tag itself which the link taglib uses. I can't find the attribute to pass in to a g.link() call to have it render the text of the link. I've tried 'body' and 'link' and 'text' and 'linkText' already - none of those work.
I'm expecting to be able to call
g.link(action:"foo", controller:"bar", _____:"text of the link here")
but don't know what to put in _____
Usually you do it like this:
g.link(action:"foo", controller:"bar", "text of the link here")
The link text doesn't need to be the last parameter, it may appear anywhere:
g.link("text of the link here", action:"foo", controller:"bar")
.
Usage with closure:
Instead of the string you can use a closure which returns a string:
g.link(action:"foo", controller:"bar", {"text of the link here"})
And, as with any groovy closure which is the last parameter for a method call, you can put it after the closing parentheses:
g.link(action:"foo", controller:"bar") {"text of the link here"}
There is no parameter to pass in (for better or for worse).
To get the text in the link, you pass it as a closure.
g.link(action:"foo", controller:"bar") { "text of the link here" }
For the sake of completeness, since it's not mentioned in the docs: if you are calling the tags (as metod calls) inside your own taglib, you can use the closure to output any other content (using out <<) inside the outer tag. For example:
out << g.form(method: "post", controller: "login") {
out << "Name: " << g.textField(name: "name") << "<br>"
out << "Password: " << g.passwordField(name: "password") << "<br>"
out << g.submitButton(name: "login")
}

What's with PCALL or is Wowwiki wrong?

This is a WoW (World of Warcraft) lua script question. Not many of these get asked here but I have no where to turn and Stackoverflow is the programmer oasis for answers.
Question:
Wowwiki states that the 2nd, 3rd, 4th arguments are your calling functions 1st, 2nd, 3rd arguments. I don't find this to be true. I find that the 3rd, 4th, 5th arguments end up being the 1st, 2nd, 3rd arguments.
Link: http://www.wowwiki.com/API_pcall
Function:
function myTest(arg1)
return arg1 .. 10;
end
Problem:
local retOK, ret1 = pcall(myTest,"string value");
when I try the sample I get an error of "trying to perform concatenate on local 'arg1' (a nil value)". If I change the code to:
local retOK, ret1 = pcall(myTest,"string value", "bob");
then I get the output of "bob10". Where does the 2nd argument go and what is it for?
More Testing:
function BobsToolbox:RunTest()
local test1, value1 = pcall(BobsToolbox.Test1, "string value");
SharpDeck:Print("Test1: " .. tostring(test1) .. " Value: " .. tostring(value1));
end
function BobsToolbox:Test1(arg1)
return arg1 .. "10";
end
Results: attempt to concatenate local 'arg1' (a nil value)
function BobsToolbox:RunTest()
local test1, value1 = pcall(Test1, "string value");
SharpDeck:Print("Test1: " .. tostring(test1) .. " Value: " .. tostring(value1));
end
function Test1(arg1)
return arg1 .. "10";
end
Results: string value10
I am new to lua and I can't understand why these are different.
New Question:
The following code works but why?
function BobsToolbox:RunTest()
local test1, value1 = pcall(BobsToolbox.Test1, "string value");
SharpDeck:Print("Test1: " .. tostring(test1) .. " Value: " .. tostring(value1));
end
function BobsToolbox.Test1(arg1)
return arg1 .. "10";
end
What's the difference between the following: ("." vs ":")
function BobsToolbox.Test1(arg1)
function BobsToolbox:Test1(arg1)
Lua Documentation:
http://www.lua.org/pil/16.html
This use of a self parameter is a central point in any object-oriented language. Most OO languages have this mechanism partially hidden from the programmer, so that she does not have to declare this parameter (although she still can use the word self or this inside a method). Lua can also hide this parameter, using the colon operator. We can rewrite the previous method definition as
function Account:withdraw (v)
self.balance = self.balance - v
end
and the method call as
a:withdraw(100.00)
The effect of the colon is to add an extra hidden parameter in a method definition and to add an extra argument in a method call. The colon is only a syntactic facility, although a convenient one; there is nothing really new here. We can define a function with the dot syntax and call it with the colon syntax, or vice-versa, as long as we handle the extra parameter correctly:
Account = { balance=0,
withdraw = function (self, v)
self.balance = self.balance - v
end
}
function Account:deposit (v)
self.balance = self.balance + v
end
Account.deposit(Account, 200.00)
Account:withdraw(100.00)
Possible Conclusion:
With this in mind I assume that when calling a ":" function using "pcall" you must supply the "self" argument.
Related: There are nice live code editors for WoW. I used to use LuaSlinger, but turns out that's no longer developed and the developer recommends Hack instead.
However, what you might be encountering here is that the colon method-call syntax is just syntax sugar, ditto for method definitions, IIRC. Basically, if you do foo:bar("quux!"), where foo is an object, you are in reality just doing foo.bar(foo, "quux!").
Hope that helps!
Well, I don't think WoWWiki is wrong. Here is the code I am using:
function myTest(arg1) return arg1 .. 10; end
local retOK, ret1 = pcall(myTest,"string value");
DEFAULT_CHAT_FRAME:AddMessage(ret1);
local retOK, ret1 = pcall(myTest,"string value", "bob");
DEFAULT_CHAT_FRAME:AddMessage(ret1);
Here is the output I get in my General chat box:
string value10
string value10
How are you trying your sample code? I just pasted my code into an existing mod lua file and made sure that mod was enabled in the addons window before selecting my character and logging in. I made a few changes to the source lua file and typed:
/console reloadui
To try the new changes and have the results output to my screen. I don't have much advice to offer you, because I haven't done much work with WoW addons. Have you tried this code in a blank addon to make sure nothing else is interfering? Have you actually tried the code in game? If you can provide any more information or want me to try anything else, let me know!
Update: Decided to try a few more tests. Here are the tests (with the same function):
local retOK, ret1 = pcall(myTest,"");
DEFAULT_CHAT_FRAME:AddMessage(ret1);
local retOK, ret1 = pcall(myTest, nil, "bob");
DEFAULT_CHAT_FRAME:AddMessage(ret1);
And the results:
10
attempt to concatenate local 'arg1' (a nil value)
It's interesting that the error I see when arg1 is nil is slightly different than the error you see. I'd be interested in knowing how you are testing your code. Or maybe you didn't copy the error down verbatim? I guess you could also try clearing out your WTF folder and disabling the rest of your addons to test this function. If it makes a difference, then you can enable them one a time until you find the problem.

Resources