Script - Obtain default path object

var f1 = DOpus.FSUtil.resolve("{apppath|excel.exe}"); DOpus.output(typeof(f1) + " : " + f1);

object : C:\Program Files (x86)\Microsoft Office\Office15

Pardon my ignorance. Can someone tell me how to reference/access the default value of the Path object. I want to lay my hands on the value as a Script variable.

Regards, AB

That's what you're printing in the above example. f1 by itself, without any methods or properties, returns the path as a string.

I want to perform a string comparison using the returned default value but as shown in my sample code, typeof(f1) is an object, not a string. I can generate a complete string from f1.pathpart and f1.filepart but would prefer to get the complete string, as a string.

Regards, AB

var str = String(f1); would convert the default value to a native String type.

Yes it would. In my opinion it would be useful to have a mechanism of explicitly accessing the property of Opus objects. Something along the lines of DOpus.FSUtil.resolve.default in this example. Currently the documentation indicates a return type of string but since there is no way of referencing the property by name, the reality is that the return type is object.

Regards, AB

f1 is an object, but the default value of f1 is a string. Referencing the default value by name doesn't make sense - if it had a name, it would be a named value, not the default value. The only issue in any of this is that when you pass f1 to the typeof operator it's not referencing the default value, but if you were to pass it to a function that expects a string it would be dereferenced automatically.

If you need to make a string object explicitly you can, using the String() operator as shown above.

This discussion probably belongs in CoffeeShop since it amounts to me exposing my relative ignorance of JScript and is not Opus specific. I appreciate your help.

My issue started with this code. The toLowerCase method fails because f1 is an object, not a string.

var f1 = DOpus.FSUtil.resolve("{apppath|excel.exe}"); DOpus.output(f1.toLowerCase());
Based on your advice..

var f1 = DOpus.FSUtil.resolve("{apppath|excel.exe}"); DOpus.output(String(f1).toLowerCase());
..does the trick.

I'm interested in your comment "..if you were to pass it to a function that expects a string it would be dereferenced automatically." Can you give me a brief example. Thanks.

Regards, AB

toLowerCase is a method of the JScript String object, so would not be expected to work in that instance. Perhaps my comment does not apply to JScript since it seems to be mostly method-based, but e.g. in VBScript you could do:

DOpus.Output "Path is " & Len(DOpus.FSUtil.resolve("{apppath|excel.exe")) & " chars long."

Len is a built-in VBScript function that expects a string, so the language automatically dereferences the default value and converts it (if necessary - which it isn't in this case).

The problem as always is that the interface Opus presents is a generic, IDispatch-based one, and the individual languages all have their own grammar and their own quirks which you need to know about and deal with.

In case String("..") is too verbose, you can also just "+" an empty string to get an object toString()-conversion.
This example does not use String(), but works now, because there's +"" at the end of the first line.

var f1 = DOpus.FSUtil.resolve("/home")+""; DOpus.output(f1.toUpperCase());