Whats the applescript syntax for sending arguments? - cocoa

I'm following apples applescript example for scripting parameters
I can send the direct parameter no problem using the following syntax
tell app "SimpleScriptingVerbs" to do command with args "Im a direct parameter"
However I can't figure out the correct syntax for sending the other optional arguments.
The rest of the accepted optional arguments look like this
<command name="do command with args" code="SVrbAgCm" description="run a command with a bunch of arguments">
<cocoa class="CommandWithArgs"/>
<direct-parameter description="a text parameter passed to the command">
<type type="text"/>
</direct-parameter>
<parameter name="blinking" code="savo" type="boolean" optional="yes"
description="a boolean parameter.">
<cocoa key="SaveOptions"/>
</parameter>
<parameter name="preferred hand" code="LRnd" type="preferredhands" optional="yes"
description="a parameter using our enumeration.">
<cocoa key="TheHand"/>
</parameter>
<parameter name="prose" code="Pros" type="text" optional="yes"
description="a text parameter.">
<cocoa key="ProseText"/>
</parameter>
<parameter name="ivalue" code="iVal" type="integer" optional="yes"
description="an integer parameter.">
<cocoa key="IntegerValue"/>
</parameter>
<parameter name="rvalue" code="rVal" type="real" optional="yes"
description="an real number parameter.">
<cocoa key="RealValue"/>
</parameter>
<result type="text" description="the direct parameter enclosed in quotes"/>
</command>
What's the correct applescript syntax to send the rest of these arguments.

You must use a parameter's name with a value, like this:
tell application "SimpleScriptingVerbs" to do command with args "Something" prose "bla 1" preferred hand Left Hand ivalue 299 rvalue 75.777
The application logs -->
proc=-[CommandWithArgs performDefaultImplementation] The other parameters are: '{
"" = Something;
IntegerValue = 299;
ProseText = "bla 1";
RealValue = "75.777";
TheHand = 1279816302;
}'

Related

how to use variable inside <xml-module:xpath-extract> mule 4

I have a variable set value as "Active." Based on the value of a variable, I want to select a node in the payload.
If I give values directly in xpath, it's work.
When I'm trying to use variables inside an xpath, like #Status = vars.xstatus. It returns a null value [].
Mule 4 flow:
<flow name="var_xpath_testFlow" doc:id="406270fb-17e7-48e9-a33a-f7a0197f8e05" >
<http:listener doc:name="Listener" doc:id="662f2277-859f-4516-974b-de7cceeb5b40" config-ref="HTTP_Listener_config" path="/vartest"/>
<set-variable value="Active" doc:name="Set Variable" doc:id="12370458-bb32-4709-b509-acc1e5f50b94" variableName="xstatus"/>
<xml-module:xpath-extract doc:id="6027ebad-f81d-4df1-8234-3d8dab04b129" config-ref="XML_Config" xpath="/DTOApplication/DTOLocation[#Status=vars.xstatus ]" target="xvalue"/>
<logger level="INFO" doc:name="Logger" doc:id="f495b0bf-f8cb-43be-b4d9-d069758e4028" message="#[vars.xvalue]"/>
</flow>
XPATH expression:
/DTOApplication/DTOLocation[#Status='Active']
XML payload: https://github.com/Manikandan99/rate-dtostep/blob/master/request.xml
how to use variables in XPath Mule 4?
Instead of a literal string use a Mule 4 expression.
Something like:
xpath="#["/DTOApplication/DTOLocation[#Status='" ++ vars.xstatus ++ "']"]"/>
I have edited your code, use below code that is having corrections for the xpath expression
<flow name="var_xpath_testFlow" doc:id="7490a882-4473-461d-846b-b6a7b65a8eca" >
<http:listener doc:name="Listener" doc:id="4767ed08-42cb-467c-80c2-4b739c68724e" config-ref="HTTP_Listener_config" path="/vartest"/>
<set-variable value="Active" doc:name="Set Variable" doc:id="62eaffcf-ea2e-4f05-8ad8-d840bbebe9e4" variableName="xstatus"/>
<xml-module:xpath-extract doc:id="15124867-b70c-4656-8eb9-d99d4e500a0e" config-ref="XML_Config" xpath='#["/DTOApplication/DTOLocation[#Status=" ++ vars.xstatus ++ "]"]' target="xvalue"/>
<logger level="INFO" doc:name="Logger" doc:id="340b9b89-18f8-4584-b6cb-7ab9d6d8efed" message="#[vars.xvalue]"/>
</flow>
Below is the screenshot that is showing how and where I did a correction
In the above screenshot as I Mentioned that click on "fx", if you add the expression without clicking on it and run your code, you will get an error as below
"Could not compile xpath expression "/DTOApplication/DTOLocation[#Status=" ++ vars.xstatus ++ "]""
In Mule 3, you must learn both the Mule Expression Language (MEL) and DataWeave. but now in Mule-4 DataWeave is the default expression language, if you click on "fx" it means you are entering DataWeave Expression Language
After this correction, I am getting correct output as in the below snippet
below is the complete xml file
<?xml version="1.0" encoding="UTF-8"?>
<mule
xmlns:xml-module="http://www.mulesoft.org/schema/mule/xml-module"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
xmlns:x12="http://www.mulesoft.org/schema/mule/x12"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/x12 http://www.mulesoft.org/schema/mule/x12/current/mule-x12.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/xml-module http://www.mulesoft.org/schema/mule/xml-module/current/mule-xml-module.xsd">
<http:listener-config name="HTTP_Listener_config"
doc:name="HTTP Listener config"
doc:id="5fe97da4-b1a9-4a9b-9a23-c4c42249fb2b">
<http:listener-connection host="0.0.0.0"
port="8081" />
</http:listener-config>
<xml-module:config name="XML_Config"
doc:name="XML Config" doc:id="6c8afa4c-6fec-4791-94a3-b4f8f63442e7" />
<flow name="var_xpath_testFlow"
doc:id="7490a882-4473-461d-846b-b6a7b65a8eca">
<http:listener doc:name="Listener"
doc:id="4767ed08-42cb-467c-80c2-4b739c68724e"
config-ref="HTTP_Listener_config" path="/vartest" />
<set-variable value="Active" doc:name="Set Variable"
doc:id="62eaffcf-ea2e-4f05-8ad8-d840bbebe9e4" variableName="xstatus" />
<xml-module:xpath-extract
doc:id="15124867-b70c-4656-8eb9-d99d4e500a0e" config-ref="XML_Config"
xpath='#["/DTOApplication/DTOLocation[#Status=" ++ vars.xstatus ++ "]"]'
target="xvalue" />
<logger level="INFO" doc:name="Logger"
doc:id="340b9b89-18f8-4584-b6cb-7ab9d6d8efed"
message="#[vars.xvalue]" />
</flow>
</mule>
Note: I am using Anypoint Studio version 7.11.1 ad Mule runtime version -4.4.0 (but I tried with runtime 4.3.0 and its working fine)

jms selector expression in Mule is not working

<flow name="readqueueFlow1" doc:name="readqueueFlow1" >
<jms:inbound-endpoint queue="MyTestQueue" connector-ref="Active_MQ-Priority" doc:name="JMS">
<jms:selector expression="JMSCorrelationID=’353’" />
</jms:inbound-endpoint>
</flow>
Its working but when i try to use the below one its not deploying
<!-- When we don't provide single quote it is failing in deployment -->
<jms:selector expression="JMSCorrelationID='#[flowVars.reqId]'" />
<!-- Payload contains reqId, when we provide it in single quote, it is assuming as a constant -->
<jms:selector expression="JMSCorrelationID='#[payload]'" />
I think here is your answer given :- Using an expression in a JMS Selector in Mule 3
And one more thing, you cannot use #[flowVars.reqId] for getting the jms:selector value dynamically since flow variable scope is limited to a flow ... instead use a session variable like #[sessionVars.reqId]..
and your flow will be modified as follow :-
<flow name="readqueueFlow1" >
<jms:inbound-endpoint queue="StudioOUT" connector-ref="Active_MQ" doc:name="JMS"/>
<scripting:component>
<scripting:script engine="groovy"><![CDATA[
def jmsMessages = []
for (def muleMessage = muleContext.client.request("jms://MyTestQueue?selector=JMSCorrelationID%3D'"+ sessionVars['reqId'] +"'", -1L);
muleMessage != null;) {
[] << muleMessage.payload
}
jmsMessages
]]></scripting:script>
</scripting:component>
<logger level="INFO" message="#[message.payload]" doc:name="Logger"/>
</flow>
You can see here the message is send to the queue using Groovy Script and I have used session variable instead of flow variable
jms:selector expression="putOnQueueTime > ABC "
can use the above expression in jms inbound.

How to access XML parameters conditionally

This is a XML code snippet:
<testcase name="T.3.03.02">
<cmd>CMD_EXPORT_RAM_KEY</cmd>
<sreg_pre>40</sreg_pre>
<sreg_pre_bitmask>ff</sreg_pre_bitmask>
<sreg_post>40</sreg_post>
<sreg_post_bitmask>ff</sreg_post_bitmask>
<erc>ERC_NO_ERROR</erc>
<testvector>
<parameter name="UID" type="info">000000000000000000000000000002</parameter>
<parameter name="UID'" type="info">000000000000000000000000000002</parameter>
<parameter name="KeyId" type="info">0e</parameter>
<parameter name="Key" type="info">0f0e0d0c0b0a09080706050403020100</parameter>
<parameter name="AuthId" type="info">00</parameter>
<parameter name="KeyAuth" type="info">2b7e151628aed2a6abf7158809cf4f3c</parameter>
<parameter name="Old counter value of updated key slot" type="info">0000000</parameter>
<parameter name="New counter value C'" type="info">0000000</parameter>
<parameter name="Protection flags F'" type="info">00</parameter>
<parameter name="M1" type="output">000000000000000000000000000002e0</parameter>
<parameter name="M2" type="output">152876f29dc7ca8d18e38d70374492b05d908c8c584a0409849a553c75254def</parameter>
<parameter name="M3" type="output">bc6e79bc4458339174fc80fb08b83188</parameter>
<parameter name="M4" type="output">000000000000000000000000000002e07783b86ae87b87e3ca12809c2df75fae</parameter>
<parameter name="M5" type="output">c8fcc8859c69c8bd840ce8e24c5114e9</parameter>
</testvector>
<precondition>RAM_KEY_PLAIN = 1; RAM_KEY_EMPTY = 0</precondition>
<description>Export plain RAM_KEY with external debugger attached; Note: The security flags SECURE_BOOT_PROTECTION and DEBUGGER_PROTECTION of the key SECRET_KEY are inherited from MASTER_ECU_KEY.</description>
</testcase>
I want to access all "parameter name="Key" type="info" values.
How do I access these values conditionally if the condition <cmd>CMD_EXPORT_RAM_KEY(second line in XML)</cmd> is valid.
In this XML file there are also other commands (<cmd> lines) also with the "Key" parameter,
but in these cases I don't want to get the key-values.
I didn't get it running.
Can anyone help me with some ideas?
Would something like this work?
doc = Nokogiri::parse(File.read( "data.xml" ))
check = doc.xpath( "//cmd" ).select{|el| el.children[0].text == "CMD_EXPORT_RAM_KEY" }
puts "Check: %i" % check.size
if(check.size == 0)
## Do stuff here
end
Try the below XPath with Nokogiri:
//testcase/cmd[text()='CMD_EXPORT_RAM_KEY']/../testvector/parameter[#name="Key" and #type="info"]
Of course, you can parameterize the CMD_EXPORT_RAM_KEY and #name/#type values.
The trick is to locate the specific ones you want using a selector, then narrow down further if necessary.
Using the CSS selector 'parameter[#name="Key"][#type="info"]' Nokogiri easily finds the single occurrence in your sample. If there were more, then more would be returned:
require 'nokogiri'
doc = Nokogiri::XML(<<EOT)
<testcase name="T.3.03.02">
<testvector>
<parameter name="UID" type="info">000000000000000000000000000002</parameter>
<parameter name="Key" type="info">0f0e0d0c0b0a09080706050403020100</parameter>
</testvector>
</testcase>
EOT
doc.search('parameter[#name="Key"][#type="info"]').map(&:content)
# => ["0f0e0d0c0b0a09080706050403020100"]
I used CSS because it looks less like line noise than the equivalent XPath selector would.
Also, when supplying sample data, reduce it to the bare minimum necessary to test the code. Anything beyond that wastes our time, and, if it's too much, can actually cause you to get no answers because nobody wants to wade through that.

IzPack: get user input then process it in the processpanle

H,
I need to get a user input during installation then use it as an argument for an application which is executed in the processPanle. How can I get the variable which contains the user input in the processPanel?
You can reference the variable using ${} syntax like shown in the following example.
userInputSpec.xml (snippet):
<field type="rule" variable="tomcat_http_port">
<spec txt="HTTP-Port:" id="panel0.field2.label" set="0:80" layout="N:5:5" />
</field>
process.xml (snippet):
<job name="Launching Browser">
<executeclass name="edu.ccdb.util.BareBonesBrowserLauncher">
<arg>http://localhost:${tomcat_http_port}/klaros-web</arg>
</executeclass>
</job>

AppleScript script command implementation

I'm trying to implement a trivial script command, byt have no success..
My sdef file
...
<class name="image" plural="images" code="imag" description="Image class">
<cocoa class="MyImage" />
<property name="width" code="wdth" type="real" access="r" description="The width of the image."/>
<property name="height" code="hght" type="real" access="r" description="The height of the image."/>
<responds-to name="rotate">
<cocoa method="scriptingRotate:"/>
</responds-to>
</class>
<command name="rotate" code="frwkrota" description="Rotate the image.">
<direct-parameter type="image"/>
<parameter name="by" code="by " type="real" description="Degrees to rotate.">
<cocoa key="angle"/>
</parameter>
</command>
...
My dictionary is ok: image responds to rotate and so on..
But
tell application "MyApp"
rotate image 1 by 1
end tell
says that: "Expected end of line but found class name." Where is the mistake?
get image 1 works normally (MyImage have objectSpecifier).
SOLVED
Seems like it was a bug with ScriptEditor..
Restarting ScriptEditor solved the problem.

Resources