Applescript cannot recognize valid command from SDEF file - macos

I created valid SDEF file, that contains among other stuff a command:
<command name="abc" code="abc01234" description="do abc">
<cocoa class="ABCCommand"/>
<direct-parameter description="a text parameter passed to the command">
<type type="text" list="yes" optional="yes"/>
</direct-parameter>
<parameter name="abc1" code="abc1" type="text" optional="yes"
description="abc1">
<cocoa key="abcKey1"/>
</parameter>
<parameter name="abc2" code="abc2" type="text" optional="yes"
description="abc2">
<cocoa key="abcKey2"/>
</parameter>
<parameter name="abctrue" code="abct" type="boolean" optional="yes"
description="xxxxxx">
<cocoa key="abctrue"/>
</parameter>
<result type="list of text" description="returns ABC"/>
</command>
Then I set the 'scriptable' flag to YES and compiled the program exactly as all guides recommend.
Now I created Applescript:
tell application "xxx123"
activate
delay 3
abc
delay 3
abc {}
delay 3
abc {"abc", "123"} without abctrue
quit
end tell
The problem is that Applescript being run from AS editor does not recognize 'abc' as command and complains on syntax error. Also in line 'abc {"abc", "123"} without abctrue' it says that 'abctrue:false' cannot follow the '}'. Any changes made in SDEF do not affect the syntax issues. So the question is: how to ensure that Applescript addresses up-to-date SDEF?

Related

How To Reference Yaml File Relative to Launch File?

I have a launch file that is loading a yaml file:
<launch>
<rosparam command="load file="filename.yaml" />
<node pkg="my_package" type="my_package_node" name="my_package_node" />
</launch>
The filename.yaml file cannot be found unless I put a complete path: "/home/username/blah/blah/blah". Seeing as this launch file is used on multiple machines by different users and locations for the repository, I obviously cannot hard-code the path. So now what? How do I reference it relative to the location of the launch file?
we can set environment variable PWD for the specified node, eg we'd like to pass a rviz configuration file to rviz, the relative path can be like this:
<arg name="rviz_file" value="$(eval env('PWD')+'/config/showme.rviz')"/>
<node name="rviz" pkg="rviz" type="rviz" args="-d $(arg rviz_file)" required="true" />
Best answer I could find myself was to use $(find package_name) as a starting point:
<launch>
<rosparam command="load file="$(find package_name)/../../yamlFolder/filename.yaml" />
<node pkg="my_package" type="my_package_node" name="my_package_node" />
</launch>
Seems kinda silly though. No reference to the path relative to the launch file itself? Would definitely like a better answer.
If You are using ROS Packages, Launch Folders Are in the root folder of Package So $(find package) are actually one folder before your launch file
If your yaml file is in a ROS package, then I think using the find substitution arg as you do in your answer is the cleanest route. If it's someplace else, I would suggest leveraging environment variables with something like
<launch>
<arg name="yaml_path" default="$(optenv YAML_PATH)"/>
<arg if="$(eval yaml_path == '')" name="yaml_file" value="$(env HOME)/some_folder/filename.yaml" />
<arg unless="$(eval yaml_path == '')" name="yaml_file" value="$(arg yaml_path)/filename.yaml"/>
<rosparam command="load" file="$(arg yaml_file)"/>
</launch>
This kind of gives the best of all worlds. If you've set YAML_PATH as an environment variable (e.g. export YAML_PATH="$HOME/some_path" from terminal or in your bashrc) then the path for yaml_file will use it. If not, optenv will evaluate to an empty string and the arg yaml_file will be set to some default path relative to your home folder. AND, if you have a user that doesn't want to mess with the environment variables at all, they can still pass in a path manually by calling it like
roslaunch my_launch_file.launch yaml_path:=/home/my_name/my_preferred_folder

klish command completion on pressing tab button

Hi I have small doubt in klish xml file. I implemented a small xml file for klish
<COMMAND name="show core"
help="It will show core status"
<ACTION> echo "core status" </ACTION>
</COMMAND>
I thought that by using command "show core" on klish command line it will print the core status as output but I am not able to print core status on command line of klish
How to solve ?
We can not use space in the < COMMAND > tag like in my case I used.
<COMMAND name="show core">
This is not the proper way to use space in the < COMMAND > tag
But if you want that your command should be like this only i.e. show core then there are two ways to achieve it.
First way:-
<COMMAND name="show"
help="Put what help you want to give"/>
<COMMAND name="show core"
help="Put what help you want to give">
<DETAIL>
</DETAIL>
<ACTION>echo "core status"</ACTION>
</COMMAND>
Second way:- Use VAR tag and completion attribute in PARAM tag
<COMMAND name="show"
help="Put what help you want to give">
<PARAM name="pname"
help="Put what help you want to give"
ptype="STRING"
completion="${vartagvariable}"/>
<DETAIL>
</DETAIL>
<ACTION>echo "core status"</ACTION>
<VAR name="vartagvariable" help="Something...." value="core" />
</COMMAND>

How to edit spring xml file [duplicate]

I want to change a value (i.e., value="false") using Shell Script. How could I go about doing that. Please provide me with any suggestion.
What I have tried / used:
I used command-> sed 's/true/false/g' ml.xml.
Problem:
But all true content changed.
What I would like:
My requirement entails that only a certain specific content to be changed, not every content.
Before: property name="s" value="true"
After: property name="s" value="false"
ml.file
<bean id="a"
class="com.s.analyzer.Analyzer" scope="singleton">
<!-- *** CHANGE to true for first daily run, otherwise false *** -->
<property name="s" value="true" />
<property name="a1l" value="2.5" />
<property name="mi" value="2000" />
<property name="ma" value="1" />
</bean>
Using xml tools would be much better here. See for example how to do this with xmlstarlet:
xmlstarlet ed --ps --inplace --update '//bean/property[#name="s"]/#value' -v false ml.xml
This is an exact match (of <property name="s" value="true):
sed -e "s/\(<property name=\"s\" value=\"\)true/\1false/g" file
To change the file inplace:
sed -i "s/\(<property name=\"s\" value=\"\)true/\1false/g" file
If you want an exact match of <property name="s" value="true" />, then:
sed -e "s/\(<property name=\"s\" value=\"\)true\(\" \/>\)/\1false\2/g" file

Change some fields in a file

I need to analyses a file and change some fields.
Example:
<taskdef uri="xxxxxx" resource="/mnt/data/yyy.xml">
<classpath path="/mnt/data/test.jar"/>
</taskdef>
<target name="test"
description="this is a xml file">
<fileset dir="/tmp/data/output/test_1/" includes=all/>
In my case I need to find this part:
<fileset dir="/tmp/data/output/test_1/" includes=all/>
and change just the name (for example) test_1
At the end, save the file
In your comment you say you "cannot use libraries like Nogokiri to parse the file". So I can only guess you're not doing full XML parsing.
Assuming you do not have to parse XML you could just use Ruby's String.replace method on the line in question. Just iterate over the lines in the file until you get to the one in quesion and call replace. Here's some pseudocode.
open file
for each line
is this what I want to change
change line
save (new) file

PropertyGrid ValueEditor for a file name

I have the following rule definition:
<Rule ...>
<... />
<StringProperty Subtype="file" ...>
<StringProperty.ValueEditors>
<ValueEditor EditorType="DefaultStringPropertyEditor" DisplayName="<Edit...>"/>
<ValueEditor EditorType="DefaultFilePropertyEditor" DisplayName="<Browse...>"/>
</StringProperty.ValueEditors>
</StringProperty>
<... />
</Rule>
It adds the "<Edit...>" and "<Browse...>" options for editing a property, but the Browse dialog asks for an *.exe file, when I need to let user select a *.txt file. There is a combobox in the dialog that allows to choose "All files .", but really that's not an option.
I have tried to find a solution but this extensibility bit does not seem to be well documented.
I have finally found a way to do that, yet for VS2012 only. Putting a metadata piece named Filters with the filters string in the typical open file dialog format seems to do the trick now.
Example:
<ValueEditor EditorType="DefaultFilePropertyEditor" DisplayName="<Browse...>">
<ValueEditor.Metadata>
<NameValuePair Name="Filters" Value="Text (*.txt)|*.txt" />
</ValueEditor.Metadata>
</ValueEditor>

Resources