GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Using External control codes in scripts


I think this has been discussed before.Are we able to use External control codes in a script?

I would like to be able to use a code like {filepath}, or {file}, or {file|ext} along with an Item to obtain the required text.
For Example

var myValue = Item.ProcessExternalCode("{filepath}");

When writing this script that parses the file name and extracts text to a custom column via regexp. I wanted to be able to define the input (currently hard coded to filename) via a string.
Making the config look like this

columns: [ { name:"pid", input:"{filename|noext}", re: /\[(PID_\d*)]/ }, { name:"Numeric Id", input:"{filename|noext}", re: /\[(\d*)\]/ }, { name:"SampleNumbericExt", input:"{filename|ext}", re: /(\d*)/ }]
Is this currently possible?


The object has methods to get all those things. There's no need to use the command codes.


Using the object methods means you need to know the value you want ahead of time. I does not achieve the use case as described in the first post, using command codes would, as they could be passed in to the method.

In the example above using command codes would allow defining outside the method the part of the filename(or path) on which to run the regexp. Currently its hard coded as filename.
Is there another way to solve this I'm not thinking of?


How to execute a JavaScript function when I have its name as a string


FileItem = DOpus.Listers(0).tabs(0).files(0); DOpus.Output(FileItem["realpath"]); DOpus.Output(FileItem["name"]); DOpus.Output(FileItem["ext"]);


Ah I had forgotten about that. Thanks that will work nicely.