GP SoftwareTwitter
Opus FAQsManualCommandsObjects

How user-defined commands use data in the template

HashFile.zip (491 Bytes)

<?xml version="1.0" encoding="UTF-8"?>
<usercommand backcol="none" hide_from_menu="no" textcol="none">
	<label>HashFile</label>
	<tip>Generate hash file.</tip>
	<template>Type/K[MD5,SHA1]</template>
	<user_label>Generate MD5 hash file.</user_label>
	<icon1>#opus12flattaeicons:calcmd5checksum</icon1>
	<function type="normal">
		<instruction>@nodeselect </instruction>
		<instruction>@disablenosel </instruction>
		<instruction>Clipboard COPYNAMES=hash2 </instruction>
		<instruction>Clipboard PASTE AS checksums.md5</instruction>
		<instruction>Clipboard SET &quot;&quot;</instruction>
	</function>
</usercommand>

How do I get the value of the "type" field from the command? And set the file name for "Clipboard PASTE AS" based on this value?

With a Type/K argument, use &Type& to insert the parameter that was given to it.

(Documented here: User-defined commands.)

How to determine the value of the "type" parameter?

@ifset:&TYPE&="MD5"
Clipboard COPYNAMES=hash2
@ifset:&Type&="SHA1"
Clipboard COPYNAMES=hash5

or

@if:&TYPE&="MD5"
Clipboard COPYNAMES=hash2
@if:&Type&="SHA1"
Clipboard COPYNAMES=hash5

The value of the "type" argument was not taken.

You would need to use scripting to do conditional branching based on the value of an argument.

In the next update we'll make it so you can do simple tests on the arguments without resorting to a script. The following command will work from 12.16.5:

@if:&&TYPE&&=MD5
Clipboard COPYNAMES=hash2
@if:&&TYPE&&=SHA1
Clipboard COPYNAMES=hash5

Clipboard PASTE=enc:utf16 AS checksums.&TYPE&
return filename
checksums.&TYPE&

can not get the value of the "type" keyword.

Directory Opus 12.16.5.0

It works OK here: